gm: simplify several onName

Change-Id: I9c470c2cf5d546626c279ce65626f767292a94e6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228354
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Hal Canary 2019-07-18 13:35:49 -04:00 committed by Skia Commit-Bot
parent bbb3f646f8
commit 594fe855a3
10 changed files with 124 additions and 272 deletions

View File

@ -98,16 +98,14 @@ static sk_sp<SkShader> make_radial() {
typedef void (*PaintProc)(SkPaint*, SkScalar width); typedef void (*PaintProc)(SkPaint*, SkScalar width);
class BlurRectGM : public skiagm::GM { class BlurRectGM : public skiagm::GM {
sk_sp<SkMaskFilter> fMaskFilters[kLastEnum_SkBlurStyle + 1];
SkString fName;
SkAlpha fAlpha;
public: public:
BlurRectGM(const char name[], U8CPU alpha) BlurRectGM(const char name[], U8CPU alpha) : fName(name), fAlpha(SkToU8(alpha)) {}
: fName(name)
, fAlpha(SkToU8(alpha)) { private:
} sk_sp<SkMaskFilter> fMaskFilters[kLastEnum_SkBlurStyle + 1];
const char* fName;
SkAlpha fAlpha;
protected:
void onOnceBeforeDraw() override { void onOnceBeforeDraw() override {
for (int i = 0; i <= kLastEnum_SkBlurStyle; ++i) { for (int i = 0; i <= kLastEnum_SkBlurStyle; ++i) {
fMaskFilters[i] = SkMaskFilter::MakeBlur((SkBlurStyle)i, fMaskFilters[i] = SkMaskFilter::MakeBlur((SkBlurStyle)i,
@ -115,13 +113,9 @@ protected:
} }
} }
SkString onShortName() override { SkString onShortName() override { return SkString(fName); }
return fName;
}
SkISize onISize() override { SkISize onISize() override { return {860, 820}; }
return SkISize::Make(860, 820);
}
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
canvas->translate(STROKE_WIDTH*3/2, STROKE_WIDTH*3/2); canvas->translate(STROKE_WIDTH*3/2, STROKE_WIDTH*3/2);
@ -161,7 +155,6 @@ protected:
} }
} }
private:
void drawProcs(SkCanvas* canvas, const SkRect& r, const SkPaint& paint, void drawProcs(SkCanvas* canvas, const SkRect& r, const SkPaint& paint,
bool doClip, const Proc procs[], size_t procsCount) { bool doClip, const Proc procs[], size_t procsCount) {
SkAutoCanvasRestore acr(canvas, true); SkAutoCanvasRestore acr(canvas, true);
@ -179,8 +172,6 @@ private:
canvas->translate(0, r.height() * 4/3); canvas->translate(0, r.height() * 4/3);
} }
} }
private:
typedef GM INHERITED;
}; };
DEF_SIMPLE_GM(blurrect_gallery, canvas, 1200, 1024) { DEF_SIMPLE_GM(blurrect_gallery, canvas, 1200, 1024) {

View File

@ -33,18 +33,14 @@
// This GM mimics a blurred RR seen in the wild. // This GM mimics a blurred RR seen in the wild.
class BlurRoundRectGM : public skiagm::GM { class BlurRoundRectGM : public skiagm::GM {
public: public:
BlurRoundRectGM(int width, int height) BlurRoundRectGM(int w, int h) : fWidth(w), fHeight(h) {}
: fName("blurroundrect"), fWidth(width), fHeight(height) {
fName.appendf("-WH-%ix%i-unevenCorners", width, height);
}
private:
SkString onShortName() override { SkString onShortName() override {
return fName; return SkStringPrintf("blurroundrect-WH-%ix%i-unevenCorners", fWidth, fHeight);
} }
SkISize onISize() override { SkISize onISize() override { return {fWidth, fHeight}; }
return SkISize::Make(fWidth, fHeight);
}
void onOnceBeforeDraw() override { void onOnceBeforeDraw() override {
SkVector radii[4]; SkVector radii[4];
@ -86,12 +82,8 @@ public:
canvas->drawRRect(fRRect, paint); canvas->drawRRect(fRRect, paint);
} }
private: SkRRect fRRect;
SkString fName; int fWidth, fHeight;
SkRRect fRRect;
int fWidth, fHeight;
typedef skiagm::GM INHERITED;
}; };
// Rounded rect with two opposite corners with large radii, the other two // Rounded rect with two opposite corners with large radii, the other two
// small. // small.
@ -125,20 +117,9 @@ static sk_sp<SkShader> MakeRadial() {
// Simpler blurred RR test cases where all the radii are the same. // Simpler blurred RR test cases where all the radii are the same.
class SimpleBlurRoundRectGM : public skiagm::GM { class SimpleBlurRoundRectGM : public skiagm::GM {
public: SkString onShortName() override { return SkString("simpleblurroundrect"); }
SimpleBlurRoundRectGM()
: fName("simpleblurroundrect") {
}
protected: SkISize onISize() override { return {1000, 500}; }
SkString onShortName() override {
return fName;
}
SkISize onISize() override {
return SkISize::Make(1000, 500);
}
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
canvas->scale(1.5f, 1.5f); canvas->scale(1.5f, 1.5f);
@ -171,10 +152,6 @@ protected:
} }
} }
} }
private:
const SkString fName;
typedef skiagm::GM INHERITED;
}; };
// Create one with dimensions/rounded corners based on the skp // Create one with dimensions/rounded corners based on the skp

