diff options
author | 2015-10-20 10:17:34 -0700 | |
---|---|---|
committer | 2015-10-20 10:17:34 -0700 | |
commit | 1d3ff434954189e194c468f429598465146dcf4b (patch) | |
tree | b26baea51421dca92277b8adfca8f24dcb1a3d62 /src/effects/SkBlurImageFilter.cpp | |
parent | 0bccd8749bdce79b2d71518fe65783b1a9b06445 (diff) |
Image filters: Replace all use of tryAllocPixels() with createDevice().
In order to have a central pinch point for bitmap allocation, change all
filters to use Proxy::createDevice() instead of allocating memory
directly with SkBitmap::tryAllocPixels().
This will aid in moving filter backing stores and caches to
discardable memory.
BUG=skia:
Review URL: https://codereview.chromium.org/1414843003
Diffstat (limited to 'src/effects/SkBlurImageFilter.cpp')
-rw-r--r-- | src/effects/SkBlurImageFilter.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index 20976968fe..8398f48b7f 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -8,6 +8,7 @@ #include "SkBitmap.h" #include "SkBlurImageFilter.h" #include "SkColorPriv.h" +#include "SkDevice.h" #include "SkGpuBlurUtils.h" #include "SkOpts.h" #include "SkReadBuffer.h" @@ -90,9 +91,12 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy, return false; } - if (!dst->tryAllocPixels(src.info().makeWH(srcBounds.width(), srcBounds.height()))) { + SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(srcBounds.width(), srcBounds.height())); + if (!device) { return false; } + *dst = device->accessBitmap(false); + SkAutoLockPixels alp_dst(*dst); dst->getBounds(&dstBounds); SkVector sigma = mapSigma(fSigma, ctx.ctm()); @@ -113,10 +117,12 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy, return true; } - SkBitmap temp; - if (!temp.tryAllocPixels(dst->info())) { + SkAutoTUnref<SkBaseDevice> tempDevice(proxy->createDevice(dst->width(), dst->height())); + if (!tempDevice) { return false; } + SkBitmap temp = tempDevice->accessBitmap(false); + SkAutoLockPixels alpTemp(temp); offset->fX = srcBounds.fLeft; offset->fY = srcBounds.fTop; |