aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/displacement.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-15 19:02:43 +0000
committerGravatar senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-15 19:02:43 +0000
commit01bdf3c568f9df2df4a787197caeba736b23fe73 (patch)
tree0e7686dbb7e36597d1f7c5792780a654b3ae53e6 /gm/displacement.cpp
parentb8aa4ddb2d8b2542b3fa4df28888bcd0fee51bd4 (diff)
Add crop rect support for SkDisplacementMapEffect (raster and GPU paths).
Covered by new test cases added to displacement GM (will require rebaseline). R=bsalomon@google.com Review URL: https://codereview.chromium.org/26531002 git-svn-id: http://skia.googlecode.com/svn/trunk@11782 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/displacement.cpp')
-rw-r--r--gm/displacement.cpp61
1 files changed, 57 insertions, 4 deletions
diff --git a/gm/displacement.cpp b/gm/displacement.cpp
index 503172011c..587843140b 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: