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/inversepaths.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/inversepaths.cpp')
-rw-r--r-- | gm/inversepaths.cpp | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/gm/inversepaths.cpp b/gm/inversepaths.cpp index ae54bee218..92ea051d12 100644 --- a/gm/inversepaths.cpp +++ b/gm/inversepaths.cpp @@ -9,8 +9,6 @@ #include "SkCanvas.h" #include "SkPath.h" -namespace skiagm { - static SkPath generate_square(SkScalar cx, SkScalar cy, SkScalar w) { SkRect rect = SkRect::MakeXYWH(cx - w / 2, cy - w / 2, w, w); SkPath path; @@ -38,6 +36,7 @@ static SkPath generate_line(SkScalar cx, SkScalar cy, SkScalar l) { return path; } +namespace { SkPaint::Style styles[] = { SkPaint::kStroke_Style, SkPaint::kStrokeAndFill_Style, @@ -62,24 +61,9 @@ SkPath ((*paths[])(SkScalar, SkScalar, SkScalar)) = { const SkScalar slideWidth = 90, slideHeight = 90; const SkScalar slideBoundary = 5; +} // namespace -class InversePathsGM : public GM { -public: - InversePathsGM() { - - } - -protected: - - SkString onShortName() override { - return SkString("inverse_paths"); - } - - SkISize onISize() override { - return SkISize::Make(800, 900); - } - - void onDraw(SkCanvas* canvas) override { +DEF_SIMPLE_GM(inverse_paths, canvas, 800, 900) { SkScalar cx = slideWidth / 2 + slideBoundary; SkScalar cy = slideHeight / 2 + slideBoundary; SkScalar dx = slideWidth + 2 * slideBoundary; @@ -137,11 +121,4 @@ protected: canvas->translate(0, dy); } } - } - -private: - typedef GM INHERITED; -}; - -DEF_GM( return new InversePathsGM; ) } |