OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 #include "gm.h" | 9 #include "gm.h" |
10 #include "SkTArray.h" | 10 #include "SkTArray.h" |
11 #include "SkRandom.h" | 11 #include "SkRandom.h" |
12 #include "SkMatrix.h" | 12 #include "SkMatrix.h" |
13 #include "SkBlurMaskFilter.h" | 13 #include "SkBlurMaskFilter.h" |
14 #include "SkGradientShader.h" | 14 #include "SkGradientShader.h" |
15 #include "SkBlurDrawLooper.h" | 15 #include "SkBlurDrawLooper.h" |
16 #include "SkRect.h" | 16 #include "SkRect.h" |
17 | 17 |
18 namespace skiagm { | 18 namespace skiagm { |
19 | 19 |
20 class OvalGM : public GM { | 20 class OvalGM : public GM { |
21 public: | 21 public: |
22 OvalGM() { | 22 OvalGM() { |
23 this->setBGColor(0xFF000000); | 23 this->setBGColor(0xFF000000); |
24 this->makePaints(); | 24 this->makePaints(); |
25 this->makeMatrices(); | 25 this->makeMatrices(); |
26 } | 26 } |
27 | 27 |
28 protected: | 28 protected: |
29 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 29 uint32_t onGetFlags() const SK_OVERRIDE { |
30 return kSkipTiled_Flag; | 30 return kSkipTiled_Flag; |
31 } | 31 } |
32 | 32 |
33 virtual SkString onShortName() SK_OVERRIDE { | 33 SkString onShortName() SK_OVERRIDE { |
34 return SkString("ovals"); | 34 return SkString("ovals"); |
35 } | 35 } |
36 | 36 |
37 virtual SkISize onISize() SK_OVERRIDE { | 37 SkISize onISize() SK_OVERRIDE { |
38 return SkISize::Make(1200, 900); | 38 return SkISize::Make(1200, 900); |
39 } | 39 } |
40 | 40 |
41 void makePaints() { | 41 void makePaints() { |
42 { | 42 { |
43 // no AA | 43 // no AA |
44 SkPaint p; | 44 SkPaint p; |
45 fPaints.push_back(p); | 45 fPaints.push_back(p); |
46 } | 46 } |
47 | 47 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 SkColor genColor(SkRandom* rand) { | 132 SkColor genColor(SkRandom* rand) { |
133 SkScalar hsv[3]; | 133 SkScalar hsv[3]; |
134 hsv[0] = rand->nextRangeF(0.0f, 360.0f); | 134 hsv[0] = rand->nextRangeF(0.0f, 360.0f); |
135 hsv[1] = rand->nextRangeF(0.75f, 1.0f); | 135 hsv[1] = rand->nextRangeF(0.75f, 1.0f); |
136 hsv[2] = rand->nextRangeF(0.75f, 1.0f); | 136 hsv[2] = rand->nextRangeF(0.75f, 1.0f); |
137 | 137 |
138 return SkHSVToColor(hsv); | 138 return SkHSVToColor(hsv); |
139 } | 139 } |
140 | 140 |
141 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 141 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
142 SkRandom rand(1); | 142 SkRandom rand(1); |
143 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); | 143 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); |
144 SkRect oval = SkRect::MakeLTRB(-20, -30, 20, 30); | 144 SkRect oval = SkRect::MakeLTRB(-20, -30, 20, 30); |
145 | 145 |
146 const SkScalar kXStart = 60.0f; | 146 const SkScalar kXStart = 60.0f; |
147 const SkScalar kYStart = 80.0f; | 147 const SkScalar kYStart = 80.0f; |
148 const int kXStep = 150; | 148 const int kXStep = 150; |
149 const int kYStep = 160; | 149 const int kYStep = 160; |
150 int maxX = fMatrices.count(); | 150 int maxX = fMatrices.count(); |
151 | 151 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 typedef GM INHERITED; | 283 typedef GM INHERITED; |
284 }; | 284 }; |
285 | 285 |
286 ////////////////////////////////////////////////////////////////////////////// | 286 ////////////////////////////////////////////////////////////////////////////// |
287 | 287 |
288 static GM* MyFactory(void*) { return new OvalGM; } | 288 static GM* MyFactory(void*) { return new OvalGM; } |
289 static GMRegistry reg(MyFactory); | 289 static GMRegistry reg(MyFactory); |
290 | 290 |
291 } | 291 } |
OLD | NEW |