Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 414483003: Implement a persistent uniqueID-based cache for SkImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Undo some unnecessary reformatting. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+}

Powered by Google App Engine
This is Rietveld 408576698