OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkRRect.h" | 10 #include "SkRRect.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 SkISize onISize() override { return SkISize::Make(500, 500); } | 59 SkISize onISize() override { return SkISize::Make(500, 500); } |
60 | 60 |
61 void onOnceBeforeDraw() override { | 61 void onOnceBeforeDraw() override { |
62 fPaint.setAntiAlias(fAntialias); | 62 fPaint.setAntiAlias(fAntialias); |
63 } | 63 } |
64 | 64 |
65 void onDraw(SkCanvas* canvas) override { | 65 void onDraw(SkCanvas* canvas) override { |
66 canvas->clear(SK_ColorWHITE); | 66 canvas->clear(SK_ColorWHITE); |
67 | 67 |
68 canvas->save(); | 68 canvas->save(); |
69 canvas->translate(canvas->imageInfo().width() / 2.f, canvas->imageInfo()
.height() / 2.f); | 69 canvas->translate(this->onISize().width() / 2.f, this->onISize().height(
) / 2.f); |
70 this->drawShapes(canvas); | 70 this->drawShapes(canvas); |
71 canvas->restore(); | 71 canvas->restore(); |
72 } | 72 } |
73 | 73 |
74 virtual void drawShapes(SkCanvas* canvas) const = 0; | 74 virtual void drawShapes(SkCanvas* canvas) const = 0; |
75 | 75 |
76 protected: | 76 protected: |
77 SkString fName; | 77 SkString fName; |
78 bool fAntialias; | 78 bool fAntialias; |
79 SkPaint fPaint; | 79 SkPaint fPaint; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 }; | 153 }; |
154 | 154 |
155 ////////////////////////////////////////////////////////////////////////////// | 155 ////////////////////////////////////////////////////////////////////////////// |
156 | 156 |
157 DEF_GM( return new SimpleShapesGM(true); ) | 157 DEF_GM( return new SimpleShapesGM(true); ) |
158 DEF_GM( return new SimpleShapesGM(false); ) | 158 DEF_GM( return new SimpleShapesGM(false); ) |
159 DEF_GM( return new InnerShapesGM(true); ) | 159 DEF_GM( return new InnerShapesGM(true); ) |
160 DEF_GM( return new InnerShapesGM(false); ) | 160 DEF_GM( return new InnerShapesGM(false); ) |
161 | 161 |
162 } | 162 } |
OLD | NEW |