Chromium Code Reviews| Index: src/gpu/SkGpuDevice.cpp |
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
| index c35ff41219be49f68297780abb2303c1378be17e..8968a28c9e0b0d10537deb01b92f67707bb08edc 100644 |
| --- a/src/gpu/SkGpuDevice.cpp |
| +++ b/src/gpu/SkGpuDevice.cpp |
| @@ -40,6 +40,8 @@ |
| #include "SkVertState.h" |
| #include "SkErrorInternals.h" |
| +enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; |
| + |
| #define CACHE_COMPATIBLE_DEVICE_TEXTURES 1 |
| #if 0 |
| @@ -1424,8 +1426,7 @@ 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::GenIDCache> cache(getImageFilterCache()); |
|
bsalomon
2014/07/25 14:11:58
A comment here about tossing the textures after fi
Stephen White
2014/07/25 17:34:17
Done. Also done in SkGpuDevice::drawDevice(), whic
|
| SkImageFilter::Context ctx(matrix, clipBounds, cache); |
| if (filter_texture(this, fContext, texture, filter, w, h, ctx, &filteredBitmap, |
| &offset)) { |
| @@ -1534,9 +1535,7 @@ 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); |
| - SkImageFilter::Context ctx(matrix, clipBounds, cache); |
| + SkImageFilter::Context ctx(matrix, clipBounds, getImageFilterCache()); |
| if (filter_texture(this, fContext, devTex, filter, w, h, ctx, &filteredBitmap, |
| &offset)) { |
| devTex = filteredBitmap.getTexture(); |
| @@ -2058,3 +2057,9 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pi |
| return true; |
| } |
| + |
| +SkImageFilter::GenIDCache* SkGpuDevice::getImageFilterCache() { |
| + // We always return a transient cache, so it is freed after each |
| + // filter traversal. |
| + return SkImageFilter::GenIDCache::Create(kDefaultImageFilterCacheSize); |
| +} |