| Index: src/gpu/SkGpuDevice.cpp
|
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
|
| index 0abf9d84b5588bc00597abd67e41dac949e01262..2853805a5b1b3bcbb73e461eb4a493d01756badb 100644
|
| --- a/src/gpu/SkGpuDevice.cpp
|
| +++ b/src/gpu/SkGpuDevice.cpp
|
| @@ -41,6 +41,8 @@
|
| #include "SkXfermode.h"
|
| #include "SkErrorInternals.h"
|
|
|
| +enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 };
|
| +
|
| #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1
|
|
|
| #if 0
|
| @@ -1425,8 +1427,9 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
| SkMatrix matrix(*draw.fMatrix);
|
| matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
|
| SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height());
|
| - SkImageFilter::Cache* cache = SkImageFilter::Cache::Create();
|
| - SkAutoUnref aur(cache);
|
| + SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(getImageFilterCache());
|
| + // This cache is transient, and is freed (along with all its contained
|
| + // textures) when it goes out of scope.
|
| SkImageFilter::Context ctx(matrix, clipBounds, cache);
|
| if (filter_texture(this, fContext, texture, filter, w, h, ctx, &filteredBitmap,
|
| &offset)) {
|
| @@ -1535,8 +1538,9 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device,
|
| SkMatrix matrix(*draw.fMatrix);
|
| matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
|
| SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height());
|
| - SkImageFilter::Cache* cache = SkImageFilter::Cache::Create();
|
| - SkAutoUnref aur(cache);
|
| + // This cache is transient, and is freed (along with all its contained
|
| + // textures) when it goes out of scope.
|
| + SkAutoTUnref<SkImageFilter::UniqueIDCache> cache(getImageFilterCache());
|
| SkImageFilter::Context ctx(matrix, clipBounds, cache);
|
| if (filter_texture(this, fContext, devTex, filter, w, h, ctx, &filteredBitmap,
|
| &offset)) {
|
| @@ -2060,3 +2064,9 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi
|
|
|
| return true;
|
| }
|
| +
|
| +SkImageFilter::UniqueIDCache* SkGpuDevice::getImageFilterCache() {
|
| + // We always return a transient cache, so it is freed after each
|
| + // filter traversal.
|
| + return SkImageFilter::UniqueIDCache::Create(kDefaultImageFilterCacheSize);
|
| +}
|
|
|