diff options
author | halcanary <halcanary@google.com> | 2015-09-09 08:16:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-09 08:16:41 -0700 |
commit | 2a24338c777462e04a2b26295f9c034155ee8f3e (patch) | |
tree | cab82add826f6d77e75c8265ea960f16929033a8 /gm/shadertext2.cpp | |
parent | 157e6483fb089bf4d2e5cd2c18b521e5ab4ff32a (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/shadertext2.cpp')
-rw-r--r-- | gm/shadertext2.cpp | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/gm/shadertext2.cpp b/gm/shadertext2.cpp index 8ceb5e494b..74f01a0c9d 100644 --- a/gm/shadertext2.cpp +++ b/gm/shadertext2.cpp @@ -9,8 +9,6 @@ #include "SkGradientShader.h" #include "SkPath.h" -namespace skiagm { - static void makebm(SkBitmap* bm, int w, int h) { bm->allocN32Pixels(w, h); bm->eraseColor(SK_ColorTRANSPARENT); @@ -41,21 +39,8 @@ struct LabeledMatrix { const char* fLabel; }; -class ShaderText2GM : public GM { -public: - ShaderText2GM() { - this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); - } - -protected: - - SkString onShortName() override { - return SkString("shadertext2"); - } - - SkISize onISize() override { return SkISize::Make(1800, 900); } - - void onDraw(SkCanvas* canvas) override { +DEF_SIMPLE_GM_BG(shadertext2, canvas, 1800, 900, + sk_tool_utils::color_to_565(0xFFDDDDDD)) { static const char kText[] = "SKIA"; static const int kTextLen = SK_ARRAY_COUNT(kText) - 1; static const int kPointSize = 55; @@ -198,14 +183,4 @@ protected: canvas->drawText(kStrokeLabel, strlen(kStrokeLabel), strokeX, y, labelPaint); } } - } - -private: - typedef GM INHERITED; -}; - -/////////////////////////////////////////////////////////////////////////////// - -static GM* MyFactory(void*) { return new ShaderText2GM; } -static GMRegistry reg(MyFactory); } |