aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/matriximagefilter.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/matriximagefilter.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/matriximagefilter.cpp')
-rw-r--r--gm/matriximagefilter.cpp41
1 files changed, 6 insertions, 35 deletions
diff --git a/gm/matriximagefilter.cpp b/gm/matriximagefilter.cpp
index b4242a7e60..3b4c0f6ecb 100644
--- a/gm/matriximagefilter.cpp
+++ b/gm/matriximagefilter.cpp
@@ -9,21 +9,8 @@
#include "SkColor.h"
#include "SkImageFilter.h"
-namespace skiagm {
-
-class MatrixImageFilterGM : public GM {
-public:
- MatrixImageFilterGM() {
- this->setBGColor(0x00000000);
- }
-
-protected:
- virtual SkString onShortName() {
- return SkString("matriximagefilter");
- }
-
- void draw(SkCanvas* canvas, const SkRect& rect, const SkBitmap& bitmap,
- const SkMatrix& matrix, SkFilterQuality filter) {
+static void draw(SkCanvas* canvas, const SkRect& rect, const SkBitmap& bitmap,
+ const SkMatrix& matrix, SkFilterQuality filter) {
SkAutoTUnref<SkImageFilter> imageFilter(
SkImageFilter::CreateMatrixFilter(matrix, filter));
SkPaint paint;
@@ -31,13 +18,9 @@ protected:
canvas->saveLayer(&rect, &paint);
canvas->drawBitmap(bitmap, 0, 0);
canvas->restore();
- }
-
- virtual SkISize onISize() {
- return SkISize::Make(420, 100);
- }
+}
- void make_checkerboard(SkBitmap* bitmap) {
+static void make_checkerboard(SkBitmap* bitmap) {
bitmap->allocN32Pixels(64, 64);
SkCanvas canvas(*bitmap);
SkPaint darkPaint;
@@ -55,10 +38,9 @@ protected:
canvas.restore();
}
}
- }
+}
- virtual void onDraw(SkCanvas* canvas) {
- canvas->clear(SK_ColorBLACK);
+DEF_SIMPLE_GM_BG(matriximagefilter, canvas, 420, 100, SK_ColorBLACK) {
SkMatrix matrix;
SkScalar margin = SkIntToScalar(10);
matrix.setSkew(SkDoubleToScalar(0.5), SkDoubleToScalar(0.2));
@@ -81,15 +63,4 @@ protected:
canvas->translate(srcRect.width() + margin, 0);
draw(canvas, srcRect, checkerboard, matrix, kHigh_SkFilterQuality);
#endif
- }
-
-private:
- typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-static GM* MyFactory(void*) { return new MatrixImageFilterGM; }
-static GMRegistry reg(MyFactory);
-
}