OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkTArray.h" | 10 #include "SkTArray.h" |
11 | 11 |
12 namespace skiagm { | 12 namespace skiagm { |
13 | 13 |
14 class HairlinesGM : public GM { | 14 class HairlinesGM : public GM { |
15 protected: | 15 protected: |
16 | 16 |
17 | 17 |
18 SkString onShortName() SK_OVERRIDE { | 18 SkString onShortName() override { |
19 return SkString("hairlines"); | 19 return SkString("hairlines"); |
20 } | 20 } |
21 | 21 |
22 SkISize onISize() SK_OVERRIDE { return SkISize::Make(1250, 1250); } | 22 SkISize onISize() override { return SkISize::Make(1250, 1250); } |
23 | 23 |
24 void onOnceBeforeDraw() SK_OVERRIDE { | 24 void onOnceBeforeDraw() override { |
25 { | 25 { |
26 SkPath* lineAnglesPath = &fPaths.push_back(); | 26 SkPath* lineAnglesPath = &fPaths.push_back(); |
27 enum { | 27 enum { |
28 kNumAngles = 15, | 28 kNumAngles = 15, |
29 kRadius = 40, | 29 kRadius = 40, |
30 }; | 30 }; |
31 for (int i = 0; i < kNumAngles; ++i) { | 31 for (int i = 0; i < kNumAngles; ++i) { |
32 SkScalar angle = SK_ScalarPI * SkIntToScalar(i) / kNumAngles; | 32 SkScalar angle = SK_ScalarPI * SkIntToScalar(i) / kNumAngles; |
33 SkScalar x = kRadius * SkScalarCos(angle); | 33 SkScalar x = kRadius * SkScalarCos(angle); |
34 SkScalar y = kRadius * SkScalarSin(angle); | 34 SkScalar y = kRadius * SkScalarSin(angle); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle + kSweepAngle),
&cosV); | 155 sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle + kSweepAngle),
&cosV); |
156 | 156 |
157 SkPoint p1 = SkPoint::Make(kRad * cosV, kRad * sinV); | 157 SkPoint p1 = SkPoint::Make(kRad * cosV, kRad * sinV); |
158 | 158 |
159 bug->moveTo(p0); | 159 bug->moveTo(p0); |
160 bug->lineTo(p1); | 160 bug->lineTo(p1); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 164 void onDraw(SkCanvas* canvas) override { |
165 static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 }; | 165 static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 }; |
166 static const SkScalar kWidths[] = { 0, 0.5f, 1.5f }; | 166 static const SkScalar kWidths[] = { 0, 0.5f, 1.5f }; |
167 | 167 |
168 enum { | 168 enum { |
169 kMargin = 5, | 169 kMargin = 5, |
170 }; | 170 }; |
171 int wrapX = canvas->getDeviceSize().fWidth - kMargin; | 171 int wrapX = canvas->getDeviceSize().fWidth - kMargin; |
172 | 172 |
173 SkScalar maxH = 0; | 173 SkScalar maxH = 0; |
174 canvas->translate(SkIntToScalar(kMargin), SkIntToScalar(kMargin)); | 174 canvas->translate(SkIntToScalar(kMargin), SkIntToScalar(kMargin)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 SkTArray<SkPath> fPaths; | 216 SkTArray<SkPath> fPaths; |
217 typedef GM INHERITED; | 217 typedef GM INHERITED; |
218 }; | 218 }; |
219 | 219 |
220 ////////////////////////////////////////////////////////////////////////////// | 220 ////////////////////////////////////////////////////////////////////////////// |
221 | 221 |
222 static GM* MyFactory(void*) { return new HairlinesGM; } | 222 static GM* MyFactory(void*) { return new HairlinesGM; } |
223 static GMRegistry reg(MyFactory); | 223 static GMRegistry reg(MyFactory); |
224 | 224 |
225 } | 225 } |
OLD | NEW |