aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/imagefiltersbase.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-11 18:57:00 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-11 18:57:00 +0000
commitf7efa502d62af80bd15b03e1131603fb6577c3df (patch)
tree13963631336d0186acad91eed297ae3f83224c3b /gm/imagefiltersbase.cpp
parentcae54f1f211e3c293ef9afb968067d06ca0ea23d (diff)
Implement intra-frame cacheing in image filters.
When image filters are processed within Skia, they simply do a blind recursion. This has the side-effect of turning the DAG into a tree. I.e., nodes visited more than once during the traversal will be processed more than once. This change implements a very simple cacheing scheme: a cache is created before traversing the DAG, and handed into the processing traversal. Before recursing into a child in SkImageFilter::filterImage(), the cache is checked for a hit, and early-out is performed. Otherwise, the node is processed, and its result bitmap and location (offset) are cached, but only if it contains two or more children and thus will be visited again during the traversal. Currently, the child count is approximated with the refcount. This is good enough in most cases (and exactly correct for the Chrome use case). We could add an exact child count to the image filter, but this will require violating the immutability of image filters slightly in order to bump the child count as nodes are connected. I leave it up to the reviewer to decide which is better. R=reed@google.com Author: senorblanco@chromium.org Review URL: https://codereview.chromium.org/230653005 git-svn-id: http://skia.googlecode.com/svn/trunk@14160 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/imagefiltersbase.cpp')
-rw-r--r--gm/imagefiltersbase.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp
index b31fbebe60..2970ff285a 100644
--- a/gm/imagefiltersbase.cpp
+++ b/gm/imagefiltersbase.cpp
@@ -26,7 +26,7 @@ public:
protected:
FailImageFilter() : INHERITED(0) {}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* offset) const {
+ SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE {
return false;
}
@@ -52,8 +52,9 @@ public:
protected:
IdentityImageFilter() : INHERITED(0) {}
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
- SkBitmap* result, SkIPoint* offset) const {
+ SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE {
*result = src;
+ offset->set(0, 0);
return true;
}