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

Side by Side Diff: src/pathops/SkPathOpsCurve.h

Issue 1096923003: working on initial winding for cubics (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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 | « src/pathops/SkPathOpsCubic.cpp ('k') | src/pathops/SkPathOpsDebug.h » ('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 #ifndef SkPathOpsCurve_DEFINE 7 #ifndef SkPathOpsCurve_DEFINE
8 #define SkPathOpsCurve_DEFINE 8 #define SkPathOpsCurve_DEFINE
9 9
10 #include "SkIntersections.h" 10 #include "SkIntersections.h"
11 #include "SkPathOpsCubic.h" 11 #include "SkPathOpsCubic.h"
12 #include "SkPathOpsLine.h" 12 #include "SkPathOpsLine.h"
13 #include "SkPathOpsQuad.h" 13 #include "SkPathOpsQuad.h"
14 14
15 #ifndef SK_RELEASE 15 #ifndef SK_RELEASE
16 #include "SkPath.h" 16 #include "SkPath.h"
17 #endif 17 #endif
18 18
19 struct SkOpCurve { 19 struct SkOpCurve {
20 SkPoint fPts[4]; 20 SkPoint fPts[4];
21 SkScalar fWeight; 21 SkScalar fWeight;
22 SkDEBUGCODE(SkPath::Verb fVerb); 22 SkDEBUGCODE(SkPath::Verb fVerb);
23 23
24 const SkPoint& operator[](int n) const { 24 const SkPoint& operator[](int n) const {
25 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb)); 25 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
26 return fPts[n]; 26 return fPts[n];
27 } 27 }
28 28
29 void dump() const;
30
31 void set(const SkDQuad& quad) {
32 for (int index = 0; index < SkDQuad::kPointCount; ++index) {
33 fPts[index] = quad[index].asSkPoint();
34 }
35 SkDEBUGCODE(fWeight = 1);
36 SkDEBUGCODE(fVerb = SkPath::kQuad_Verb);
37 }
38
29 void set(const SkDCubic& cubic) { 39 void set(const SkDCubic& cubic) {
30 for (int index = 0; index < SkDCubic::kPointCount; ++index) { 40 for (int index = 0; index < SkDCubic::kPointCount; ++index) {
31 fPts[index] = cubic[index].asSkPoint(); 41 fPts[index] = cubic[index].asSkPoint();
32 } 42 }
33 SkDEBUGCODE(fWeight = 1); 43 SkDEBUGCODE(fWeight = 1);
34 SkDEBUGCODE(fVerb = SkPath::kCubic_Verb); 44 SkDEBUGCODE(fVerb = SkPath::kCubic_Verb);
35 } 45 }
36 }; 46 };
37 47
38 struct SkDCurve { 48 struct SkDCurve {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 172 }
163 173
164 static SkVector (* const CurveSlopeAtT[])(const SkPoint[], SkScalar , double ) = { 174 static SkVector (* const CurveSlopeAtT[])(const SkPoint[], SkScalar , double ) = {
165 NULL, 175 NULL,
166 fline_dxdy_at_t, 176 fline_dxdy_at_t,
167 fquad_dxdy_at_t, 177 fquad_dxdy_at_t,
168 fconic_dxdy_at_t, 178 fconic_dxdy_at_t,
169 fcubic_dxdy_at_t 179 fcubic_dxdy_at_t
170 }; 180 };
171 181
172 static SkPoint quad_top(const SkPoint a[3], SkScalar , double startT, double end T) { 182 static SkPoint quad_top(const SkPoint a[3], SkScalar , double startT, double end T, double* topT) {
173 SkDQuad quad; 183 SkDQuad quad;
174 quad.set(a); 184 quad.set(a);
175 SkDPoint topPt = quad.top(startT, endT); 185 SkDPoint topPt = quad.top(startT, endT, topT);
176 return topPt.asSkPoint(); 186 return topPt.asSkPoint();
177 } 187 }
178 188
179 static SkPoint conic_top(const SkPoint a[3], SkScalar weight, double startT, dou ble endT) { 189 static SkPoint conic_top(const SkPoint a[3], SkScalar weight, double startT, dou ble endT,
190 double* topT) {
180 SkDConic conic; 191 SkDConic conic;
181 conic.set(a, weight); 192 conic.set(a, weight);
182 SkDPoint topPt = conic.top(startT, endT); 193 SkDPoint topPt = conic.top(startT, endT, topT);
183 return topPt.asSkPoint(); 194 return topPt.asSkPoint();
184 } 195 }
185 196
186 static SkPoint cubic_top(const SkPoint a[4], SkScalar , double startT, double en dT) { 197 static SkPoint cubic_top(const SkPoint a[4], SkScalar , double startT, double en dT, double* topT) {
187 SkDCubic cubic; 198 SkDCubic cubic;
188 cubic.set(a); 199 cubic.set(a);
189 SkDPoint topPt = cubic.top(startT, endT); 200 SkDPoint topPt = cubic.top(startT, endT, topT);
190 return topPt.asSkPoint(); 201 return topPt.asSkPoint();
191 } 202 }
192 203
193 static SkPoint (* const CurveTop[])(const SkPoint[], SkScalar , double , double ) = { 204 static SkPoint (* const CurveTop[])(const SkPoint[], SkScalar , double , double , double* ) = {
194 NULL, 205 NULL,
195 NULL, 206 NULL,
196 quad_top, 207 quad_top,
197 conic_top, 208 conic_top,
198 cubic_top 209 cubic_top
199 }; 210 };
200 211
201 static bool line_is_vertical(const SkPoint a[2], SkScalar , double startT, doubl e endT) { 212 static bool line_is_vertical(const SkPoint a[2], SkScalar , double startT, doubl e endT) {
202 SkDLine line; 213 SkDLine line;
203 line.set(a); 214 line.set(a);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 static void (* const CurveIntersectRay[])(const SkPoint[] , SkScalar , const SkD Line& , 277 static void (* const CurveIntersectRay[])(const SkPoint[] , SkScalar , const SkD Line& ,
267 SkIntersections* ) = { 278 SkIntersections* ) = {
268 NULL, 279 NULL,
269 line_intersect_ray, 280 line_intersect_ray,
270 quad_intersect_ray, 281 quad_intersect_ray,
271 conic_intersect_ray, 282 conic_intersect_ray,
272 cubic_intersect_ray 283 cubic_intersect_ray
273 }; 284 };
274 285
275 #endif 286 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkPathOpsCubic.cpp ('k') | src/pathops/SkPathOpsDebug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698