aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/matrixconvolution.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2015-12-07 07:48:34 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-07 07:48:34 -0800
commita544eda5ddea215037b1ada6ba5cfc98f6c8ee15 (patch)
tree526b3e1de1670a1755ac169004111cf04f94298d /gm/matrixconvolution.cpp
parentd7a2c1f5fd710581d6233de5c202d3f2627948e0 (diff)
Matrix convolution bounds fix; affectsTransparentBlack fixes.
Because the convolution kernel is (currently) applied in device space, there's no way to know which object-space pixels will be touched. So return false from canComputeFastBounds(). The results from the matrixconvolution GM were actually wrong, since they were showing edge differences on the clip boundaries, where they should really only show on crop boundaries. I added a crop to the GM to keep the results the same (which are useful to test the different convolution tile modes). While I was at it, SkImageFilter::affectsTransparentBlack() was inapplicable on most things except color filters, and its use on leaf nodes was confusing. So I removed it, and made SkImageFilter::canComputeFastBounds() virtual instead. BUG=skia:4630 Review URL: https://codereview.chromium.org/1500923004
Diffstat (limited to 'gm/matrixconvolution.cpp')
-rw-r--r--gm/matrixconvolution.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp
index 6d16f8dfa7..3b159f455b 100644
--- a/gm/matrixconvolution.cpp
+++ b/gm/matrixconvolution.cpp
@@ -86,21 +86,22 @@ protected:
void onDraw(SkCanvas* canvas) override {
canvas->clear(SK_ColorBLACK);
SkIPoint kernelOffset = SkIPoint::Make(1, 0);
+ SkImageFilter::CropRect rect(SkRect::Make(fBitmap.bounds()));
for (int x = 10; x < 310; x += 100) {
- this->draw(canvas, x, 10, kernelOffset, MCIF::kClamp_TileMode, true);
- this->draw(canvas, x, 110, kernelOffset, MCIF::kClampToBlack_TileMode, true);
- this->draw(canvas, x, 210, kernelOffset, MCIF::kRepeat_TileMode, true);
+ this->draw(canvas, x, 10, kernelOffset, MCIF::kClamp_TileMode, true, &rect);
+ this->draw(canvas, x, 110, kernelOffset, MCIF::kClampToBlack_TileMode, true, &rect);
+ this->draw(canvas, x, 210, kernelOffset, MCIF::kRepeat_TileMode, true, &rect);
kernelOffset.fY++;
}
kernelOffset.fY = 1;
- SkImageFilter::CropRect rect(SkRect::MakeXYWH(10, 5, 60, 60));
- this->draw(canvas, 310, 10, kernelOffset, MCIF::kClamp_TileMode, true, &rect);
- this->draw(canvas, 310, 110, kernelOffset, MCIF::kClampToBlack_TileMode, true, &rect);
- this->draw(canvas, 310, 210, kernelOffset, MCIF::kRepeat_TileMode, true, &rect);
-
- this->draw(canvas, 410, 10, kernelOffset, MCIF::kClamp_TileMode, false);
- this->draw(canvas, 410, 110, kernelOffset, MCIF::kClampToBlack_TileMode, false);
- this->draw(canvas, 410, 210, kernelOffset, MCIF::kRepeat_TileMode, false);
+ SkImageFilter::CropRect smallRect(SkRect::MakeXYWH(10, 5, 60, 60));
+ this->draw(canvas, 310, 10, kernelOffset, MCIF::kClamp_TileMode, true, &smallRect);
+ this->draw(canvas, 310, 110, kernelOffset, MCIF::kClampToBlack_TileMode, true, &smallRect);
+ this->draw(canvas, 310, 210, kernelOffset, MCIF::kRepeat_TileMode, true, &smallRect);
+
+ this->draw(canvas, 410, 10, kernelOffset, MCIF::kClamp_TileMode, false, &rect);
+ this->draw(canvas, 410, 110, kernelOffset, MCIF::kClampToBlack_TileMode, false, &rect);
+ this->draw(canvas, 410, 210, kernelOffset, MCIF::kRepeat_TileMode, false, &rect);
}
private: