Index: gm/imagefiltersclipped.cpp |
diff --git a/gm/imagefiltersclipped.cpp b/gm/imagefiltersclipped.cpp |
index 362d327b37cf4548cba1a684fa5f65179576f38e..bf651a831ea644ac3b5c845e969f87227d5e10dc 100644 |
--- a/gm/imagefiltersclipped.cpp |
+++ b/gm/imagefiltersclipped.cpp |
@@ -28,12 +28,11 @@ namespace skiagm { |
class ImageFiltersClippedGM : public GM { |
public: |
- ImageFiltersClippedGM() : fInitialized(false) { |
+ ImageFiltersClippedGM() { |
this->setBGColor(0x00000000); |
} |
protected: |
- |
SkString onShortName() override { |
return SkString("imagefiltersclipped"); |
} |
@@ -42,7 +41,7 @@ protected: |
return SkISize::Make(860, 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 = SkMinScalar(x, y) * 0.8f; |
@@ -80,15 +79,13 @@ protected: |
canvas->restore(); |
} |
- void onDraw(SkCanvas* canvas) override { |
- 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)); |
@@ -150,15 +147,13 @@ protected: |
} |
private: |
- bool fInitialized; |
SkBitmap fCheckerboard; |
SkBitmap fGradientCircle; |
+ |
typedef GM INHERITED; |
}; |
////////////////////////////////////////////////////////////////////////////// |
-static GM* MyFactory(void*) { return new ImageFiltersClippedGM; } |
-static GMRegistry reg(MyFactory); |
- |
+DEF_GM(return new ImageFiltersClippedGM;) |
} |