aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-29 15:20:39 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-29 15:20:39 +0000
commit0a5c233e3b911232c0d6f9a88ded99ecf88b8a97 (patch)
tree54bc91597d65bb936d65f595555f7677dd1cd597 /src
parentdaaafa6e81860e3dc52660ba019c336f0a43f1e7 (diff)
Implement bounds traversals for tile and matrix convolution filters.
Add a new GM that exercises tiled drawing all pixel-moving filters (and some non-pixel-moving ones) and compares it against non-tiled drawing of the same filters. Fixing this test revealed that tile and matrix convolution filters had no onFilterBounds() traversals (test-driven development FTW). Tile requires (conservatively) the bounds to include the whole source rect, since it may end up in the result. Matrix convolution requires the bounds to be offset by the kernel size and target. R=reed@google.com BUG=skia: Review URL: https://codereview.chromium.org/258243005 git-svn-id: http://skia.googlecode.com/svn/trunk@14432 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkMatrixConvolutionImageFilter.cpp13
-rw-r--r--src/effects/SkTileImageFilter.cpp11
2 files changed, 24 insertions, 0 deletions
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp
index 878cbae795..3c9fc87787 100644
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp
@@ -306,6 +306,19 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy,
return true;
}
+bool SkMatrixConvolutionImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ SkIRect* dst) const {
+ SkIRect bounds = src;
+ bounds.fRight += fKernelSize.width() - 1;
+ bounds.fBottom += fKernelSize.height() - 1;
+ bounds.offset(-fKernelOffset);
+ if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
+ return false;
+ }
+ *dst = bounds;
+ return true;
+}
+
#if SK_SUPPORT_GPU
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp
index f3bad76345..73c0a581e9 100644
--- a/src/effects/SkTileImageFilter.cpp
+++ b/src/effects/SkTileImageFilter.cpp
@@ -75,6 +75,17 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
return true;
}
+bool SkTileImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
+ SkIRect* dst) const {
+ SkRect srcRect;
+ ctm.mapRect(&srcRect, fSrcRect);
+ SkIRect srcIRect;
+ srcRect.roundOut(&srcIRect);
+ srcIRect.join(src);
+ *dst = srcIRect;
+ return true;
+}
+
SkTileImageFilter::SkTileImageFilter(SkReadBuffer& buffer)
: INHERITED(1, buffer) {
buffer.readRect(&fSrcRect);