Index: gm/imagefiltersscaled.cpp |
diff --git a/gm/imagefiltersscaled.cpp b/gm/imagefiltersscaled.cpp |
index b53263606c978b9e2ae3f1dbd348e96f0f6591be..e98749ebac3bd18ac561b4823e1b8fe252e4f8f9 100644 |
--- a/gm/imagefiltersscaled.cpp |
+++ b/gm/imagefiltersscaled.cpp |
@@ -27,21 +27,21 @@ namespace skiagm { |
class ImageFiltersScaledGM : public GM { |
public: |
- ImageFiltersScaledGM() : fInitialized(false) { |
+ ImageFiltersScaledGM() { |
this->setBGColor(0x00000000); |
} |
protected: |
- virtual SkString onShortName() { |
+ SkString onShortName() override { |
return SkString("imagefiltersscaled"); |
} |
- virtual SkISize onISize() { |
+ SkISize onISize() override { |
return SkISize::Make(1428, 500); |
} |
- void make_gradient_circle(int width, int height) { |
+ void makeGradientCircle(int width, int height) { |
SkScalar x = SkIntToScalar(width / 2); |
SkScalar y = SkIntToScalar(height / 2); |
SkScalar radius = SkScalarMul(SkMinScalar(x, y), SkIntToScalar(4) / SkIntToScalar(5)); |
@@ -60,15 +60,13 @@ protected: |
canvas.drawCircle(x, y, radius, paint); |
} |
- virtual void onDraw(SkCanvas* canvas) { |
- if (!fInitialized) { |
- fCheckerboard.allocN32Pixels(64, 64); |
- SkCanvas checkerboardCanvas(fCheckerboard); |
- sk_tool_utils::draw_checkerboard(&checkerboardCanvas, 0xFFA0A0A0, 0xFF404040, 8); |
+ void onOnceBeforeDraw() override { |
+ fCheckerboard = sk_tool_utils::create_checkerboard_bitmap(64, 64, |
+ 0xFFA0A0A0, 0xFF404040, 8); |
+ this->makeGradientCircle(64, 64); |
+ } |
- this->make_gradient_circle(64, 64); |
- fInitialized = true; |
- } |
+ void onDraw(SkCanvas* canvas) override { |
canvas->clear(SK_ColorBLACK); |
SkAutoTUnref<SkImageFilter> gradient(SkBitmapSource::Create(fGradientCircle)); |
@@ -152,15 +150,13 @@ protected: |
} |
private: |
- bool fInitialized; |
SkBitmap fCheckerboard; |
SkBitmap fGradientCircle; |
+ |
typedef GM INHERITED; |
}; |
////////////////////////////////////////////////////////////////////////////// |
-static GM* MyFactory(void*) { return new ImageFiltersScaledGM; } |
-static GMRegistry reg(MyFactory); |
- |
+DEF_GM(return new ImageFiltersScaledGM;) |
} |