View File

@ -54,6 +54,7 @@ static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
class FilterBitmapGM : public skiagm::GM { class FilterBitmapGM : public skiagm::GM {
void onOnceBeforeDraw() override { void onOnceBeforeDraw() override {
this->setBGColor(0xFFDDDDDD);
this->makeBitmap(); this->makeBitmap();
@ -69,25 +70,11 @@ class FilterBitmapGM : public skiagm::GM {
fMatrix[2].setScale(0.7f, 1.05f); fMatrix[2].setScale(0.7f, 1.05f);
} }
public: protected:
SkBitmap fBM; SkBitmap fBM;
SkMatrix fMatrix[3]; SkMatrix fMatrix[3];
SkString fName;
FilterBitmapGM() SkISize onISize() override { return SkISize::Make(1024, 768); }
{
this->setBGColor(0xFFDDDDDD);
}
protected:
SkString onShortName() override {
return fName;
}
SkISize onISize() override {
return SkISize::Make(1024, 768);
}
virtual void makeBitmap() = 0; virtual void makeBitmap() = 0;
virtual SkScalar getScale() = 0; virtual SkScalar getScale() = 0;
@ -104,21 +91,17 @@ protected:
canvas->translate(0, size.fHeight); canvas->translate(0, size.fHeight);
} }
} }
private:
typedef skiagm::GM INHERITED;
}; };
class FilterBitmapTextGM: public FilterBitmapGM { class FilterBitmapTextGM: public FilterBitmapGM {
public: public:
FilterBitmapTextGM(float textSize) FilterBitmapTextGM(float textSize) : fTextSize(textSize) {}
: fTextSize(textSize)
{
fName.printf("filterbitmap_text_%.2fpt", fTextSize);
}
protected: private:
float fTextSize; SkString onShortName() override {
return SkStringPrintf("filterbitmap_text_%.2fpt", fTextSize);
}
const float fTextSize;
SkScalar getScale() override { SkScalar getScale() override {
return 32.f/fTextSize; return 32.f/fTextSize;
@ -143,20 +126,18 @@ class FilterBitmapTextGM: public FilterBitmapGM {
setTypeface(&font, "serif", SkFontStyle::BoldItalic()); setTypeface(&font, "serif", SkFontStyle::BoldItalic());
canvas.drawString("Hamburgefons", fTextSize/2, 4.8f*fTextSize, font, paint); canvas.drawString("Hamburgefons", fTextSize/2, 4.8f*fTextSize, font, paint);
} }
private:
typedef FilterBitmapGM INHERITED;
}; };
class FilterBitmapCheckerboardGM: public FilterBitmapGM { class FilterBitmapCheckerboardGM: public FilterBitmapGM {
SkString onShortName() override {
return SkStringPrintf("filterbitmap_checkerboard_%d_%d%s",
fSize, fNumChecks, fConvertToG8 ? "_g8" : "");
}
public: public:
FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = false) FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = false)
: fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8) : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8) {}
{
fName.printf("filterbitmap_checkerboard_%d_%d%s",
fSize, fNumChecks, convertToG8 ? "_g8" : "");
}
protected: protected:
int fSize; int fSize;
int fNumChecks; int fNumChecks;
@ -190,23 +171,24 @@ private:
}; };
class FilterBitmapImageGM: public FilterBitmapGM { class FilterBitmapImageGM: public FilterBitmapGM {
public: const char* fFilename;
FilterBitmapImageGM(const char filename[], bool convertToG8 = false) int fSize;
: fFilename(filename), fConvertToG8(convertToG8)
{ SkString onShortName() override {
fName.printf("filterbitmap_image_%s%s", filename, convertToG8 ? "_g8" : ""); return SkStringPrintf("filterbitmap_image_%s%s", fFilename, fConvertToG8 ? "_g8" : "");
} }
protected: public:
SkString fFilename; FilterBitmapImageGM(const char filename[], bool convertToG8 = false)
int fSize; : fFilename(filename), fConvertToG8(convertToG8) {}
protected:
SkScalar getScale() override { SkScalar getScale() override {
return 192.f/fSize; return 192.f/fSize;
} }
void makeBitmap() override { void makeBitmap() override {
SkString resource = SkStringPrintf("images/%s", fFilename.c_str()); SkString resource = SkStringPrintf("images/%s", fFilename);
if (!GetResourceAsBitmap(resource.c_str(), &fBM)) { if (!GetResourceAsBitmap(resource.c_str(), &fBM)) {
fBM.allocN32Pixels(1, 1); fBM.allocN32Pixels(1, 1);
fBM.eraseARGB(255, 255, 0 , 0); // red == bad fBM.eraseARGB(255, 255, 0 , 0); // red == bad

View File

@ -19,6 +19,7 @@
#include "tools/Resources.h" #include "tools/Resources.h"
#include "tools/ToolUtils.h" #include "tools/ToolUtils.h"
namespace {
static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) {
SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()),
SkIntToScalar(bm.height())); SkIntToScalar(bm.height()));
@ -46,8 +47,15 @@ static void draw_row(SkCanvas* canvas, const SkBitmap& bm, const SkMatrix& mat,
} }
class FilterIndiaBoxGM : public skiagm::GM { class FilterIndiaBoxGM : public skiagm::GM {
SkBitmap fBM;
SkMatrix fMatrix[2];
void onOnceBeforeDraw() override { void onOnceBeforeDraw() override {
this->makeBitmap(); constexpr char kResource[] = "images/box.gif";
if (!GetResourceAsBitmap(kResource, &fBM)) {
fBM.allocN32Pixels(1, 1);
fBM.eraseARGB(255, 255, 0 , 0); // red == bad
}
SkScalar cx = SkScalarHalf(fBM.width()); SkScalar cx = SkScalarHalf(fBM.width());
SkScalar cy = SkScalarHalf(fBM.height()); SkScalar cy = SkScalarHalf(fBM.height());
@ -59,25 +67,9 @@ class FilterIndiaBoxGM : public skiagm::GM {
fMatrix[1].setRotate(30, cx, cy); fMatrix[1].postScale(horizScale, vertScale); fMatrix[1].setRotate(30, cx, cy); fMatrix[1].postScale(horizScale, vertScale);
} }
public: SkString onShortName() override { return SkString("filterindiabox"); }
SkBitmap fBM;
SkMatrix fMatrix[2];
SkString fName;
FilterIndiaBoxGM() { this->setBGColor(ToolUtils::color_to_565(0xFFDDDDDD)); } SkISize onISize() override { return {680, 130}; }
FilterIndiaBoxGM(const char filename[]) : fFilename(filename) {
fName.printf("filterindiabox");
}
protected:
SkString onShortName() override {
return fName;
}
SkISize onISize() override {
return SkISize::Make(680, 130);
}
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
canvas->translate(10, 10); canvas->translate(10, 10);
@ -90,27 +82,7 @@ protected:
canvas->translate(0, size.fHeight); canvas->translate(0, size.fHeight);
} }
} }
protected:
SkString fFilename;
int fSize;
SkScalar getScale() {
return 192.f/fSize;
}
void makeBitmap() {
if (!GetResourceAsBitmap(fFilename.c_str(), &fBM)) {
fBM.allocN32Pixels(1, 1);
fBM.eraseARGB(255, 255, 0 , 0); // red == bad
}
fSize = fBM.height();
}
private:
typedef skiagm::GM INHERITED;
}; };
} // namespace
////////////////////////////////////////////////////////////////////////////// DEF_GM( return new FilterIndiaBoxGM(); )
DEF_GM( return new FilterIndiaBoxGM("images/box.gif"); )

