diff options
author | 2014-04-14 15:51:48 +0000 | |
---|---|---|
committer | 2014-04-14 15:51:48 +0000 | |
commit | 1a479e7547d4efe2d1d06fab5c9442b77ec6c954 (patch) | |
tree | a2e15b7cd71e7440933cb8164f282102897f6c82 /src/core/SkCanvas.cpp | |
parent | 8f9e681093aac6c46c71df604ac685cef46309a2 (diff) |
Allow clients to specify an external SkImageFilter cache.
This change allows external callers to substitute their own
SkImageFilter cache for the default intra-frame cache in Skia. This
allows the caller to perform inter-frame caching for example, by the
maintaining a persistent cache between frames and doing custom
invalidation.
R=reed@google.com
Review URL: https://codereview.chromium.org/225903010
git-svn-id: http://skia.googlecode.com/svn/trunk@14181 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkCanvas.cpp')
-rw-r--r-- | src/core/SkCanvas.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index a3e2969514..569e9e59ba 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1258,8 +1258,12 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, SkMatrix matrix = *iter.fMatrix; matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y())); SkIRect clipBounds = SkIRect::MakeWH(srcDev->width(), srcDev->height()); - SkImageFilter::Cache* cache = SkImageFilter::Cache::Create(); - SkAutoUnref aur(cache); + SkImageFilter::Cache* cache = SkImageFilter::GetExternalCache(); + SkAutoUnref aur(NULL); + if (!cache) { + cache = SkImageFilter::Cache::Create(); + aur.reset(cache); + } SkImageFilter::Context ctx(matrix, clipBounds, cache); if (filter->filterImage(&proxy, src, ctx, &dst, &offset)) { SkPaint tmpUnfiltered(*paint); @@ -1300,8 +1304,12 @@ void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, SkMatrix matrix = *iter.fMatrix; matrix.postTranslate(SkIntToScalar(-pos.x()), SkIntToScalar(-pos.y())); SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); - SkImageFilter::Cache* cache = SkImageFilter::Cache::Create(); - SkAutoUnref aur(cache); + SkImageFilter::Cache* cache = SkImageFilter::GetExternalCache(); + SkAutoUnref aur(NULL); + if (!cache) { + cache = SkImageFilter::Cache::Create(); + aur.reset(cache); + } SkImageFilter::Context ctx(matrix, clipBounds, cache); if (filter->filterImage(&proxy, bitmap, ctx, &dst, &offset)) { SkPaint tmpUnfiltered(*paint); |