gm: delete boilerplate

Change-Id: I1fdcbadf8ec587637edfca29cd34f845a11ef045
Reviewed-on: https://skia-review.googlesource.com/c/186083
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2019-01-23 10:40:02 -05:00 committed by Skia Commit-Bot
parent c7601bf508
commit 607c44fa25
4 changed files with 20 additions and 183 deletions

View File

@ -12,21 +12,7 @@
#define W 800 #define W 800
#define H 800 #define H 800
class AnalyticAntiAliasConvexGM : public skiagm::GM { DEF_SIMPLE_GM(analytic_antialias_convex, canvas, W, H) {
public:
AnalyticAntiAliasConvexGM() {}
protected:
SkString onShortName() override {
return SkString("analytic_antialias_convex");
}
SkISize onISize() override {
return SkISize::Make(W, H);
}
void onDraw(SkCanvas* canvas) override {
SkPaint p; SkPaint p;
p.setColor(SK_ColorRED); p.setColor(SK_ColorRED);
p.setAntiAlias(true); p.setAntiAlias(true);
@ -98,27 +84,9 @@ protected:
path.lineTo(710, 534); path.lineTo(710, 534);
path.lineTo(700, 534); path.lineTo(700, 534);
canvas->drawPath(path, p); canvas->drawPath(path, p);
} }
private: DEF_SIMPLE_GM(analytic_antialias_general, canvas, W, H) {
typedef skiagm::GM INHERITED;
};
class AnalyticAntiAliasGeneralGM : public skiagm::GM {
public:
AnalyticAntiAliasGeneralGM() {}
protected:
SkString onShortName() override {
return SkString("analytic_antialias_general");
}
SkISize onISize() override {
return SkISize::Make(W, H);
}
void onDraw(SkCanvas* canvas) override {
SkPaint p; SkPaint p;
p.setColor(SK_ColorRED); p.setColor(SK_ColorRED);
p.setAntiAlias(true); p.setAntiAlias(true);
@ -162,27 +130,9 @@ protected:
path.addRect({20, 20, 100.1f, 100}); path.addRect({20, 20, 100.1f, 100});
path.addRect({100.9f, 20, 200, 100}); path.addRect({100.9f, 20, 200, 100});
canvas->drawPath(path, p); canvas->drawPath(path, p);
} }
private: DEF_SIMPLE_GM(analytic_antialias_inverse, canvas, W, H) {
typedef skiagm::GM INHERITED;
};
class AnalyticAntiAliasInverseGM : public skiagm::GM {
public:
AnalyticAntiAliasInverseGM() {}
protected:
SkString onShortName() override {
return SkString("analytic_antialias_inverse");
}
SkISize onISize() override {
return SkISize::Make(W, H);
}
void onDraw(SkCanvas* canvas) override {
SkPaint p; SkPaint p;
p.setColor(SK_ColorRED); p.setColor(SK_ColorRED);
p.setAntiAlias(true); p.setAntiAlias(true);
@ -194,12 +144,4 @@ protected:
path.setFillType(SkPath::kInverseWinding_FillType); path.setFillType(SkPath::kInverseWinding_FillType);
canvas->drawPath(path, p); canvas->drawPath(path, p);
canvas->restore(); canvas->restore();
} }
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new AnalyticAntiAliasConvexGM; )
DEF_GM( return new AnalyticAntiAliasGeneralGM; )
DEF_GM( return new AnalyticAntiAliasInverseGM; )

View File

