diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-14 15:44:01 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-14 15:44:01 +0000 |
commit | 4cb543d6057b692e1099e9f115155f0bf323a0c8 (patch) | |
tree | 66f8cbe4e7ef74221766ade874096f934c8b2031 /src/gpu | |
parent | 0d30c51c6cf45b3a08a3000b6d348c16bdec7f05 (diff) |
Implement support for a Context parameter in image filters
Some upcoming work (support for expanding crop rects) requires
the clip bounds to be available during filter traversal. This change
replaces the SkMatrix parameter in the onFilterImage() traversals
with a Context parameter. It contains the CTM, as well as the clip
bounds.
BUG=skia:
R=reed@google.com
Review URL: https://codereview.chromium.org/189913021
git-svn-id: http://skia.googlecode.com/svn/trunk@13803 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index ed80c50581..e872f1ac97 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1588,8 +1588,8 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, static bool filter_texture(SkBaseDevice* device, GrContext* context, GrTexture* texture, const SkImageFilter* filter, - int w, int h, const SkMatrix& ctm, SkBitmap* result, - SkIPoint* offset) { + int w, int h, const SkImageFilter::Context& ctx, + SkBitmap* result, SkIPoint* offset) { SkASSERT(filter); SkDeviceImageFilterProxy proxy(device); @@ -1597,7 +1597,7 @@ static bool filter_texture(SkBaseDevice* device, GrContext* context, // Save the render target and set it to NULL, so we don't accidentally draw to it in the // filter. Also set the clip wide open and the matrix to identity. GrContext::AutoWideOpenIdentityDraw awo(context, NULL); - return filter->filterImageGPU(&proxy, wrap_texture(texture), ctm, result, offset); + return filter->filterImageGPU(&proxy, wrap_texture(texture), ctx, result, offset); } else { return false; } @@ -1628,7 +1628,9 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, SkIPoint offset = SkIPoint::Make(0, 0); SkMatrix matrix(*draw.fMatrix); matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top)); - if (filter_texture(this, fContext, texture, filter, w, h, matrix, &filteredBitmap, + SkIRect clipBounds = SkIRect::MakeWH(bitmap.width(), bitmap.height()); + SkImageFilter::Context ctx(matrix, clipBounds); + if (filter_texture(this, fContext, texture, filter, w, h, ctx, &filteredBitmap, &offset)) { texture = (GrTexture*) filteredBitmap.getTexture(); w = filteredBitmap.width(); @@ -1734,7 +1736,9 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, SkIPoint offset = SkIPoint::Make(0, 0); SkMatrix matrix(*draw.fMatrix); matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y)); - if (filter_texture(this, fContext, devTex, filter, w, h, matrix, &filteredBitmap, + SkIRect clipBounds = SkIRect::MakeWH(devTex->width(), devTex->height()); + SkImageFilter::Context ctx(matrix, clipBounds); + if (filter_texture(this, fContext, devTex, filter, w, h, ctx, &filteredBitmap, &offset)) { devTex = filteredBitmap.getTexture(); w = filteredBitmap.width(); @@ -1771,7 +1775,7 @@ bool SkGpuDevice::canHandleImageFilter(const SkImageFilter* filter) { } bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, - const SkMatrix& ctm, + const SkImageFilter::Context& ctx, SkBitmap* result, SkIPoint* offset) { // want explicitly our impl, so guard against a subclass of us overriding it if (!this->SkGpuDevice::canHandleImageFilter(filter)) { @@ -1788,8 +1792,8 @@ bool SkGpuDevice::filterImage(const SkImageFilter* filter, const SkBitmap& src, // must be pushed upstack. SkAutoCachedTexture act(this, src, NULL, &texture); - return filter_texture(this, fContext, texture, filter, src.width(), src.height(), ctm, result, - offset); + return filter_texture(this, fContext, texture, filter, src.width(), src.height(), ctx, + result, offset); } /////////////////////////////////////////////////////////////////////////////// |