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

Side by Side Diff: src/core/SkDashMeasure.h

Issue 2236483004: Add SkDashMeasure.h (name up for bikeshedding) which takes a dashinfo (Closed) Base URL: https://skia.googlesource.com/skia.git@initializer_constructor
Patch Set: remove accidentally-included test gm Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 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 "SkCurveMeasure.h"
9 #include "SkGeometry.h"
10 #include "SkPath.h"
11 #include "SkPathEffect.h"
12 #include "SkPathMeasurePriv.h"
13
14 static inline void getDashedPath(const SkPath& path,
15 const struct SkPathEffect::DashInfo& dashInfo,
16 SkPath* dst) {
17 const SkScalar* intervals = dashInfo.fIntervals;
18
19 SkScalar interval_accum = 0.0f;
caryclark 2016/08/11 12:35:12 remove this
Harry Stern 2016/08/11 15:21:09 Done.
20 int32_t interval_index = 0;
21
22 interval_accum = intervals[interval_index];
caryclark 2016/08/11 12:35:12 SkScalar internal_accum ...
Harry Stern 2016/08/11 15:21:09 Done.
23
24 SkPath::Iter iter(path, false);
25 SkPath::Verb current;
26 SkPoint pts[4];
27
28 while ((current = iter.next(pts)) != SkPath::kDone_Verb) {
29 SkSegType segtype;
30 SkPoint end;
31 switch (current) {
32 case (SkPath::kMove_Verb):
caryclark 2016/08/11 12:35:12 no need for parens
Harry Stern 2016/08/11 15:21:09 Done.
33 dst->moveTo(pts[0]);
34 continue;
35 case (SkPath::kLine_Verb):
36 segtype = kLine_SegType;
37 end = pts[1];
38 break;
39 case (SkPath::kQuad_Verb):
40 segtype = kQuad_SegType;
41 end = pts[2];
42 break;
43 case (SkPath::kConic_Verb):
44 segtype = kConic_SegType;
45 end = pts[3];
caryclark 2016/08/11 12:35:12 pts[2]
Harry Stern 2016/08/11 15:21:09 Done.
46 break;
47 case (SkPath::kCubic_Verb):
48 segtype = kCubic_SegType;
49 end = pts[3];
50 break;
51 case (SkPath::kClose_Verb):
52 // should not appear in the iter since we're not using RawIter
53 SkASSERT(false);
54 break;
55 default: // unreachable
56 SkASSERT(false);
57 break;
58 }
59
60 // TODO(hstern): Do heuristic check to see whether we should do
61 // pathmeasure or curvemeasure. probably do it before the outer loop
62 // by giving CurveMeasure a reset() and reusing the object inside.
63 SkCurveMeasure meas(pts, segtype);
64
65 SkScalar prevT = 0.0f;
caryclark 2016/08/11 12:35:12 0 is fine here
Harry Stern 2016/08/11 15:21:09 Done.
66
67 SkScalar current_length = meas.getLength();
68 while (interval_accum < current_length) {
69 SkScalar time;
70 SkPoint pos;
71 meas.getPosTanTime(interval_accum, &pos, nullptr, &time);
72 if (!(interval_index%2)) {
caryclark 2016/08/11 12:35:12 spaces on both sides of %
Harry Stern 2016/08/11 15:21:09 Done. I'm actually going to put this in a tiny hel
73 SkPathMeasure_segTo(pts, segtype, prevT, time, dst);
74 }
75 else {
76 dst->moveTo(pos);
caryclark 2016/08/11 12:35:12 put else on same line as close brace
Harry Stern 2016/08/11 15:21:09 Done, but I have written my elses on separate line
77 }
78 prevT = time;
79
80 interval_accum += intervals[interval_index];
81 interval_index = (interval_index+1)%dashInfo.fCount;
caryclark 2016/08/11 12:35:12 spaces on both sides of %
Harry Stern 2016/08/11 15:21:09 Done.
82 }
83 if (!(interval_index%2)) {
caryclark 2016/08/11 12:35:12 spaces on either side of %
Harry Stern 2016/08/11 15:21:09 Done.
84 SkPathMeasure_segTo(pts, segtype, prevT, 1.0f, dst);
caryclark 2016/08/11 12:35:12 1 is fine here
Harry Stern 2016/08/11 15:21:09 Done.
85 }
86 else {
caryclark 2016/08/11 12:35:12 put else on same line as close brace
Harry Stern 2016/08/11 15:21:09 Done.
87 dst->moveTo(end);
88 }
89
90 interval_accum = interval_accum - current_length;
91 }
92 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698