View File

@ -69,22 +69,16 @@ static const char* zh = "zh";
static const char* ja = "ja"; static const char* ja = "ja";
class FontMgrGM : public skiagm::GM { class FontMgrGM : public skiagm::GM {
public: sk_sp<SkFontMgr> fFM;
FontMgrGM() {
SkGraphics::SetFontCacheLimit(16 * 1024 * 1024);
fName.set("fontmgr_iter"); void onOnceBeforeDraw() override {
SkGraphics::SetFontCacheLimit(16 * 1024 * 1024);
fFM = SkFontMgr::RefDefault(); fFM = SkFontMgr::RefDefault();
} }
protected: SkString onShortName() override { return SkString("fontmgr_iter"); }
SkString onShortName() override {
return fName;
}
SkISize onISize() override { SkISize onISize() override { return {1536, 768}; }
return SkISize::Make(1536, 768);
}
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
SkScalar y = 20; SkScalar y = 20;
@ -123,29 +117,19 @@ protected:
y += 24; y += 24;
} }
} }
private:
sk_sp<SkFontMgr> fFM;
SkString fName;
typedef GM INHERITED;
}; };
class FontMgrMatchGM : public skiagm::GM { class FontMgrMatchGM : public skiagm::GM {
sk_sp<SkFontMgr> fFM; sk_sp<SkFontMgr> fFM;
public: void onOnceBeforeDraw() override {
FontMgrMatchGM() : fFM(SkFontMgr::RefDefault()) { fFM = SkFontMgr::RefDefault();
SkGraphics::SetFontCacheLimit(16 * 1024 * 1024); SkGraphics::SetFontCacheLimit(16 * 1024 * 1024);
} }
protected: SkString onShortName() override { return SkString("fontmgr_match"); }
SkString onShortName() override {
return SkString("fontmgr_match");
}
SkISize onISize() override { SkISize onISize() override { return {640, 1024}; }
return SkISize::Make(640, 1024);
}
void iterateFamily(SkCanvas* canvas, const SkFont& font, SkFontStyleSet* fset) { void iterateFamily(SkCanvas* canvas, const SkFont& font, SkFontStyleSet* fset) {
SkFont f(font); SkFont f(font);
@ -211,23 +195,22 @@ protected:
this->iterateFamily(canvas, font, fset.get()); this->iterateFamily(canvas, font, fset.get());
return DrawResult::kOk; return DrawResult::kOk;
} }
private:
typedef GM INHERITED;
}; };
class FontMgrBoundsGM : public skiagm::GM { class FontMgrBoundsGM : public skiagm::GM {
public: public:
FontMgrBoundsGM(double scale, double skew) FontMgrBoundsGM(float scale, float skew) : fScaleX(scale) , fSkewX(skew) {}
: fFM(SkFontMgr::RefDefault())
, fName("fontmgr_bounds") private:
, fScaleX(SkDoubleToScalar(scale)) SkString onShortName() override {
, fSkewX(SkDoubleToScalar(skew)) if (fScaleX != 1 || fSkewX != 0) {
, fLabelBounds(false) return SkStringPrintf("fontmgr_bounds_%g_%g", fScaleX, fSkewX);
{
if (scale != 1 || skew != 0) {
fName.appendf("_%g_%g", scale, skew);
} }
return SkString("fontmgr_bounds");
}
void onOnceBeforeDraw() override {
fFM = SkFontMgr::RefDefault();
} }
bool onGetControls(SkMetaData* controls) override { bool onGetControls(SkMetaData* controls) override {
@ -318,17 +301,9 @@ public:
} }
} }
} }
protected: SkISize onISize() override { return {1024, 850}; }
SkString onShortName() override {
return fName;
}
SkISize onISize() override {
return SkISize::Make(1024, 850);
}
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
SkFont font; SkFont font;
@ -372,19 +347,16 @@ protected:
} }
} }
private: sk_sp<SkFontMgr> fFM;
const sk_sp<SkFontMgr> fFM;
SkString fName;
const SkScalar fScaleX; const SkScalar fScaleX;
const SkScalar fSkewX; const SkScalar fSkewX;
bool fLabelBounds; bool fLabelBounds = false;
typedef GM INHERITED;
}; };
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
DEF_GM(return new FontMgrGM;) DEF_GM(return new FontMgrGM;)
DEF_GM(return new FontMgrMatchGM;) DEF_GM(return new FontMgrMatchGM;)
DEF_GM(return new FontMgrBoundsGM(1.0, 0);) DEF_GM(return new FontMgrBoundsGM(1, 0);)
DEF_GM(return new FontMgrBoundsGM(0.75, 0);) DEF_GM(return new FontMgrBoundsGM(0.75f, 0);)
DEF_GM(return new FontMgrBoundsGM(1.0, -0.25);) DEF_GM(return new FontMgrBoundsGM(1, -0.25f);)