@ -124,23 +124,7 @@ static void draw_rect_tests(SkCanvas* canvas) {
Each region should show as a blue center surrounded by a 2px green Each region should show as a blue center surrounded by a 2px green
border, with no red. border, with no red.
*/ */
DEF_SIMPLE_GM(aaclip, canvas, 240, 120) {
class AAClipGM : public skiagm::GM {
public:
AAClipGM() {
}
protected:
SkString onShortName() override {
return SkString("aaclip");
}
SkISize onISize() override {
return SkISize::Make(240, 120);
}
void onDraw(SkCanvas* canvas) override {
// Initial pixel-boundary-aligned draw // Initial pixel-boundary-aligned draw
draw_rect_tests(canvas); draw_rect_tests(canvas);
@ -160,13 +144,7 @@ protected:
canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5); canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5);
canvas->translate(SkIntToScalar(50), 0); canvas->translate(SkIntToScalar(50), 0);
draw_rect_tests(canvas); draw_rect_tests(canvas);
} }
private:
typedef skiagm::GM INHERITED;
};
DEF_GM(return new AAClipGM;)
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
@ -210,20 +188,7 @@ static void test_image(SkCanvas* canvas, const SkImageInfo& info) {
CGImageRelease(image); CGImageRelease(image);
} }
class CGImageGM : public skiagm::GM { DEF_SIMPLE_GM(cgimage, canvas, 800, 250) {
public:
CGImageGM() {}
protected:
SkString onShortName() override {
return SkString("cgimage");
}
SkISize onISize() override {
return SkISize::Make(800, 250);
}
void onDraw(SkCanvas* canvas) override {
const struct { const struct {
SkColorType fCT; SkColorType fCT;
SkAlphaType fAT; SkAlphaType fAT;
@ -244,12 +209,8 @@ protected:
test_image(canvas, info); test_image(canvas, info);
canvas->translate(info.width() + 10, 0); canvas->translate(info.width() + 10, 0);
} }
} }
private:
typedef skiagm::GM INHERITED;
};
//DEF_GM( return new CGImageGM; )
#endif #endif
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -115,24 +115,9 @@ static sk_sp<SkShader> make_bg_shader() {
&m); &m);
} }
namespace skiagm { DEF_SIMPLE_GM(aarectmodes, canvas, 640, 480) {
SkPaint bgPaint;
class AARectModesGM : public GM { bgPaint.setShader(make_bg_shader());
SkPaint fBGPaint;
public:
AARectModesGM () {
fBGPaint.setShader(make_bg_shader());
}
protected:
SkString onShortName() override {
return SkString("aarectmodes");
}
SkISize onISize() override { return SkISize::Make(640, 480); }
void onDraw(SkCanvas* canvas) override {
if (false) { // avoid bit rot, suppress warning if (false) { // avoid bit rot, suppress warning
test4(canvas); test4(canvas);
} }
@ -150,7 +135,7 @@ namespace skiagm {
canvas->translate(W * 5, 0); canvas->translate(W * 5, 0);
canvas->save(); canvas->save();
} }
canvas->drawRect(bounds, fBGPaint); canvas->drawRect(bounds, bgPaint);
canvas->saveLayer(&bounds, nullptr); canvas->saveLayer(&bounds, nullptr);
SkScalar dy = drawCell(canvas, gModes[i], SkScalar dy = drawCell(canvas, gModes[i],
gAlphaValue[alpha & 1], gAlphaValue[alpha & 1],
@ -163,13 +148,4 @@ namespace skiagm {
canvas->restore(); canvas->restore();
canvas->translate(W * 5 / 4, 0); canvas->translate(W * 5 / 4, 0);
} }
}
private:
typedef GM INHERITED;
};
//////////////////////////////////////////////////////////////////////////////
DEF_GM( return new AARectModesGM; );
} }

View File

@ -67,16 +67,7 @@ DEF_GM( return new AddArcGM; )
#define R 400 #define R 400
class AddArcMeasGM : public skiagm::GM { DEF_SIMPLE_GM(addarc_meas, canvas, 2*R + 40, 2*R + 40) {
public:
AddArcMeasGM() {}
protected:
SkString onShortName() override { return SkString("addarc_meas"); }
SkISize onISize() override { return SkISize::Make(2*R + 40, 2*R + 40); }
void onDraw(SkCanvas* canvas) override {
canvas->translate(R + 20, R + 20); canvas->translate(R + 20, R + 20);
SkPaint paint; SkPaint paint;
@ -106,12 +97,7 @@ protected:
canvas->drawLine({0, 0}, pos, measPaint); canvas->drawLine({0, 0}, pos, measPaint);
} }
} }
} }
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new AddArcMeasGM; )
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
@ -230,16 +216,7 @@ static void html_canvas_arc(SkPath* path, SkScalar x, SkScalar y, SkScalar r, Sk
} }
// Lifted from canvas-arc-circumference-fill-diffs.html // Lifted from canvas-arc-circumference-fill-diffs.html
class ManyArcsGM : public skiagm::GM { DEF_SIMPLE_GM(manyarcs, canvas, 620, 330) {
public:
ManyArcsGM() {}
protected:
SkString onShortName() override { return SkString("manyarcs"); }
SkISize onISize() override { return SkISize::Make(620, 330); }
void onDraw(SkCanvas* canvas) override {
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
@ -281,24 +258,10 @@ protected:
canvas->restore(); canvas->restore();
canvas->translate(0, 40); canvas->translate(0, 40);
} }
} }
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new ManyArcsGM; )
// Lifted from https://bugs.chromium.org/p/chromium/issues/detail?id=640031 // Lifted from https://bugs.chromium.org/p/chromium/issues/detail?id=640031
class TinyAngleBigRadiusArcsGM : public skiagm::GM { DEF_SIMPLE_GM(tinyanglearcs, canvas, 620, 330) {
public:
TinyAngleBigRadiusArcsGM() {}
protected:
SkString onShortName() override { return SkString("tinyanglearcs"); }
SkISize onISize() override { return SkISize::Make(620, 330); }
void onDraw(SkCanvas* canvas) override {
SkPaint paint; SkPaint paint;
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style); paint.setStyle(SkPaint::kStroke_Style);
@ -331,9 +294,4 @@ protected:
canvas->drawPath(path, paint); canvas->drawPath(path, paint);
canvas->translate(20, 0); canvas->translate(20, 0);
} }
} }
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new TinyAngleBigRadiusArcsGM; )