Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: gm/dashing.cpp

Issue 1805963002: allow one zero length dash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix dash nanobench Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/arcto.cpp ('k') | src/effects/SkDashPathEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkPaint.h" 10 #include "SkPaint.h"
11 #include "SkDashPathEffect.h" 11 #include "SkDashPathEffect.h"
12 12
13 static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint, 13 static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint,
14 SkScalar finalX = SkIntToScalar(600), SkScalar finalY = SkI ntToScalar(0), 14 SkScalar finalX = SkIntToScalar(600), SkScalar finalY = SkI ntToScalar(0),
15 SkScalar phase = SkIntToScalar(0), 15 SkScalar phase = SkIntToScalar(0),
16 SkScalar startX = SkIntToScalar(0), SkScalar startY = SkInt ToScalar(0)) { 16 SkScalar startX = SkIntToScalar(0), SkScalar startY = SkInt ToScalar(0)) {
17 SkPaint p(paint); 17 SkPaint p(paint);
18 18
19 const SkScalar intervals[] = { 19 const SkScalar intervals[] = {
20 SkIntToScalar(on), 20 SkIntToScalar(on),
21 SkIntToScalar(off), 21 SkIntToScalar(off),
22 }; 22 };
23 23
24 p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref(); 24 SkAutoTUnref<SkPathEffect> effect(SkDashPathEffect::Create(intervals, 2, pha se));
25 p.setPathEffect(effect);
25 canvas->drawLine(startX, startY, finalX, finalY, p); 26 canvas->drawLine(startX, startY, finalX, finalY, p);
26 } 27 }
27 28
28 // earlier bug stopped us from drawing very long single-segment dashes, because 29 // 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 // SkPathMeasure was skipping very small delta-T values (nearlyzero). This is
30 // now fixes, so this giant dash should appear. 31 // now fixes, so this giant dash should appear.
31 static void show_giant_dash(SkCanvas* canvas) { 32 static void show_giant_dash(SkCanvas* canvas) {
32 SkPaint paint; 33 SkPaint paint;
33 34
34 drawline(canvas, 1, 1, paint, SkIntToScalar(20 * 1000)); 35 drawline(canvas, 1, 1, paint, SkIntToScalar(20 * 1000));
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 544 }
544 545
545 ////////////////////////////////////////////////////////////////////////////// 546 //////////////////////////////////////////////////////////////////////////////
546 547
547 DEF_GM(return new DashingGM;) 548 DEF_GM(return new DashingGM;)
548 DEF_GM(return new Dashing2GM;) 549 DEF_GM(return new Dashing2GM;)
549 DEF_GM(return new Dashing3GM;) 550 DEF_GM(return new Dashing3GM;)
550 DEF_GM(return new Dashing4GM;) 551 DEF_GM(return new Dashing4GM;)
551 DEF_GM(return new Dashing5GM(true);) 552 DEF_GM(return new Dashing5GM(true);)
552 DEF_GM(return new Dashing5GM(false);) 553 DEF_GM(return new Dashing5GM(false);)
OLDNEW
« no previous file with comments | « gm/arcto.cpp ('k') | src/effects/SkDashPathEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698