OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 protected: | 51 protected: |
52 | 52 |
53 SkString onShortName() { | 53 SkString onShortName() { |
54 return SkString("dashing"); | 54 return SkString("dashing"); |
55 } | 55 } |
56 | 56 |
57 SkISize onISize() { return SkISize::Make(640, 340); } | 57 SkISize onISize() { return SkISize::Make(640, 340); } |
58 | 58 |
59 virtual void onDraw(SkCanvas* canvas) { | 59 virtual void onDraw(SkCanvas* canvas) { |
60 static const struct { | 60 constexpr struct { |
61 int fOnInterval; | 61 int fOnInterval; |
62 int fOffInterval; | 62 int fOffInterval; |
63 } gData[] = { | 63 } gData[] = { |
64 { 1, 1 }, | 64 { 1, 1 }, |
65 { 4, 1 }, | 65 { 4, 1 }, |
66 }; | 66 }; |
67 | 67 |
68 SkPaint paint; | 68 SkPaint paint; |
69 paint.setStyle(SkPaint::kStroke_Style); | 69 paint.setStyle(SkPaint::kStroke_Style); |
70 | 70 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 protected: | 139 protected: |
140 | 140 |
141 SkString onShortName() { | 141 SkString onShortName() { |
142 return SkString("dashing2"); | 142 return SkString("dashing2"); |
143 } | 143 } |
144 | 144 |
145 SkISize onISize() { return SkISize::Make(640, 480); } | 145 SkISize onISize() { return SkISize::Make(640, 480); } |
146 | 146 |
147 virtual void onDraw(SkCanvas* canvas) { | 147 virtual void onDraw(SkCanvas* canvas) { |
148 static const int gIntervals[] = { | 148 constexpr int gIntervals[] = { |
149 3, // 3 dashes: each count [0] followed by intervals [1..count] | 149 3, // 3 dashes: each count [0] followed by intervals [1..count] |
150 2, 10, 10, | 150 2, 10, 10, |
151 4, 20, 5, 5, 5, | 151 4, 20, 5, 5, 5, |
152 2, 2, 2 | 152 2, 2, 2 |
153 }; | 153 }; |
154 | 154 |
155 void (*gProc[])(SkPath*, const SkRect&) = { | 155 void (*gProc[])(SkPath*, const SkRect&) = { |
156 make_path_line, make_path_rect, make_path_oval, make_path_star, | 156 make_path_line, make_path_rect, make_path_oval, make_path_star, |
157 }; | 157 }; |
158 | 158 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 protected: | 328 protected: |
329 | 329 |
330 SkString onShortName() { | 330 SkString onShortName() { |
331 return SkString("dashing4"); | 331 return SkString("dashing4"); |
332 } | 332 } |
333 | 333 |
334 SkISize onISize() { return SkISize::Make(640, 950); } | 334 SkISize onISize() { return SkISize::Make(640, 950); } |
335 | 335 |
336 virtual void onDraw(SkCanvas* canvas) { | 336 virtual void onDraw(SkCanvas* canvas) { |
337 static const struct { | 337 constexpr struct { |
338 int fOnInterval; | 338 int fOnInterval; |
339 int fOffInterval; | 339 int fOffInterval; |
340 } gData[] = { | 340 } gData[] = { |
341 { 1, 1 }, | 341 { 1, 1 }, |
342 { 4, 2 }, | 342 { 4, 2 }, |
343 { 0, 4 }, // test for zero length on interval | 343 { 0, 4 }, // test for zero length on interval |
344 }; | 344 }; |
345 | 345 |
346 SkPaint paint; | 346 SkPaint paint; |
347 paint.setStyle(SkPaint::kStroke_Style); | 347 paint.setStyle(SkPaint::kStroke_Style); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 if (fDoAA) { | 413 if (fDoAA) { |
414 return SkString("dashing5_aa"); | 414 return SkString("dashing5_aa"); |
415 } else { | 415 } else { |
416 return SkString("dashing5_bw"); | 416 return SkString("dashing5_bw"); |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 SkISize onISize() override { return SkISize::Make(400, 200); } | 420 SkISize onISize() override { return SkISize::Make(400, 200); } |
421 | 421 |
422 void onDraw(SkCanvas* canvas) override { | 422 void onDraw(SkCanvas* canvas) override { |
423 static const int kOn = 4; | 423 constexpr int kOn = 4; |
424 static const int kOff = 4; | 424 constexpr int kOff = 4; |
425 static const int kIntervalLength = kOn + kOff; | 425 constexpr int kIntervalLength = kOn + kOff; |
426 | 426 |
427 static const SkColor gColors[kIntervalLength] = { | 427 constexpr SkColor gColors[kIntervalLength] = { |
428 SK_ColorRED, | 428 SK_ColorRED, |
429 SK_ColorGREEN, | 429 SK_ColorGREEN, |
430 SK_ColorBLUE, | 430 SK_ColorBLUE, |
431 SK_ColorCYAN, | 431 SK_ColorCYAN, |
432 SK_ColorMAGENTA, | 432 SK_ColorMAGENTA, |
433 SK_ColorYELLOW, | 433 SK_ColorYELLOW, |
434 SK_ColorGRAY, | 434 SK_ColorGRAY, |
435 SK_ColorDKGRAY | 435 SK_ColorDKGRAY |
436 }; | 436 }; |
437 | 437 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 547 } |
548 | 548 |
549 ////////////////////////////////////////////////////////////////////////////// | 549 ////////////////////////////////////////////////////////////////////////////// |
550 | 550 |
551 DEF_GM(return new DashingGM;) | 551 DEF_GM(return new DashingGM;) |
552 DEF_GM(return new Dashing2GM;) | 552 DEF_GM(return new Dashing2GM;) |
553 DEF_GM(return new Dashing3GM;) | 553 DEF_GM(return new Dashing3GM;) |
554 DEF_GM(return new Dashing4GM;) | 554 DEF_GM(return new Dashing4GM;) |
555 DEF_GM(return new Dashing5GM(true);) | 555 DEF_GM(return new Dashing5GM(true);) |
556 DEF_GM(return new Dashing5GM(false);) | 556 DEF_GM(return new Dashing5GM(false);) |
OLD | NEW |