OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 paint->setAlpha(0xFF); | 33 paint->setAlpha(0xFF); |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 class StrokesGM : public skiagm::GM { | 37 class StrokesGM : public skiagm::GM { |
38 public: | 38 public: |
39 StrokesGM() {} | 39 StrokesGM() {} |
40 | 40 |
41 protected: | 41 protected: |
42 | 42 |
43 SkString onShortName() SK_OVERRIDE { | 43 SkString onShortName() override { |
44 return SkString("strokes_round"); | 44 return SkString("strokes_round"); |
45 } | 45 } |
46 | 46 |
47 SkISize onISize() SK_OVERRIDE { | 47 SkISize onISize() override { |
48 return SkISize::Make(W, H*2); | 48 return SkISize::Make(W, H*2); |
49 } | 49 } |
50 | 50 |
51 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 51 void onDraw(SkCanvas* canvas) override { |
52 SkPaint paint; | 52 SkPaint paint; |
53 paint.setStyle(SkPaint::kStroke_Style); | 53 paint.setStyle(SkPaint::kStroke_Style); |
54 paint.setStrokeWidth(SkIntToScalar(9)/2); | 54 paint.setStrokeWidth(SkIntToScalar(9)/2); |
55 | 55 |
56 for (int y = 0; y < 2; y++) { | 56 for (int y = 0; y < 2; y++) { |
57 paint.setAntiAlias(!!y); | 57 paint.setAntiAlias(!!y); |
58 SkAutoCanvasRestore acr(canvas, true); | 58 SkAutoCanvasRestore acr(canvas, true); |
59 canvas->translate(0, SH * y); | 59 canvas->translate(0, SH * y); |
60 canvas->clipRect(SkRect::MakeLTRB( | 60 canvas->clipRect(SkRect::MakeLTRB( |
61 SkIntToScalar(2), SkIntToScalar(2) | 61 SkIntToScalar(2), SkIntToScalar(2) |
(...skipping 12 matching lines...) Expand all Loading... |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 private: | 77 private: |
78 typedef skiagm::GM INHERITED; | 78 typedef skiagm::GM INHERITED; |
79 }; | 79 }; |
80 | 80 |
81 class Strokes2GM : public skiagm::GM { | 81 class Strokes2GM : public skiagm::GM { |
82 SkPath fPath; | 82 SkPath fPath; |
83 protected: | 83 protected: |
84 void onOnceBeforeDraw() SK_OVERRIDE { | 84 void onOnceBeforeDraw() override { |
85 SkRandom rand; | 85 SkRandom rand; |
86 fPath.moveTo(0, 0); | 86 fPath.moveTo(0, 0); |
87 for (int i = 0; i < 13; i++) { | 87 for (int i = 0; i < 13; i++) { |
88 SkScalar x = rand.nextUScalar1() * (W >> 1); | 88 SkScalar x = rand.nextUScalar1() * (W >> 1); |
89 SkScalar y = rand.nextUScalar1() * (H >> 1); | 89 SkScalar y = rand.nextUScalar1() * (H >> 1); |
90 fPath.lineTo(x, y); | 90 fPath.lineTo(x, y); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 SkString onShortName() SK_OVERRIDE { | 95 SkString onShortName() override { |
96 return SkString("strokes_poly"); | 96 return SkString("strokes_poly"); |
97 } | 97 } |
98 | 98 |
99 SkISize onISize() SK_OVERRIDE { | 99 SkISize onISize() override { |
100 return SkISize::Make(W, H*2); | 100 return SkISize::Make(W, H*2); |
101 } | 101 } |
102 | 102 |
103 static void rotate(SkScalar angle, SkScalar px, SkScalar py, SkCanvas* canva
s) { | 103 static void rotate(SkScalar angle, SkScalar px, SkScalar py, SkCanvas* canva
s) { |
104 SkMatrix matrix; | 104 SkMatrix matrix; |
105 matrix.setRotate(angle, px, py); | 105 matrix.setRotate(angle, px, py); |
106 canvas->concat(matrix); | 106 canvas->concat(matrix); |
107 } | 107 } |
108 | 108 |
109 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 109 void onDraw(SkCanvas* canvas) override { |
110 canvas->drawColor(SK_ColorWHITE); | 110 canvas->drawColor(SK_ColorWHITE); |
111 | 111 |
112 SkPaint paint; | 112 SkPaint paint; |
113 paint.setStyle(SkPaint::kStroke_Style); | 113 paint.setStyle(SkPaint::kStroke_Style); |
114 paint.setStrokeWidth(SkIntToScalar(9)/2); | 114 paint.setStrokeWidth(SkIntToScalar(9)/2); |
115 | 115 |
116 for (int y = 0; y < 2; y++) { | 116 for (int y = 0; y < 2; y++) { |
117 paint.setAntiAlias(!!y); | 117 paint.setAntiAlias(!!y); |
118 SkAutoCanvasRestore acr(canvas, true); | 118 SkAutoCanvasRestore acr(canvas, true); |
119 canvas->translate(0, SH * y); | 119 canvas->translate(0, SH * y); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 r.inset(bounds.width() / 10, -bounds.height() / 10); | 183 r.inset(bounds.width() / 10, -bounds.height() / 10); |
184 path->addOval(r, SkPath::kCCW_Direction); | 184 path->addOval(r, SkPath::kCCW_Direction); |
185 title->set("CW CCW"); | 185 title->set("CW CCW"); |
186 } | 186 } |
187 | 187 |
188 public: | 188 public: |
189 Strokes3GM() {} | 189 Strokes3GM() {} |
190 | 190 |
191 protected: | 191 protected: |
192 | 192 |
193 SkString onShortName() SK_OVERRIDE { | 193 SkString onShortName() override { |
194 return SkString("strokes3"); | 194 return SkString("strokes3"); |
195 } | 195 } |
196 | 196 |
197 SkISize onISize() SK_OVERRIDE { | 197 SkISize onISize() override { |
198 return SkISize::Make(1500, 1500); | 198 return SkISize::Make(1500, 1500); |
199 } | 199 } |
200 | 200 |
201 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 201 void onDraw(SkCanvas* canvas) override { |
202 SkPaint origPaint; | 202 SkPaint origPaint; |
203 origPaint.setAntiAlias(true); | 203 origPaint.setAntiAlias(true); |
204 origPaint.setStyle(SkPaint::kStroke_Style); | 204 origPaint.setStyle(SkPaint::kStroke_Style); |
205 SkPaint fillPaint(origPaint); | 205 SkPaint fillPaint(origPaint); |
206 fillPaint.setColor(SK_ColorRED); | 206 fillPaint.setColor(SK_ColorRED); |
207 SkPaint strokePaint(origPaint); | 207 SkPaint strokePaint(origPaint); |
208 strokePaint.setColor(0xFF4444FF); | 208 strokePaint.setColor(0xFF4444FF); |
209 | 209 |
210 void (*procs[])(SkPath*, const SkRect&, SkString*) = { | 210 void (*procs[])(SkPath*, const SkRect&, SkString*) = { |
211 make0, make1, make2, make3, make4, make5 | 211 make0, make1, make2, make3, make4, make5 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 243 |
244 ////////////////////////////////////////////////////////////////////////////// | 244 ////////////////////////////////////////////////////////////////////////////// |
245 | 245 |
246 static skiagm::GM* F0(void*) { return new StrokesGM; } | 246 static skiagm::GM* F0(void*) { return new StrokesGM; } |
247 static skiagm::GM* F1(void*) { return new Strokes2GM; } | 247 static skiagm::GM* F1(void*) { return new Strokes2GM; } |
248 static skiagm::GM* F2(void*) { return new Strokes3GM; } | 248 static skiagm::GM* F2(void*) { return new Strokes3GM; } |
249 | 249 |
250 static skiagm::GMRegistry R0(F0); | 250 static skiagm::GMRegistry R0(F0); |
251 static skiagm::GMRegistry R1(F1); | 251 static skiagm::GMRegistry R1(F1); |
252 static skiagm::GMRegistry R2(F2); | 252 static skiagm::GMRegistry R2(F2); |
OLD | NEW |