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