Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Unified Diff: gm/matrixconvolution.cpp

Issue 27471002: Implement crop rect support for SkMatrixConvolutionImageFilter. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix style issue Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/matrixconvolution.cpp
diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp
index 853b57be072b1a293e7feecfb9f6cd301e83cb3e..5c443da3ff39fc0905b7f79048ef0ee5a85e7d04 100644
--- a/gm/matrixconvolution.cpp
+++ b/gm/matrixconvolution.cpp
@@ -44,10 +44,12 @@ protected:
}
virtual SkISize onISize() {
- return make_isize(400, 300);
+ return make_isize(500, 300);
}
- void draw(SkCanvas* canvas, int x, int y, const SkIPoint& target, SkMatrixConvolutionImageFilter::TileMode tileMode, bool convolveAlpha) {
+ void draw(SkCanvas* canvas, int x, int y, const SkIPoint& target,
+ SkMatrixConvolutionImageFilter::TileMode tileMode, bool convolveAlpha,
+ const SkImageFilter::CropRect* cropRect = NULL) {
SkScalar kernel[9] = {
SkIntToScalar( 1), SkIntToScalar( 1), SkIntToScalar( 1),
SkIntToScalar( 1), SkIntToScalar(-7), SkIntToScalar( 1),
@@ -56,15 +58,27 @@ protected:
SkISize kernelSize = SkISize::Make(3, 3);
SkScalar gain = SkFloatToScalar(0.3f), bias = SkIntToScalar(100);
SkPaint paint;
- SkAutoTUnref<SkImageFilter> filter(SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize, kernel, gain, bias, target, tileMode, convolveAlpha)));
+ SkAutoTUnref<SkImageFilter> filter(
+ SkNEW_ARGS(SkMatrixConvolutionImageFilter, (kernelSize,
+ kernel,
+ gain,
+ bias,
+ target,
+ tileMode,
+ convolveAlpha,
+ NULL,
+ cropRect)));
paint.setImageFilter(filter);
canvas->save();
- canvas->clipRect(SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y),
- SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height())));
- canvas->drawBitmap(fBitmap, SkIntToScalar(x), SkIntToScalar(y), &paint);
+ canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
+ canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()),
+ SkIntToScalar(fBitmap.height())));
+ canvas->drawBitmap(fBitmap, 0, 0, &paint);
canvas->restore();
}
+ typedef SkMatrixConvolutionImageFilter MCIF;
+
virtual void onDraw(SkCanvas* canvas) {
if (!fInitialized) {
make_bitmap();
@@ -73,15 +87,20 @@ protected:
canvas->clear(0x00000000);
SkIPoint target = SkIPoint::Make(1, 0);
for (int x = 10; x < 310; x += 100) {
- draw(canvas, x, 10, target, SkMatrixConvolutionImageFilter::kClamp_TileMode, true);
- draw(canvas, x, 110, target, SkMatrixConvolutionImageFilter::kClampToBlack_TileMode, true);
- draw(canvas, x, 210, target, SkMatrixConvolutionImageFilter::kRepeat_TileMode, true);
+ this->draw(canvas, x, 10, target, MCIF::kClamp_TileMode, true);
+ this->draw(canvas, x, 110, target, MCIF::kClampToBlack_TileMode, true);
+ this->draw(canvas, x, 210, target, MCIF::kRepeat_TileMode, true);
target.fY++;
}
target.fY = 1;
- draw(canvas, 310, 10, target, SkMatrixConvolutionImageFilter::kClamp_TileMode, false);
- draw(canvas, 310, 110, target, SkMatrixConvolutionImageFilter::kClampToBlack_TileMode, false);
- draw(canvas, 310, 210, target, SkMatrixConvolutionImageFilter::kRepeat_TileMode, false);
+ SkImageFilter::CropRect rect(SkRect::MakeXYWH(10, 10, 60, 60));
+ this->draw(canvas, 310, 10, target, MCIF::kClamp_TileMode, true, &rect);
+ this->draw(canvas, 310, 110, target, MCIF::kClampToBlack_TileMode, true, &rect);
+ this->draw(canvas, 310, 210, target, MCIF::kRepeat_TileMode, true, &rect);
+
+ this->draw(canvas, 410, 10, target, MCIF::kClamp_TileMode, false);
+ this->draw(canvas, 410, 110, target, MCIF::kClampToBlack_TileMode, false);
+ this->draw(canvas, 410, 210, target, MCIF::kRepeat_TileMode, false);
}
private:
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/core/SkImageFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698