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

Unified Diff: gm/displacement.cpp

Issue 182983003: Factory methods for heap-allocated SkImageFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase Created 6 years, 9 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 | « gm/colorfilterimagefilter.cpp ('k') | gm/dropshadowimagefilter.cpp » ('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 b1f097b8bf848f0eaa3477f4098e778695bb39d7..af7c772532e21e7f596ab1d176ee1a6134d40651 100644
--- a/gm/displacement.cpp
+++ b/gm/displacement.cpp
@@ -83,135 +83,135 @@ protected:
}
canvas->clear(0x00000000);
SkPaint paint;
- SkAutoTUnref<SkImageFilter> displ(SkNEW_ARGS(SkBitmapSource, (fCheckerboard)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ)))->unref();
+ SkAutoTUnref<SkImageFilter> displ(SkBitmapSource::Create(fCheckerboard));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 0.0f, displ))->unref();
drawClippedBitmap(canvas, 0, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 16.0f, displ))->unref();
drawClippedBitmap(canvas, 100, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 32.0f, displ))->unref();
drawClippedBitmap(canvas, 200, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 48.0f, displ))->unref();
drawClippedBitmap(canvas, 300, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 64.0f, displ))->unref();
drawClippedBitmap(canvas, 400, 0, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 0, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 100, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 200, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ))->unref();
drawClippedBitmap(canvas, 300, 100, paint);
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType, 40.0f, displ)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ 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();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ, NULL, &cropRect))->unref();
drawClippedBitmap(canvas, 400, 300, paint);
// Tests for images of different sizes
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fSmall)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kG_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fSmall));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 0, 400, paint);
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fLarge)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kB_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fLarge));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 100, 400, paint);
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeW)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kR_ChannelSelectorType,
- SkDisplacementMapEffect::kB_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fLargeW));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kR_ChannelSelectorType,
+ SkDisplacementMapEffect::kB_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 200, 400, paint);
- displ.reset(SkNEW_ARGS(SkBitmapSource, (fLargeH)));
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, displ)))->unref();
+ displ.reset(SkBitmapSource::Create(fLargeH));
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, displ))->unref();
drawClippedBitmap(canvas, 300, 400, paint);
// Test for no given displacement input. In this case, both displacement
// and color should use the same bitmap, given to SkCanvas::drawBitmap()
// as an input argument.
- paint.setImageFilter(SkNEW_ARGS(SkDisplacementMapEffect,
- (SkDisplacementMapEffect::kG_ChannelSelectorType,
- SkDisplacementMapEffect::kA_ChannelSelectorType,
- 40.0f, NULL)))->unref();
+ paint.setImageFilter(SkDisplacementMapEffect::Create(
+ SkDisplacementMapEffect::kG_ChannelSelectorType,
+ SkDisplacementMapEffect::kA_ChannelSelectorType,
+ 40.0f, NULL))->unref();
drawClippedBitmap(canvas, 400, 400, paint);
}
« no previous file with comments | « gm/colorfilterimagefilter.cpp ('k') | gm/dropshadowimagefilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698