From 13ccbf8a681d69e4685849d9dedeabea0fea7773 Mon Sep 17 00:00:00 2001 From: reed Date: Tue, 20 Oct 2015 09:56:52 -0700 Subject: [PATCH] use (temp) gpu-imagefilter-cache for applyFilter BUG=skia: Review URL: https://codereview.chromium.org/1414653003 --- src/gpu/SkGpuDevice.cpp | 10 +++++++--- src/gpu/SkGpuDevice.h | 2 ++ src/image/SkImage_Gpu.cpp | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index abccd193a1..fceacfc913 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -2015,10 +2015,14 @@ bool SkGpuDevice::EXPERIMENTAL_drawPicture(SkCanvas* mainCanvas, const SkPicture #endif } -SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { - // We always return a transient cache, so it is freed after each - // filter traversal. +SkImageFilter::Cache* SkGpuDevice::NewImageFilterCache() { return SkImageFilter::Cache::Create(kDefaultImageFilterCacheSize); } +SkImageFilter::Cache* SkGpuDevice::getImageFilterCache() { + // We always return a transient cache, so it is freed after each + // filter traversal. + return SkGpuDevice::NewImageFilterCache(); +} + #endif diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index 2e8d14e7a5..b2031e8a22 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -135,6 +135,8 @@ public: const SkImageFilter::Context&, SkBitmap* result, SkIPoint* offset); + static SkImageFilter::Cache* NewImageFilterCache(); + protected: bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) override; bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) override; diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 46196ca8b5..b1f78513ec 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -235,7 +235,8 @@ SkImage* SkImage_Gpu::onApplyFilter(SkImageFilter* filter, SkIPoint* offsetResul const SkIRect clipBounds = srcBounds; SkGpuImageFilterProxy proxy(fTexture->getContext()); - SkImageFilter::Context ctx(SkMatrix::I(), clipBounds, SkImageFilter::Cache::Get()); + SkAutoTUnref cache(SkGpuDevice::NewImageFilterCache()); + SkImageFilter::Context ctx(SkMatrix::I(), clipBounds, cache); SkBitmap dst; if (!filter->filterImage(&proxy, src, ctx, &dst, offsetResult)) {