View File

@ -35,21 +35,13 @@ const char* gProg = R"(
static sk_sp<SkShader> gShader; static sk_sp<SkShader> gShader;
class RuntimeShader : public skiagm::GM { class RuntimeShader : public skiagm::GM {
public: sk_sp<SkData> fData;
RuntimeShader() {
fName.printf("runtime_shader");
}
protected:
bool runAsBench() const override { return true; } bool runAsBench() const override { return true; }
SkString onShortName() override { SkString onShortName() override { return SkString("runtime_shader"); }
return fName;
}
SkISize onISize() override { SkISize onISize() override { return {512, 256}; }
return SkISize::Make(512, 256);
}
void onOnceBeforeDraw() override { void onOnceBeforeDraw() override {
// use global to pass gl persistent cache test in dm // use global to pass gl persistent cache test in dm
@ -69,10 +61,5 @@ protected:
p.setShader(gShader); p.setShader(gShader);
canvas->drawRect({0, 0, 256, 256}, p); canvas->drawRect({0, 0, 256, 256}, p);
} }
private:
SkString fName;
sk_sp<SkData> fData;
typedef skiagm::GM INHERITED;
}; };
DEF_GM(return new RuntimeShader;) DEF_GM(return new RuntimeShader;)

View File

@ -45,20 +45,18 @@ static sk_sp<SkShader> shader_sweep(const SkColor colors[], int count, const SkS
class ShallowGradientGM : public skiagm::GM { class ShallowGradientGM : public skiagm::GM {
public: public:
ShallowGradientGM(MakeShaderProc proc, const char name[], bool dither) ShallowGradientGM(MakeShaderProc proc, const char name[], bool dither)
: fProc(proc) : fProc(proc), fName(name), fDither(dither) {}
, fDither(dither) {
fName.printf("shallow_gradient_%s", name);
}
protected: private:
MakeShaderProc fProc;
const char* fName;
bool fDither;
SkString onShortName() override { SkString onShortName() override {
return fName; return SkStringPrintf("shallow_gradient_%s%s", fName, fDither ? "" : "_nodither");
} }
SkISize onISize() override { SkISize onISize() override { return {800, 800}; }
return SkISize::Make(800, 800);
}
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
const SkColor colors[] = { 0xFF555555, 0xFF444444 }; const SkColor colors[] = { 0xFF555555, 0xFF444444 };
@ -72,23 +70,18 @@ protected:
paint.setDither(fDither); paint.setDither(fDither);
canvas->drawRect(r, paint); canvas->drawRect(r, paint);
} }
private:
MakeShaderProc fProc;
SkString fName;
bool fDither;
typedef skiagm::GM INHERITED;
}; };
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
DEF_GM( return new ShallowGradientGM(shader_linear, "linear", true); ) #define M(PROC, DITHER) DEF_GM( return new ShallowGradientGM(shader_ ## PROC, #PROC, DITHER); )
DEF_GM( return new ShallowGradientGM(shader_radial, "radial", true); ) M(linear, true)
DEF_GM( return new ShallowGradientGM(shader_conical, "conical", true); ) M(radial, true)
DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep", true); ) M(conical, true)
M(sweep, true)
DEF_GM( return new ShallowGradientGM(shader_linear, "linear_nodither", false); ) M(linear, false)
DEF_GM( return new ShallowGradientGM(shader_radial, "radial_nodither", false); ) M(radial, false)
DEF_GM( return new ShallowGradientGM(shader_conical, "conical_nodither", false); ) M(conical, false)
DEF_GM( return new ShallowGradientGM(shader_sweep, "sweep_nodither", false); ) M(sweep, false)
#undef M

