aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/imageblur.cpp
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-09-09 08:16:41 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-09 08:16:41 -0700
commit2a24338c777462e04a2b26295f9c034155ee8f3e (patch)
treecab82add826f6d77e75c8265ea960f16929033a8 /gm/imageblur.cpp
parent157e6483fb089bf4d2e5cd2c18b521e5ab4ff32a (diff)
GM: replace boilerplate with macros
I have verified locally that nothing draws differently. Motivation: * SK_SIMPLE_GM makes it easier to write a GM. * Reducing 1100 lines of code makes maintenance easier. * Simple GMs are easy to convert to Fiddles. Review URL: https://codereview.chromium.org/1333553002
Diffstat (limited to 'gm/imageblur.cpp')
-rw-r--r--gm/imageblur.cpp46
1 files changed, 7 insertions, 39 deletions
diff --git a/gm/imageblur.cpp b/gm/imageblur.cpp
index f6ac0982b7..575f02c095 100644
--- a/gm/imageblur.cpp
+++ b/gm/imageblur.cpp
@@ -12,27 +12,7 @@
#define WIDTH 500
#define HEIGHT 500
-namespace skiagm {
-
-class ImageBlurGM : public GM {
-public:
- ImageBlurGM(SkScalar sigmaX, SkScalar sigmaY, const char* suffix)
- : fSigmaX(sigmaX), fSigmaY(sigmaY) {
- this->setBGColor(0xFF000000);
- fName.printf("imageblur%s", suffix);
- }
-
-protected:
-
- SkString onShortName() override {
- return fName;
- }
-
- SkISize onISize() override {
- return SkISize::Make(WIDTH, HEIGHT);
- }
-
- void onDraw(SkCanvas* canvas) override {
+void imageblurgm_draw(SkScalar fSigmaX, SkScalar fSigmaY, SkCanvas* canvas) {
SkPaint paint;
paint.setImageFilter(SkBlurImageFilter::Create(fSigmaX, fSigmaY))->unref();
canvas->saveLayer(nullptr, &paint);
@@ -51,22 +31,10 @@ protected:
SkIntToScalar(y), textPaint);
}
canvas->restore();
- }
-
-private:
- SkScalar fSigmaX;
- SkScalar fSigmaY;
- SkString fName;
-
- typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static GM* MyFactory1(void*) { return new ImageBlurGM(24.0f, 0.0f, ""); }
-static GMRegistry reg1(MyFactory1);
-
-static GM* MyFactory2(void*) { return new ImageBlurGM(80.0f, 80.0f, "_large"); }
-static GMRegistry reg2(MyFactory2);
-
+}
+DEF_SIMPLE_GM_BG(imageblur, canvas, WIDTH, HEIGHT, SK_ColorBLACK) {
+ imageblurgm_draw(24.0f, 0.0f, canvas);
+}
+DEF_SIMPLE_GM_BG(imageblur_large, canvas, WIDTH, HEIGHT, SK_ColorBLACK) {
+ imageblurgm_draw(80.0f, 80.0f, canvas);
}