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/clipdrawdraw.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/clipdrawdraw.cpp')
-rw-r--r-- | gm/clipdrawdraw.cpp | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/gm/clipdrawdraw.cpp b/gm/clipdrawdraw.cpp index aa635d97a9..1aecb9ff3b 100644 --- a/gm/clipdrawdraw.cpp +++ b/gm/clipdrawdraw.cpp @@ -7,8 +7,6 @@ #include "gm.h" -namespace skiagm { - // This GM exercises the use case found in crbug.com/423834. // The following pattern: // save(); @@ -18,16 +16,7 @@ namespace skiagm { // // drawRect(rect, noAA); // can leave 1 pixel wide remnants of the first rect. -class ClipDrawDrawGM : public GM { -public: - ClipDrawDrawGM() { this->setBGColor(sk_tool_utils::color_to_565(0xFFCCCCCC)); } - -protected: - SkString onShortName() override { return SkString("clipdrawdraw"); } - - SkISize onISize() override { return SkISize::Make(512, 512); } - - static void Draw(SkCanvas* canvas, const SkRect& rect) { +static void Draw(SkCanvas* canvas, const SkRect& rect) { SkPaint p; p.setAntiAlias(false); @@ -44,9 +33,10 @@ protected: p.setColor(SK_ColorWHITE); canvas->drawRect(rect, p); canvas->restore(); - } +} - void onDraw(SkCanvas* canvas) override { +DEF_SIMPLE_GM_BG(clipdrawdraw, canvas, 512, 512, + sk_tool_utils::color_to_565(0xFFCCCCCC)) { // Vertical remnant const SkRect rect1 = SkRect::MakeLTRB(136.5f, 137.5f, 338.5f, 293.5f); @@ -56,13 +46,4 @@ protected: Draw(canvas, rect1); Draw(canvas, rect2); - } - -private: - typedef GM INHERITED; -}; - -////////////////////////////////////////////////////////////////////////////// - -DEF_GM(return new ClipDrawDrawGM;) } |