diff options
author | 2016-09-21 09:46:57 -0700 | |
---|---|---|
committer | 2016-09-21 09:46:57 -0700 | |
commit | 04a44d0fd45f5596c716e99e7a3bbcc03db0e05a (patch) | |
tree | 2dbd1b8dc623cdf1a72d4ed0e2f90851265be145 /src/pdf/SkPDFDevice.cpp | |
parent | 3e8012e74f70bf49427a7422f9e5996c9882d4f3 (diff) |
Add a transient image filter cache to SkImage::makeWithFilter & PDF
Added a bench for makeWithFilter (~23 ms -> ~6 ms median locally).
Also fixed indentation.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2360663002
Review-Url: https://codereview.chromium.org/2360663002
Diffstat (limited to 'src/pdf/SkPDFDevice.cpp')
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 5299d70d0e..e79c915283 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -16,6 +16,7 @@ #include "SkDraw.h" #include "SkDrawFilter.h" #include "SkGlyphCache.h" +#include "SkImageFilterCache.h" #include "SkMakeUnique.h" #include "SkPath.h" #include "SkPathEffect.h" @@ -2286,8 +2287,8 @@ void SkPDFDevice::drawSpecial(const SkDraw& draw, SkSpecialImage* srcImg, int x, SkMatrix matrix = *draw.fMatrix; matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y); -// SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); - SkImageFilter::Context ctx(matrix, clipBounds, nullptr /*cache.get()*/); + SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache()); + SkImageFilter::Context ctx(matrix, clipBounds, cache.get()); sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg, ctx, &offset)); if (resultImg) { @@ -2316,3 +2317,9 @@ sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { return nullptr; } + +SkImageFilterCache* SkPDFDevice::getImageFilterCache() { + // We always return a transient cache, so it is freed after each + // filter traversal. + return SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize); +} |