View File

@ -197,17 +197,13 @@ typedef sk_sp<SkShader> (*ShaderProc)(SkTileMode, SkTileMode);
class Tiling2GM : public skiagm::GM { class Tiling2GM : public skiagm::GM {
ShaderProc fProc; ShaderProc fProc;
SkString fName; const char* fName;
public: public:
Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { Tiling2GM(ShaderProc proc, const char name[]) : fProc(proc), fName(name) {}
fName.printf("tilemode_%s", name);
}
protected: private:
SkString onShortName() override { return SkString(fName); }
SkString onShortName() override {
return fName;
}
SkISize onISize() override { return SkISize::Make(650, 610); } SkISize onISize() override { return SkISize::Make(650, 610); }
@ -261,12 +257,10 @@ protected:
y += r.height() * 4 / 3; y += r.height() * 4 / 3;
} }
} }
private:
typedef skiagm::GM INHERITED;
}; };
DEF_GM( return new Tiling2GM(make_bm, "bitmap"); )
DEF_GM( return new Tiling2GM(make_grad, "gradient"); ) DEF_GM( return new Tiling2GM(make_bm, "tilemode_bitmap"); )
DEF_GM( return new Tiling2GM(make_grad, "tilemode_gradient"); )
//////////////////// ////////////////////

