From fbaea5336690ffc4fd9ee695608e9457da10eeab Mon Sep 17 00:00:00 2001 From: "senorblanco@chromium.org" Date: Tue, 27 Aug 2013 21:37:01 +0000 Subject: In image filters, apply the CTM and offset to the crop rect. This is necessary to compensate for both clipping applied by the compositor (communicated via the CTM) and for cropping applied in upstream image filters (communicated via the offset). This requires a few ugly conversions, since the crop rect is an SkIRect, and the ctm is an SkMatrix. I also had to offset the matrix passed to filter evaluation by drawSprite() and internalDrawBitmap() by the primitive position. This is the same offset that is applied when drawing the primitive, to compensate for the internal saveLayer(). Also apply the total matrix to the filter params in asNewEffect(), so that (for example) lighting params are offset by both the compositor clipping and upstream crop rects. R=reed@google.com Review URL: https://codereview.chromium.org/23295017 git-svn-id: http://skia.googlecode.com/svn/trunk@10961 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/SkGpuDevice.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gpu/SkGpuDevice.cpp') diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index ccb83111a6..f77fdf70a8 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1476,7 +1476,9 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, SkBitmap filteredBitmap; if (NULL != filter) { - if (filter_texture(this, fContext, texture, filter, w, h, SkMatrix::I(), &filteredBitmap, + SkMatrix matrix(*draw.fMatrix); + matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); + if (filter_texture(this, fContext, texture, filter, w, h, matrix, &filteredBitmap, &offset)) { texture = (GrTexture*) filteredBitmap.getTexture(); w = filteredBitmap.width(); @@ -1563,7 +1565,9 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device, if (NULL != filter) { SkIPoint offset = SkIPoint::Make(0, 0); - if (filter_texture(this, fContext, devTex, filter, w, h, SkMatrix::I(), &filteredBitmap, + SkMatrix matrix(*draw.fMatrix); + matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); + if (filter_texture(this, fContext, devTex, filter, w, h, matrix, &filteredBitmap, &offset)) { devTex = filteredBitmap.getTexture(); w = filteredBitmap.width(); -- cgit v1.2.3