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 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 | 10 |
11 namespace skiagm { | 11 namespace skiagm { |
12 | 12 |
13 class PointsGM : public GM { | 13 class PointsGM : public GM { |
14 public: | 14 public: |
15 PointsGM() {} | 15 PointsGM() {} |
16 | 16 |
17 protected: | 17 protected: |
18 | 18 |
19 SkString onShortName() SK_OVERRIDE { | 19 SkString onShortName() override { |
20 return SkString("points"); | 20 return SkString("points"); |
21 } | 21 } |
22 | 22 |
23 SkISize onISize() SK_OVERRIDE { | 23 SkISize onISize() override { |
24 return SkISize::Make(640, 490); | 24 return SkISize::Make(640, 490); |
25 } | 25 } |
26 | 26 |
27 static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) { | 27 static void fill_pts(SkPoint pts[], size_t n, SkRandom* rand) { |
28 for (size_t i = 0; i < n; i++) { | 28 for (size_t i = 0; i < n; i++) { |
29 // Compute these independently and store in variables, rather | 29 // Compute these independently and store in variables, rather |
30 // than in the parameter-passing expression, to get consistent | 30 // than in the parameter-passing expression, to get consistent |
31 // evaluation order across compilers. | 31 // evaluation order across compilers. |
32 SkScalar y = rand->nextUScalar1() * 480; | 32 SkScalar y = rand->nextUScalar1() * 480; |
33 SkScalar x = rand->nextUScalar1() * 640; | 33 SkScalar x = rand->nextUScalar1() * 640; |
34 pts[i].set(x, y); | 34 pts[i].set(x, y); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 38 void onDraw(SkCanvas* canvas) override { |
39 canvas->translate(SK_Scalar1, SK_Scalar1); | 39 canvas->translate(SK_Scalar1, SK_Scalar1); |
40 | 40 |
41 SkRandom rand; | 41 SkRandom rand; |
42 SkPaint p0, p1, p2, p3; | 42 SkPaint p0, p1, p2, p3; |
43 const size_t n = 99; | 43 const size_t n = 99; |
44 | 44 |
45 p0.setColor(SK_ColorRED); | 45 p0.setColor(SK_ColorRED); |
46 p1.setColor(SK_ColorGREEN); | 46 p1.setColor(SK_ColorGREEN); |
47 p2.setColor(SK_ColorBLUE); | 47 p2.setColor(SK_ColorBLUE); |
48 p3.setColor(SK_ColorWHITE); | 48 p3.setColor(SK_ColorWHITE); |
(...skipping 16 matching lines...) Expand all Loading... |
65 private: | 65 private: |
66 typedef GM INHERITED; | 66 typedef GM INHERITED; |
67 }; | 67 }; |
68 | 68 |
69 ////////////////////////////////////////////////////////////////////////////// | 69 ////////////////////////////////////////////////////////////////////////////// |
70 | 70 |
71 static GM* MyFactory(void*) { return new PointsGM; } | 71 static GM* MyFactory(void*) { return new PointsGM; } |
72 static GMRegistry reg(MyFactory); | 72 static GMRegistry reg(MyFactory); |
73 | 73 |
74 } | 74 } |
OLD | NEW |