diff options
author | robertphillips <robertphillips@google.com> | 2015-09-03 13:32:33 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-03 13:32:33 -0700 |
commit | 943a462fef57832e2683894bb9f2f36ac25d98f7 (patch) | |
tree | c08c082d19d7dfb0db1331739b04cdb8b174440c /gm/matrixconvolution.cpp | |
parent | 44c3128bd892d32f797810d93ef1ed392e0b902d (diff) |
Minor code cleanup (left over from prior CL)
This was requested in https://codereview.chromium.org/1309543012/ (Add new GM to directly exercise perspective bitmap drawing)
Review URL: https://codereview.chromium.org/1320673011
Diffstat (limited to 'gm/matrixconvolution.cpp')
-rw-r--r-- | gm/matrixconvolution.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/gm/matrixconvolution.cpp b/gm/matrixconvolution.cpp index 1e6a49d4b6..6d16f8dfa7 100644 --- a/gm/matrixconvolution.cpp +++ b/gm/matrixconvolution.cpp @@ -14,17 +14,17 @@ namespace skiagm { class MatrixConvolutionGM : public GM { public: - MatrixConvolutionGM() : fInitialized(false) { + MatrixConvolutionGM() { this->setBGColor(0x00000000); } protected: - virtual SkString onShortName() { + SkString onShortName() override { return SkString("matrixconvolution"); } - void make_bitmap() { + void makeBitmap() { fBitmap.allocN32Pixels(80, 80); SkCanvas canvas(fBitmap); canvas.clear(0x00000000); @@ -43,7 +43,7 @@ protected: canvas.drawText(str, strlen(str), SkIntToScalar(-10), SkIntToScalar(80), paint); } - virtual SkISize onISize() { + SkISize onISize() override { return SkISize::Make(500, 300); } @@ -79,11 +79,11 @@ protected: typedef SkMatrixConvolutionImageFilter MCIF; - virtual void onDraw(SkCanvas* canvas) { - if (!fInitialized) { - make_bitmap(); - fInitialized = true; - } + void onOnceBeforeDraw() override { + this->makeBitmap(); + } + + void onDraw(SkCanvas* canvas) override { canvas->clear(SK_ColorBLACK); SkIPoint kernelOffset = SkIPoint::Make(1, 0); for (int x = 10; x < 310; x += 100) { @@ -104,14 +104,13 @@ protected: } private: - typedef GM INHERITED; SkBitmap fBitmap; - bool fInitialized; + + typedef GM INHERITED; }; ////////////////////////////////////////////////////////////////////////////// -static GM* MyFactory(void*) { return new MatrixConvolutionGM; } -static GMRegistry reg(MyFactory); +DEF_GM(return new MatrixConvolutionGM;) } |