aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-03-07 12:45:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-07 12:45:14 -0800
commit4418dbac3386f26c8da62ab242be9c178961eb18 (patch)
treed94be5d8f77cb85fd6bc908ef7ebc93357ce4908 /src/gpu
parent19de504eaee0c18cac4f840e0ca336a1e41b65eb (diff)
Swap over to using SkImageFilter::filterImage instead of filterImageDeprecated
This CL relies on https://codereview.chromium.org/1757983002/ (Add SkSpecialImage-based methods to SkImageFilter) GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1762013002 TBR=bsalomon@google.com Review URL: https://codereview.chromium.org/1762013002
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrLayerHoister.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index c39aa2007f..a446be8084 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -14,6 +14,7 @@
#include "SkGpuDevice.h"
#include "SkLayerInfo.h"
#include "SkRecordDraw.h"
+#include "SkSpecialImage.h"
#include "SkSurface.h"
#include "SkSurface_Gpu.h"
@@ -285,18 +286,14 @@ void GrLayerHoister::FilterLayer(GrContext* context,
static const int kDefaultCacheSize = 32 * 1024 * 1024;
- SkBitmap filteredBitmap;
- SkIPoint offset = SkIPoint::Make(0, 0);
-
const SkIPoint filterOffset = SkIPoint::Make(layer->srcIR().fLeft, layer->srcIR().fTop);
- SkMatrix totMat = SkMatrix::I();
- totMat.preConcat(info.fPreMat);
+ SkMatrix totMat(info.fPreMat);
totMat.preConcat(info.fLocalMat);
totMat.postTranslate(-SkIntToScalar(filterOffset.fX), -SkIntToScalar(filterOffset.fY));
SkASSERT(0 == layer->rect().fLeft && 0 == layer->rect().fTop);
- SkIRect clipBounds = layer->rect();
+ const SkIRect& clipBounds = layer->rect();
// This cache is transient, and is freed (along with all its contained
// textures) when it goes out of scope.
@@ -304,18 +301,24 @@ void GrLayerHoister::FilterLayer(GrContext* context,
SkImageFilter::Context filterContext(totMat, clipBounds, cache);
SkImageFilter::DeviceProxy proxy(device);
- SkBitmap src;
- GrWrapTextureInBitmap(layer->texture(), layer->texture()->width(), layer->texture()->height(),
- false, &src);
- if (!layer->filter()->filterImageDeprecated(&proxy, src, filterContext,
- &filteredBitmap, &offset)) {
+ // TODO: should the layer hoister store stand alone layers as SkSpecialImages internally?
+ const SkIRect subset = SkIRect::MakeWH(layer->texture()->width(), layer->texture()->height());
+ SkAutoTUnref<SkSpecialImage> img(SkSpecialImage::NewFromGpu(&proxy, subset,
+ kNeedNewImageUniqueID_SpecialImage,
+ layer->texture()));
+
+ SkIPoint offset = SkIPoint::Make(0, 0);
+ SkAutoTUnref<SkSpecialImage> result(layer->filter()->filterImage(img,
+ filterContext,
+ &offset));
+ if (!result) {
// Filtering failed. Press on with the unfiltered version.
return;
}
- SkIRect newRect = SkIRect::MakeWH(filteredBitmap.width(), filteredBitmap.height());
- layer->setTexture(filteredBitmap.getTexture(), newRect, false);
+ SkASSERT(result->peekTexture());
+ layer->setTexture(result->peekTexture(), result->subset(), false);
layer->setOffset(offset);
}