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 "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // A right angle (crbug.com/137465 and crbug.com/256776) | 131 // A right angle (crbug.com/137465 and crbug.com/256776) |
132 SkPath* bug2 = &fPaths.push_back(); | 132 SkPath* bug2 = &fPaths.push_back(); |
133 | 133 |
134 bug2->moveTo(5.5f, 5.5f); | 134 bug2->moveTo(5.5f, 5.5f); |
135 bug2->lineTo(5.5f, 0.5f); | 135 bug2->lineTo(5.5f, 0.5f); |
136 bug2->lineTo(0.5f, 0.5f); | 136 bug2->lineTo(0.5f, 0.5f); |
137 } | 137 } |
138 | 138 |
139 { | 139 { |
140 // Arc example to test imperfect truncation bug (crbug.com/295626) | 140 // Arc example to test imperfect truncation bug (crbug.com/295626) |
141 static const SkScalar kRad = SkIntToScalar(2000); | 141 constexpr SkScalar kRad = SkIntToScalar(2000); |
142 static const SkScalar kStartAngle = 262.59717f; | 142 constexpr SkScalar kStartAngle = 262.59717f; |
143 static const SkScalar kSweepAngle = SkScalarHalf(17.188717f); | 143 constexpr SkScalar kSweepAngle = SkScalarHalf(17.188717f); |
144 | 144 |
145 SkPath* bug = &fPaths.push_back(); | 145 SkPath* bug = &fPaths.push_back(); |
146 | 146 |
147 // Add a circular arc | 147 // Add a circular arc |
148 SkRect circle = SkRect::MakeLTRB(-kRad, -kRad, kRad, kRad); | 148 SkRect circle = SkRect::MakeLTRB(-kRad, -kRad, kRad, kRad); |
149 bug->addArc(circle, kStartAngle, kSweepAngle); | 149 bug->addArc(circle, kStartAngle, kSweepAngle); |
150 | 150 |
151 // Now add the chord that should cap the circular arc | 151 // Now add the chord that should cap the circular arc |
152 SkScalar cosV, sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle)
, &cosV); | 152 SkScalar cosV, sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle)
, &cosV); |
153 | 153 |
154 SkPoint p0 = SkPoint::Make(kRad * cosV, kRad * sinV); | 154 SkPoint p0 = SkPoint::Make(kRad * cosV, kRad * sinV); |
155 | 155 |
156 sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle + kSweepAngle),
&cosV); | 156 sinV = SkScalarSinCos(SkDegreesToRadians(kStartAngle + kSweepAngle),
&cosV); |
157 | 157 |
158 SkPoint p1 = SkPoint::Make(kRad * cosV, kRad * sinV); | 158 SkPoint p1 = SkPoint::Make(kRad * cosV, kRad * sinV); |
159 | 159 |
160 bug->moveTo(p0); | 160 bug->moveTo(p0); |
161 bug->lineTo(p1); | 161 bug->lineTo(p1); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 void onDraw(SkCanvas* canvas) override { | 165 void onDraw(SkCanvas* canvas) override { |
166 static const SkAlpha kAlphaValue[] = { 0xFF, 0x40 }; | 166 constexpr SkAlpha kAlphaValue[] = { 0xFF, 0x40 }; |
167 static const SkScalar kWidths[] = { 0, 0.5f, 1.5f }; | 167 constexpr SkScalar kWidths[] = { 0, 0.5f, 1.5f }; |
168 | 168 |
169 enum { | 169 enum { |
170 kMargin = 5, | 170 kMargin = 5, |
171 }; | 171 }; |
172 int wrapX = 1250 - kMargin; | 172 int wrapX = 1250 - kMargin; |
173 | 173 |
174 SkScalar maxH = 0; | 174 SkScalar maxH = 0; |
175 canvas->translate(SkIntToScalar(kMargin), SkIntToScalar(kMargin)); | 175 canvas->translate(SkIntToScalar(kMargin), SkIntToScalar(kMargin)); |
176 canvas->save(); | 176 canvas->save(); |
177 | 177 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 canvas->translate(120, 0); | 255 canvas->translate(120, 0); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 ////////////////////////////////////////////////////////////////////////////// | 259 ////////////////////////////////////////////////////////////////////////////// |
260 | 260 |
261 static GM* MyFactory(void*) { return new HairlinesGM; } | 261 static GM* MyFactory(void*) { return new HairlinesGM; } |
262 static GMRegistry reg(MyFactory); | 262 static GMRegistry reg(MyFactory); |
263 | 263 |
264 } | 264 } |
OLD | NEW |