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

Unified Diff: gm/displacement.cpp

Issue 26531002: Add crop rect support for SkDisplacementMapEffect (raster and GPU paths). (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Update to new CropRect API. 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/effects/SkDisplacementMapEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/displacement.cpp
diff --git a/gm/displacement.cpp b/gm/displacement.cpp
index 503172011c6c2e5e78c3fabba92aee0a677c7ca6..587843140b92e6297f4b39b1e381c7f82b9203b1 100644
--- a/gm/displacement.cpp
+++ b/gm/displacement.cpp
@@ -60,14 +60,14 @@ protected:
}
virtual SkISize onISize() {
- return make_isize(500, 200);
+ return make_isize(500, 400);
}
void drawClippedBitmap(SkCanvas* canvas, int x, int y, const SkPaint& paint) {
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(x, y);
+ canvas->clipRect(SkRect::MakeWH(SkIntToScalar(fBitmap.width()), SkIntToScalar(fBitmap.height())));
+ canvas->drawBitmap(fBitmap, 0, 0, &paint);
canvas->restore();
}
@@ -121,6 +121,59 @@ protected:
(SkDisplacementMapEffect::kR_ChannelSelectorType,
SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->unref();
drawClippedBitmap(canvas, 400, 100, paint);
+
+ SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(30, 30, 40, 40));
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ 0.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 0, 200, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 16.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 100, 200, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 32.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 200, 200, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 48.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 300, 200, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 64.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 400, 200, paint);
+
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 0, 300, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 100, 300, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 200, 300, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 300, 300, paint);
+ paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
+ (SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect)))->unref();
+ drawClippedBitmap(canvas, 400, 300, paint);
}
private:
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/effects/SkDisplacementMapEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698