View File

@ -194,17 +194,12 @@ typedef sk_sp<SkShader> (*ShaderProc)(SkTileMode, SkTileMode);
class ScaledTiling2GM : public skiagm::GM { class ScaledTiling2GM : public skiagm::GM {
ShaderProc fProc; ShaderProc fProc;
SkString fName; const char* fName;
public: public:
ScaledTiling2GM(ShaderProc proc, const char name[]) : fProc(proc) { ScaledTiling2GM(ShaderProc proc, const char name[]) : fProc(proc), fName(name) {}
fName.printf("scaled_tilemode_%s", name);
}
protected: private:
SkString onShortName() override { return SkString(fName); }
SkString onShortName() override {
return fName;
}
SkISize onISize() override { return SkISize::Make(650, 610); } SkISize onISize() override { return SkISize::Make(650, 610); }
@ -257,14 +252,11 @@ protected:
y += r.height() * 4 / 3; y += r.height() * 4 / 3;
} }
} }
private:
typedef skiagm::GM INHERITED;
}; };
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
DEF_GM( return new ScaledTilingGM(true); ) DEF_GM( return new ScaledTilingGM(true); )
DEF_GM( return new ScaledTilingGM(false); ) DEF_GM( return new ScaledTilingGM(false); )
DEF_GM( return new ScaledTiling2GM(make_bm, "bitmap"); ) DEF_GM( return new ScaledTiling2GM(make_bm, "scaled_tilemode_bitmap"); )
DEF_GM( return new ScaledTiling2GM(make_grad, "gradient"); ) DEF_GM( return new ScaledTiling2GM(make_grad, "scaled_tilemode_gradient"); )

View File

@ -45,7 +45,7 @@ static sk_sp<SkImage> make_picture_image(int width, int height, SkColor colors[2
SkPictureRecorder recorder; SkPictureRecorder recorder;
draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height, colors); draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height, colors);
return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
SkISize::Make(width, height), nullptr, nullptr, {width, height}, nullptr, nullptr,
SkImage::BitDepth::kU8, SkImage::BitDepth::kU8,
SkColorSpace::MakeSRGB()); SkColorSpace::MakeSRGB());
} }
@ -82,21 +82,15 @@ static void show_image(SkCanvas* canvas, int width, int height, SkColor colors[2
class VeryLargeBitmapGM : public skiagm::GM { class VeryLargeBitmapGM : public skiagm::GM {
ImageMakerProc fProc; ImageMakerProc fProc;
SkString fName; const char* fName;
public: public:
VeryLargeBitmapGM(ImageMakerProc proc, const char suffix[]) : fProc(proc) { VeryLargeBitmapGM(ImageMakerProc proc, const char name[]) : fProc(proc), fName(name) {}
fName.printf("verylarge%s", suffix);
}
protected: private:
SkString onShortName() override { SkString onShortName() override { return SkString(fName); }
return fName;
}
SkISize onISize() override { SkISize onISize() override { return {500, 600}; }
return SkISize::Make(500, 600);
}
void onDraw(SkCanvas* canvas) override { void onDraw(SkCanvas* canvas) override {
int veryBig = 65*1024; // 64K < size int veryBig = 65*1024; // 64K < size
@ -128,9 +122,7 @@ protected:
// This used to be big enough that we didn't draw on CPU, but now we do. // This used to be big enough that we didn't draw on CPU, but now we do.
show_image(canvas, veryBig, small, colors, fProc); show_image(canvas, veryBig, small, colors, fProc);
} }
private:
typedef skiagm::GM INHERITED;
}; };
DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); )
DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "verylargebitmap"); )
DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "verylarge_picture_image"); )