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 H 800
class AnalyticAntiAliasConvexGM : public skiagm::GM {
public:
AnalyticAntiAliasConvexGM() {}
protected:
SkString onShortName() override {
return SkString("analytic_antialias_convex");
}
SkISize onISize() override {
return SkISize::Make(W, H);
}
void onDraw(SkCanvas* canvas) override {
DEF_SIMPLE_GM(analytic_antialias_convex, canvas, W, H) {
SkPaint p;
p.setColor(SK_ColorRED);
p.setAntiAlias(true);
@ -98,27 +84,9 @@ protected:
path.lineTo(710, 534);
path.lineTo(700, 534);
canvas->drawPath(path, p);
}
}
private:
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 {
DEF_SIMPLE_GM(analytic_antialias_general, canvas, W, H) {
SkPaint p;
p.setColor(SK_ColorRED);
p.setAntiAlias(true);
@ -162,27 +130,9 @@ protected:
path.addRect({20, 20, 100.1f, 100});
path.addRect({100.9f, 20, 200, 100});
canvas->drawPath(path, p);
}
}
private:
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 {
DEF_SIMPLE_GM(analytic_antialias_inverse, canvas, W, H) {
SkPaint p;
p.setColor(SK_ColorRED);
p.setAntiAlias(true);
@ -194,12 +144,4 @@ protected:
path.setFillType(SkPath::kInverseWinding_FillType);
canvas->drawPath(path, p);
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
border, with no red.
*/
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 {
DEF_SIMPLE_GM(aaclip, canvas, 240, 120) {
// Initial pixel-boundary-aligned draw
draw_rect_tests(canvas);
@ -160,13 +144,7 @@ protected:
canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5);
canvas->translate(SkIntToScalar(50), 0);
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);
}
class CGImageGM : public skiagm::GM {
public:
CGImageGM() {}
protected:
SkString onShortName() override {
return SkString("cgimage");
}
SkISize onISize() override {
return SkISize::Make(800, 250);
}
void onDraw(SkCanvas* canvas) override {
DEF_SIMPLE_GM(cgimage, canvas, 800, 250) {
const struct {
SkColorType fCT;
SkAlphaType fAT;
@ -244,12 +209,8 @@ protected:
test_image(canvas, info);
canvas->translate(info.width() + 10, 0);
}
}
}
private:
typedef skiagm::GM INHERITED;
};
//DEF_GM( return new CGImageGM; )
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -115,24 +115,9 @@ static sk_sp<SkShader> make_bg_shader() {
&m);
}
namespace skiagm {
class AARectModesGM : public GM {
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 {
DEF_SIMPLE_GM(aarectmodes, canvas, 640, 480) {
SkPaint bgPaint;
bgPaint.setShader(make_bg_shader());
if (false) { // avoid bit rot, suppress warning
test4(canvas);
}
@ -150,7 +135,7 @@ namespace skiagm {
canvas->translate(W * 5, 0);
canvas->save();
}
canvas->drawRect(bounds, fBGPaint);
canvas->drawRect(bounds, bgPaint);
canvas->saveLayer(&bounds, nullptr);
SkScalar dy = drawCell(canvas, gModes[i],
gAlphaValue[alpha & 1],
@ -163,13 +148,4 @@ namespace skiagm {
canvas->restore();
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
class AddArcMeasGM : public skiagm::GM {
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 {
DEF_SIMPLE_GM(addarc_meas, canvas, 2*R + 40, 2*R + 40) {
canvas->translate(R + 20, R + 20);
SkPaint paint;
@ -106,12 +97,7 @@ protected:
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
class ManyArcsGM : public skiagm::GM {
public:
ManyArcsGM() {}
protected:
SkString onShortName() override { return SkString("manyarcs"); }
SkISize onISize() override { return SkISize::Make(620, 330); }
void onDraw(SkCanvas* canvas) override {
DEF_SIMPLE_GM(manyarcs, canvas, 620, 330) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
@ -281,24 +258,10 @@ protected:
canvas->restore();
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
class TinyAngleBigRadiusArcsGM : public skiagm::GM {
public:
TinyAngleBigRadiusArcsGM() {}
protected:
SkString onShortName() override { return SkString("tinyanglearcs"); }
SkISize onISize() override { return SkISize::Make(620, 330); }
void onDraw(SkCanvas* canvas) override {
DEF_SIMPLE_GM(tinyanglearcs, canvas, 620, 330) {
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
@ -331,9 +294,4 @@ protected:
canvas->drawPath(path, paint);
canvas->translate(20, 0);
}
}
private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new TinyAngleBigRadiusArcsGM; )
}