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