blob: bd906cbab2708c047045b05876101cdbc5c8bab6 [file] [log] [blame]
reed@google.com35a81df2012-05-04 21:49:27 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm.h"
9#include "SkCanvas.h"
10#include "SkPaint.h"
11#include "SkDashPathEffect.h"
12
reed@google.comde1837b2012-05-21 16:47:43 +000013static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint,
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +000014 SkScalar finalX = SkIntToScalar(600), SkScalar finalY = SkIntToScalar(0),
robertphillips9f2251c2014-11-04 13:33:50 -080015 SkScalar phase = SkIntToScalar(0),
16 SkScalar startX = SkIntToScalar(0), SkScalar startY = SkIntToScalar(0)) {
reed@google.com35a81df2012-05-04 21:49:27 +000017 SkPaint p(paint);
18
19 const SkScalar intervals[] = {
20 SkIntToScalar(on),
21 SkIntToScalar(off),
22 };
23
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +000024 p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref();
robertphillips9f2251c2014-11-04 13:33:50 -080025 canvas->drawLine(startX, startY, finalX, finalY, p);
reed@google.comde1837b2012-05-21 16:47:43 +000026}
27
28// earlier bug stopped us from drawing very long single-segment dashes, because
29// SkPathMeasure was skipping very small delta-T values (nearlyzero). This is
30// now fixes, so this giant dash should appear.
31static void show_giant_dash(SkCanvas* canvas) {
32 SkPaint paint;
33
34 drawline(canvas, 1, 1, paint, SkIntToScalar(20 * 1000));
reed@google.com35a81df2012-05-04 21:49:27 +000035}
36
egdaniel21402e32014-11-05 05:02:27 -080037static void show_zero_len_dash(SkCanvas* canvas) {
38 SkPaint paint;
39
40 drawline(canvas, 2, 2, paint, SkIntToScalar(0));
41 paint.setStyle(SkPaint::kStroke_Style);
42 paint.setStrokeWidth(SkIntToScalar(2));
43 canvas->translate(0, SkIntToScalar(20));
44 drawline(canvas, 4, 4, paint, SkIntToScalar(0));
45}
46
reed@google.com21384df2012-05-18 17:59:08 +000047class DashingGM : public skiagm::GM {
reed@google.com35a81df2012-05-04 21:49:27 +000048public:
49 DashingGM() {}
50
51protected:
commit-bot@chromium.orga90c6802014-04-30 13:20:45 +000052
reed@google.com35a81df2012-05-04 21:49:27 +000053 SkString onShortName() {
54 return SkString("dashing");
55 }
56
tfarinaf5393182014-06-09 23:59:03 -070057 SkISize onISize() { return SkISize::Make(640, 300); }
reed@google.com35a81df2012-05-04 21:49:27 +000058
59 virtual void onDraw(SkCanvas* canvas) {
60 static const struct {
61 int fOnInterval;
62 int fOffInterval;
63 } gData[] = {
64 { 1, 1 },
65 { 4, 1 },
66 };
rmistry@google.comae933ce2012-08-23 18:19:56 +000067
reed@google.com35a81df2012-05-04 21:49:27 +000068 SkPaint paint;
69 paint.setStyle(SkPaint::kStroke_Style);
70
71 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
72 canvas->translate(0, SK_ScalarHalf);
reed@google.com35a81df2012-05-04 21:49:27 +000073 for (int width = 0; width <= 2; ++width) {
74 for (size_t data = 0; data < SK_ARRAY_COUNT(gData); ++data) {
75 for (int aa = 0; aa <= 1; ++aa) {
76 int w = width * width * width;
77 paint.setAntiAlias(SkToBool(aa));
78 paint.setStrokeWidth(SkIntToScalar(w));
rmistry@google.comae933ce2012-08-23 18:19:56 +000079
reed@google.com35a81df2012-05-04 21:49:27 +000080 int scale = w ? w : 1;
81
82 drawline(canvas, gData[data].fOnInterval * scale,
83 gData[data].fOffInterval * scale,
84 paint);
85 canvas->translate(0, SkIntToScalar(20));
86 }
87 }
88 }
rmistry@google.comae933ce2012-08-23 18:19:56 +000089
reed@google.comde1837b2012-05-21 16:47:43 +000090 show_giant_dash(canvas);
egdaniel21402e32014-11-05 05:02:27 -080091 canvas->translate(0, SkIntToScalar(20));
92 show_zero_len_dash(canvas);
reed@google.com35a81df2012-05-04 21:49:27 +000093 }
reed@google.com21384df2012-05-18 17:59:08 +000094};
reed@google.com35a81df2012-05-04 21:49:27 +000095
reed@google.com21384df2012-05-18 17:59:08 +000096///////////////////////////////////////////////////////////////////////////////
97
98static void make_unit_star(SkPath* path, int n) {
99 SkScalar rad = -SK_ScalarPI / 2;
100 const SkScalar drad = (n >> 1) * SK_ScalarPI * 2 / n;
rmistry@google.comae933ce2012-08-23 18:19:56 +0000101
reed@google.com21384df2012-05-18 17:59:08 +0000102 path->moveTo(0, -SK_Scalar1);
103 for (int i = 1; i < n; i++) {
104 rad += drad;
105 SkScalar cosV, sinV = SkScalarSinCos(rad, &cosV);
106 path->lineTo(cosV, sinV);
107 }
108 path->close();
109}
110
111static void make_path_line(SkPath* path, const SkRect& bounds) {
112 path->moveTo(bounds.left(), bounds.top());
113 path->lineTo(bounds.right(), bounds.bottom());
114}
115
116static void make_path_rect(SkPath* path, const SkRect& bounds) {
117 path->addRect(bounds);
118}
119
120static void make_path_oval(SkPath* path, const SkRect& bounds) {
121 path->addOval(bounds);
122}
123
124static void make_path_star(SkPath* path, const SkRect& bounds) {
125 make_unit_star(path, 5);
126 SkMatrix matrix;
127 matrix.setRectToRect(path->getBounds(), bounds, SkMatrix::kCenter_ScaleToFit);
128 path->transform(matrix);
129}
130
131class Dashing2GM : public skiagm::GM {
132public:
133 Dashing2GM() {}
rmistry@google.comae933ce2012-08-23 18:19:56 +0000134
reed@google.com21384df2012-05-18 17:59:08 +0000135protected:
commit-bot@chromium.orga90c6802014-04-30 13:20:45 +0000136
reed@google.com21384df2012-05-18 17:59:08 +0000137 SkString onShortName() {
138 return SkString("dashing2");
139 }
rmistry@google.comae933ce2012-08-23 18:19:56 +0000140
tfarinaf5393182014-06-09 23:59:03 -0700141 SkISize onISize() { return SkISize::Make(640, 480); }
rmistry@google.comae933ce2012-08-23 18:19:56 +0000142
reed@google.com21384df2012-05-18 17:59:08 +0000143 virtual void onDraw(SkCanvas* canvas) {
144 static const int gIntervals[] = {
145 3, // 3 dashes: each count [0] followed by intervals [1..count]
146 2, 10, 10,
147 4, 20, 5, 5, 5,
148 2, 2, 2
149 };
150
151 void (*gProc[])(SkPath*, const SkRect&) = {
152 make_path_line, make_path_rect, make_path_oval, make_path_star,
153 };
rmistry@google.comae933ce2012-08-23 18:19:56 +0000154
reed@google.com21384df2012-05-18 17:59:08 +0000155 SkPaint paint;
156 paint.setAntiAlias(true);
157 paint.setStyle(SkPaint::kStroke_Style);
158 paint.setStrokeWidth(SkIntToScalar(6));
rmistry@google.comae933ce2012-08-23 18:19:56 +0000159
reed@google.com21384df2012-05-18 17:59:08 +0000160 SkRect bounds = SkRect::MakeWH(SkIntToScalar(120), SkIntToScalar(120));
161 bounds.offset(SkIntToScalar(20), SkIntToScalar(20));
162 SkScalar dx = bounds.width() * 4 / 3;
163 SkScalar dy = bounds.height() * 4 / 3;
164
165 const int* intervals = &gIntervals[1];
166 for (int y = 0; y < gIntervals[0]; ++y) {
167 SkScalar vals[SK_ARRAY_COUNT(gIntervals)]; // more than enough
168 int count = *intervals++;
169 for (int i = 0; i < count; ++i) {
170 vals[i] = SkIntToScalar(*intervals++);
171 }
172 SkScalar phase = vals[0] / 2;
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +0000173 paint.setPathEffect(SkDashPathEffect::Create(vals, count, phase))->unref();
rmistry@google.comae933ce2012-08-23 18:19:56 +0000174
reed@google.com21384df2012-05-18 17:59:08 +0000175 for (size_t x = 0; x < SK_ARRAY_COUNT(gProc); ++x) {
176 SkPath path;
177 SkRect r = bounds;
178 r.offset(x * dx, y * dy);
179 gProc[x](&path, r);
rmistry@google.comae933ce2012-08-23 18:19:56 +0000180
reed@google.com21384df2012-05-18 17:59:08 +0000181 canvas->drawPath(path, paint);
182 }
183 }
184 }
reed@google.com35a81df2012-05-04 21:49:27 +0000185};
186
187//////////////////////////////////////////////////////////////////////////////
188
robertphillips@google.com629ab542012-11-28 17:18:11 +0000189// Test out the on/off line dashing Chrome if fond of
190class Dashing3GM : public skiagm::GM {
191public:
192 Dashing3GM() {}
193
194protected:
commit-bot@chromium.orga90c6802014-04-30 13:20:45 +0000195
robertphillips@google.com629ab542012-11-28 17:18:11 +0000196 SkString onShortName() {
197 return SkString("dashing3");
198 }
199
tfarinaf5393182014-06-09 23:59:03 -0700200 SkISize onISize() { return SkISize::Make(640, 480); }
robertphillips@google.com629ab542012-11-28 17:18:11 +0000201
202 // Draw a 100x100 block of dashed lines. The horizontal ones are BW
203 // while the vertical ones are AA.
skia.committer@gmail.com73b140a2012-12-05 02:01:21 +0000204 void drawDashedLines(SkCanvas* canvas,
205 SkScalar lineLength,
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000206 SkScalar phase,
207 SkScalar dashLength,
208 int strokeWidth,
209 bool circles) {
robertphillips@google.com629ab542012-11-28 17:18:11 +0000210 SkPaint p;
211 p.setColor(SK_ColorBLACK);
212 p.setStyle(SkPaint::kStroke_Style);
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000213 p.setStrokeWidth(SkIntToScalar(strokeWidth));
robertphillips@google.com629ab542012-11-28 17:18:11 +0000214
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000215 if (circles) {
216 p.setStrokeCap(SkPaint::kRound_Cap);
217 }
218
219 SkScalar intervals[2] = { dashLength, dashLength };
robertphillips@google.com629ab542012-11-28 17:18:11 +0000220
commit-bot@chromium.org35c03fb2014-03-31 18:52:51 +0000221 p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref();
robertphillips@google.com629ab542012-11-28 17:18:11 +0000222
223 SkPoint pts[2];
224
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000225 for (int y = 0; y < 100; y += 10*strokeWidth) {
robertphillips@google.com629ab542012-11-28 17:18:11 +0000226 pts[0].set(0, SkIntToScalar(y));
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000227 pts[1].set(lineLength, SkIntToScalar(y));
robertphillips@google.com629ab542012-11-28 17:18:11 +0000228
229 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p);
230 }
231
232 p.setAntiAlias(true);
233
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000234 for (int x = 0; x < 100; x += 14*strokeWidth) {
robertphillips@google.com629ab542012-11-28 17:18:11 +0000235 pts[0].set(SkIntToScalar(x), 0);
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000236 pts[1].set(SkIntToScalar(x), lineLength);
robertphillips@google.com629ab542012-11-28 17:18:11 +0000237
238 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, pts, p);
239 }
240 }
241
242 virtual void onDraw(SkCanvas* canvas) {
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000243 // 1on/1off 1x1 squares with phase of 0 - points fastpath
robertphillips@google.com629ab542012-11-28 17:18:11 +0000244 canvas->save();
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000245 canvas->translate(2, 0);
246 this->drawDashedLines(canvas, 100, 0, SK_Scalar1, 1, false);
robertphillips@google.com629ab542012-11-28 17:18:11 +0000247 canvas->restore();
248
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000249 // 1on/1off 1x1 squares with phase of .5 - rects fastpath (due to partial squares)
robertphillips@google.com629ab542012-11-28 17:18:11 +0000250 canvas->save();
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000251 canvas->translate(112, 0);
252 this->drawDashedLines(canvas, 100, SK_ScalarHalf, SK_Scalar1, 1, false);
robertphillips@google.com629ab542012-11-28 17:18:11 +0000253 canvas->restore();
254
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000255 // 1on/1off 1x1 squares with phase of 1 - points fastpath
robertphillips@google.com629ab542012-11-28 17:18:11 +0000256 canvas->save();
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000257 canvas->translate(222, 0);
258 this->drawDashedLines(canvas, 100, SK_Scalar1, SK_Scalar1, 1, false);
robertphillips@google.com629ab542012-11-28 17:18:11 +0000259 canvas->restore();
260
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000261 // 1on/1off 1x1 squares with phase of 1 and non-integer length - rects fastpath
robertphillips@google.com629ab542012-11-28 17:18:11 +0000262 canvas->save();
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000263 canvas->translate(332, 0);
reed@google.com140d7282013-01-07 20:25:04 +0000264 this->drawDashedLines(canvas, 99.5f, SK_ScalarHalf, SK_Scalar1, 1, false);
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000265 canvas->restore();
266
robertphillips@google.com5c4d5582013-01-15 12:53:31 +0000267 // 255on/255off 1x1 squares with phase of 0 - rects fast path
268 canvas->save();
269 canvas->translate(446, 0);
270 this->drawDashedLines(canvas, 100, 0, SkIntToScalar(255), 1, false);
271 canvas->restore();
272
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000273 // 1on/1off 3x3 squares with phase of 0 - points fast path
274 canvas->save();
275 canvas->translate(2, 110);
276 this->drawDashedLines(canvas, 100, 0, SkIntToScalar(3), 3, false);
277 canvas->restore();
278
279 // 1on/1off 3x3 squares with phase of 1.5 - rects fast path
280 canvas->save();
281 canvas->translate(112, 110);
commit-bot@chromium.org4b413c82013-11-25 19:44:07 +0000282 this->drawDashedLines(canvas, 100, 1.5f, SkIntToScalar(3), 3, false);
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000283 canvas->restore();
284
285 // 1on/1off 1x1 circles with phase of 1 - no fast path yet
286 canvas->save();
287 canvas->translate(2, 220);
288 this->drawDashedLines(canvas, 100, SK_Scalar1, SK_Scalar1, 1, true);
289 canvas->restore();
290
291 // 1on/1off 3x3 circles with phase of 1 - no fast path yet
292 canvas->save();
293 canvas->translate(112, 220);
294 this->drawDashedLines(canvas, 100, 0, SkIntToScalar(3), 3, true);
295 canvas->restore();
296
297 // 1on/1off 1x1 squares with rotation - should break fast path
298 canvas->save();
299 canvas->translate(332+SK_ScalarRoot2Over2*100, 110+SK_ScalarRoot2Over2*100);
robertphillips@google.com629ab542012-11-28 17:18:11 +0000300 canvas->rotate(45);
301 canvas->translate(-50, -50);
302
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000303 this->drawDashedLines(canvas, 100, SK_Scalar1, SK_Scalar1, 1, false);
robertphillips@google.com629ab542012-11-28 17:18:11 +0000304 canvas->restore();
305
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000306 // 3on/3off 3x1 rects - should use rect fast path regardless of phase
307 for (int phase = 0; phase <= 3; ++phase) {
308 canvas->save();
skia.committer@gmail.com73b140a2012-12-05 02:01:21 +0000309 canvas->translate(SkIntToScalar(phase*110+2),
robertphillips@google.com8c685c52012-12-04 20:34:11 +0000310 SkIntToScalar(330));
311 this->drawDashedLines(canvas, 100, SkIntToScalar(phase), SkIntToScalar(3), 1, false);
312 canvas->restore();
313 }
robertphillips@google.com629ab542012-11-28 17:18:11 +0000314 }
315
316};
317
318//////////////////////////////////////////////////////////////////////////////
319
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000320class Dashing4GM : public skiagm::GM {
321public:
322 Dashing4GM() {}
323
324protected:
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000325
326 SkString onShortName() {
327 return SkString("dashing4");
328 }
329
tfarinaf5393182014-06-09 23:59:03 -0700330 SkISize onISize() { return SkISize::Make(640, 950); }
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000331
332 virtual void onDraw(SkCanvas* canvas) {
333 static const struct {
334 int fOnInterval;
335 int fOffInterval;
336 } gData[] = {
337 { 1, 1 },
338 { 4, 2 },
339 { 0, 4 }, // test for zero length on interval
340 };
341
342 SkPaint paint;
343 paint.setStyle(SkPaint::kStroke_Style);
344
345 canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
346 canvas->translate(0, SK_ScalarHalf);
347
348 for (int width = 0; width <= 2; ++width) {
349 for (size_t data = 0; data < SK_ARRAY_COUNT(gData); ++data) {
350 for (int aa = 0; aa <= 1; ++aa) {
351 for (int cap = 0; cap <= 1; ++cap) {
352 int w = width * width * width;
353 paint.setAntiAlias(SkToBool(aa));
354 paint.setStrokeWidth(SkIntToScalar(w));
355
356 SkToBool(cap) ? paint.setStrokeCap(SkPaint::kSquare_Cap)
357 : paint.setStrokeCap(SkPaint::kRound_Cap);
358
359 int scale = w ? w : 1;
360
361 drawline(canvas, gData[data].fOnInterval * scale,
362 gData[data].fOffInterval * scale,
363 paint);
364 canvas->translate(0, SkIntToScalar(20));
365 }
366 }
367 }
368 }
369
370 for (int aa = 0; aa <= 1; ++aa) {
371 paint.setAntiAlias(SkToBool(aa));
372 paint.setStrokeWidth(8.f);
373 paint.setStrokeCap(SkPaint::kSquare_Cap);
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000374 // Single dash element that is cut off at start and end
commit-bot@chromium.org71db8822014-05-19 14:59:04 +0000375 drawline(canvas, 32, 16, paint, 20.f, 0, 5.f);
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000376 canvas->translate(0, SkIntToScalar(20));
377
378 // Two dash elements where each one is cut off at beginning and end respectively
commit-bot@chromium.org71db8822014-05-19 14:59:04 +0000379 drawline(canvas, 32, 16, paint, 56.f, 0, 5.f);
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000380 canvas->translate(0, SkIntToScalar(20));
381
382 // Many dash elements where first and last are cut off at beginning and end respectively
commit-bot@chromium.org71db8822014-05-19 14:59:04 +0000383 drawline(canvas, 32, 16, paint, 584.f, 0, 5.f);
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000384 canvas->translate(0, SkIntToScalar(20));
385
386 // Diagonal dash line where src pnts are not axis aligned (as apposed to being diagonal from
387 // a canvas rotation)
commit-bot@chromium.org71db8822014-05-19 14:59:04 +0000388 drawline(canvas, 32, 16, paint, 600.f, 30.f);
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000389 canvas->translate(0, SkIntToScalar(20));
390
391 // Case where only the off interval exists on the line. Thus nothing should be drawn
commit-bot@chromium.org71db8822014-05-19 14:59:04 +0000392 drawline(canvas, 32, 16, paint, 8.f, 0.f, 40.f);
commit-bot@chromium.org628ed0b2014-05-19 14:32:49 +0000393 canvas->translate(0, SkIntToScalar(20));
394 }
395 }
396};
397
398//////////////////////////////////////////////////////////////////////////////
399
robertphillips9f2251c2014-11-04 13:33:50 -0800400class Dashing5GM : public skiagm::GM {
401public:
402 Dashing5GM(bool doAA) : fDoAA(doAA) {}
reed@google.com35a81df2012-05-04 21:49:27 +0000403
robertphillips9f2251c2014-11-04 13:33:50 -0800404protected:
robertphillips9f2251c2014-11-04 13:33:50 -0800405
mtklein36352bf2015-03-25 18:17:31 -0700406 bool runAsBench() const override { return true; }
mtkleincf5d9c92015-01-23 10:31:45 -0800407
mtklein36352bf2015-03-25 18:17:31 -0700408 SkString onShortName() override {
robertphillips9f2251c2014-11-04 13:33:50 -0800409 if (fDoAA) {
410 return SkString("dashing5_aa");
411 } else {
412 return SkString("dashing5_bw");
413 }
414 }
415
mtklein36352bf2015-03-25 18:17:31 -0700416 SkISize onISize() override { return SkISize::Make(400, 200); }
robertphillips9f2251c2014-11-04 13:33:50 -0800417
mtklein36352bf2015-03-25 18:17:31 -0700418 void onDraw(SkCanvas* canvas) override {
robertphillips9f2251c2014-11-04 13:33:50 -0800419 static const int kOn = 4;
420 static const int kOff = 4;
421 static const int kIntervalLength = kOn + kOff;
422
423 static const SkColor gColors[kIntervalLength] = {
424 SK_ColorRED,
425 SK_ColorGREEN,
426 SK_ColorBLUE,
427 SK_ColorCYAN,
428 SK_ColorMAGENTA,
429 SK_ColorYELLOW,
430 SK_ColorGRAY,
431 SK_ColorDKGRAY
432 };
433
434 SkPaint paint;
435 paint.setStyle(SkPaint::kStroke_Style);
436
437 paint.setAntiAlias(fDoAA);
438
439 SkMatrix rot;
440 rot.setRotate(90);
441 SkASSERT(rot.rectStaysRect());
442
443 canvas->concat(rot);
444
445 int sign; // used to toggle the direction of the lines
446 int phase = 0;
447
448 for (int x = 0; x < 200; x += 10) {
449 paint.setStrokeWidth(SkIntToScalar(phase+1));
450 paint.setColor(gColors[phase]);
451 sign = (x % 20) ? 1 : -1;
452 drawline(canvas, kOn, kOff, paint,
453 SkIntToScalar(x), -sign * SkIntToScalar(10003),
454 SkIntToScalar(phase),
455 SkIntToScalar(x), sign * SkIntToScalar(10003));
456 phase = (phase + 1) % kIntervalLength;
457 }
458
459 for (int y = -400; y < 0; y += 10) {
460 paint.setStrokeWidth(SkIntToScalar(phase+1));
461 paint.setColor(gColors[phase]);
462 sign = (y % 20) ? 1 : -1;
463 drawline(canvas, kOn, kOff, paint,
464 -sign * SkIntToScalar(10003), SkIntToScalar(y),
465 SkIntToScalar(phase),
466 sign * SkIntToScalar(10003), SkIntToScalar(y));
467 phase = (phase + 1) % kIntervalLength;
468 }
469 }
470
471private:
472 bool fDoAA;
473};
474
475//////////////////////////////////////////////////////////////////////////////
476
477DEF_GM(return SkNEW(DashingGM);)
478DEF_GM(return SkNEW(Dashing2GM);)
479DEF_GM(return SkNEW(Dashing3GM);)
480DEF_GM(return SkNEW(Dashing4GM);)
481DEF_GM(return SkNEW_ARGS(Dashing5GM, (true));)
482DEF_GM(return SkNEW_ARGS(Dashing5GM, (false));)
483