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
diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp
index e8878b5..4f6e6d2 100644
--- a/gm/strokefill.cpp
+++ b/gm/strokefill.cpp
@@ -11,8 +11,6 @@
#include "SkTextFormatParams.h"
#include "SkTypeface.h"
-namespace skiagm {
-
/* Generated on a Mac with:
* paint.setTypeface(SkTypeface::CreateByName("Papyrus"));
* paint.getTextPath("H", 1, 100, 80, &textPath);
@@ -228,31 +226,15 @@
return path;
}
-class StrokeFillGM : public GM {
-public:
- StrokeFillGM() {
-
- }
-
-protected:
-
- SkString onShortName() override {
- return SkString("stroke-fill");
- }
-
- SkISize onISize() override {
- return SkISize::Make(640, 480);
- }
-
- static void show_bold(SkCanvas* canvas, const void* text, int len,
- SkScalar x, SkScalar y, const SkPaint& paint) {
+static void show_bold(SkCanvas* canvas, const void* text, int len,
+ SkScalar x, SkScalar y, const SkPaint& paint) {
SkPaint p(paint);
canvas->drawText(text, len, x, y, p);
p.setFakeBoldText(true);
canvas->drawText(text, len, x, y + SkIntToScalar(120), p);
- }
-
- static void path_bold(SkCanvas* canvas, const SkPath& path, const SkPaint& paint) {
+}
+
+static void path_bold(SkCanvas* canvas, const SkPath& path, const SkPaint& paint) {
SkPaint p(paint);
canvas->drawPath(path, p);
p.setStyle(SkPaint::kStrokeAndFill_Style);
@@ -265,9 +247,10 @@
canvas->translate(0, 120);
canvas->drawPath(path, p);
canvas->restore();
- }
-
- void onDraw(SkCanvas* canvas) override {
+}
+
+DEF_SIMPLE_GM_BG_NAME(strokefill, canvas, 640, 480, SK_ColorWHITE,
+ SkString("stroke-fill")) {
SkScalar x = SkIntToScalar(100);
SkScalar y = SkIntToScalar(88);
@@ -347,13 +330,4 @@
SkASSERT(SkPathPriv::CheapIsFirstDirection(path4, SkPathPriv::kCW_FirstDirection));
path4.moveTo(0, 0); // test for crbug.com/247770
canvas->drawPath(path4, paint);
- }
-
-private:
- typedef GM INHERITED;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-
-DEF_GM(return new StrokeFillGM;)
}