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/dashcubics.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/dashcubics.cpp')
-rw-r--r-- | gm/dashcubics.cpp | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp index ecbe41537b..1773303f0c 100644 --- a/gm/dashcubics.cpp +++ b/gm/dashcubics.cpp @@ -14,22 +14,8 @@ /* * Inspired by http://code.google.com/p/chromium/issues/detail?id=112145 */ - -class DashCubicsGM : public skiagm::GM { -public: - DashCubicsGM() {} - -protected: - - virtual SkString onShortName() { - return SkString("dashcubics"); - } - - virtual SkISize onISize() { - return SkISize::Make(860, 700); - } - - void flower(SkCanvas* canvas, const SkPath& path, SkScalar intervals[2], SkPaint::Join join) { +static void flower(SkCanvas* canvas, const SkPath& path, + SkScalar intervals[2], SkPaint::Join join) { SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 0); SkPaint paint; @@ -48,9 +34,9 @@ protected: paint.setPathEffect(nullptr); paint.setStrokeWidth(0); canvas->drawPath(path, paint); - } +} - virtual void onDraw(SkCanvas* canvas) { +DEF_SIMPLE_GM(dashcubics, canvas, 860, 700) { SkPath path; const char* d = "M 337,98 C 250,141 250,212 250,212 C 250,212 250,212 250,212" "C 250,212 250,212 250,212 C 250,212 250,141 163,98 C 156,195 217,231 217,231" @@ -73,13 +59,4 @@ protected: canvas->restore(); } } - } - -private: - typedef GM INHERITED; -}; - -////////////////////////////////////////////////////////////////////////////// - -static skiagm::GM* MyFactory(void*) { return new DashCubicsGM; } -static skiagm::GMRegistry reg(MyFactory); +} |