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

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

Issue 2128633003: pathops coincidence and security rewrite (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: require resulting t to be between 0 and 1 Created 4 years, 5 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
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"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const SkDPoint& operator[](int n) const { 57 const SkDPoint& operator[](int n) const {
58 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb)); 58 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
59 return fCubic[n]; 59 return fCubic[n];
60 } 60 }
61 61
62 SkDPoint& operator[](int n) { 62 SkDPoint& operator[](int n) {
63 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb)); 63 SkASSERT(n >= 0 && n <= SkPathOpsVerbToPoints(fVerb));
64 return fCubic[n]; 64 return fCubic[n];
65 } 65 }
66 66
67 SkDPoint conicTop(const SkPoint curve[3], SkScalar curveWeight, 67 SkDPoint conicTop(const SkPoint curve[3], SkScalar curveWeight,
68 double s, double e, double* topT); 68 double s, double e, double* topT);
69 SkDPoint cubicTop(const SkPoint curve[4], SkScalar , double s, double e, dou ble* topT); 69 SkDPoint cubicTop(const SkPoint curve[4], SkScalar , double s, double e, dou ble* topT);
70 void dump() const;
70 void dumpID(int ) const; 71 void dumpID(int ) const;
71 SkDPoint lineTop(const SkPoint[2], SkScalar , double , double , double* topT ); 72 SkDPoint lineTop(const SkPoint[2], SkScalar , double , double , double* topT );
73 double nearPoint(SkPath::Verb verb, const SkDPoint& xy, const SkDPoint& opp) const;
74 void offset(SkPath::Verb verb, const SkDVector& );
72 SkDPoint quadTop(const SkPoint curve[3], SkScalar , double s, double e, doub le* topT); 75 SkDPoint quadTop(const SkPoint curve[3], SkScalar , double s, double e, doub le* topT);
73 76
74 void setConicBounds(const SkPoint curve[3], SkScalar curveWeight, 77 void setConicBounds(const SkPoint curve[3], SkScalar curveWeight,
75 double s, double e, SkPathOpsBounds* ); 78 double s, double e, SkPathOpsBounds* );
76 void setCubicBounds(const SkPoint curve[4], SkScalar , 79 void setCubicBounds(const SkPoint curve[4], SkScalar ,
77 double s, double e, SkPathOpsBounds* ); 80 double s, double e, SkPathOpsBounds* );
78 void setQuadBounds(const SkPoint curve[3], SkScalar , 81 void setQuadBounds(const SkPoint curve[3], SkScalar ,
79 double s, double e, SkPathOpsBounds*); 82 double s, double e, SkPathOpsBounds*);
80 }; 83 };
81 84
82 85
83 extern SkDPoint (SkDCurve::* const Top[])(const SkPoint curve[], SkScalar cWeigh t, 86 extern SkDPoint (SkDCurve::* const Top[])(const SkPoint curve[], SkScalar cWeigh t,
84 double tStart, double tEnd, double* topT); 87 double tStart, double tEnd, double* topT);
(...skipping 23 matching lines...) Expand all
108 } 111 }
109 112
110 static SkDPoint (* const CurveDPointAtT[])(const SkPoint[], SkScalar , double ) = { 113 static SkDPoint (* const CurveDPointAtT[])(const SkPoint[], SkScalar , double ) = {
111 nullptr, 114 nullptr,
112 dline_xy_at_t, 115 dline_xy_at_t,
113 dquad_xy_at_t, 116 dquad_xy_at_t,
114 dconic_xy_at_t, 117 dconic_xy_at_t,
115 dcubic_xy_at_t 118 dcubic_xy_at_t
116 }; 119 };
117 120
121 static SkDPoint ddline_xy_at_t(const SkDCurve& c, double t) {
122 return c.fLine.ptAtT(t);
123 }
124
125 static SkDPoint ddquad_xy_at_t(const SkDCurve& c, double t) {
126 return c.fQuad.ptAtT(t);
127 }
128
129 static SkDPoint ddconic_xy_at_t(const SkDCurve& c, double t) {
130 return c.fConic.ptAtT(t);
131 }
132
133 static SkDPoint ddcubic_xy_at_t(const SkDCurve& c, double t) {
134 return c.fCubic.ptAtT(t);
135 }
136
137 static SkDPoint (* const CurveDDPointAtT[])(const SkDCurve& , double ) = {
herb_g 2016/07/18 15:13:39 Space before ","
caryclark 2016/07/18 15:55:49 The Skia style guide https://skia.org/dev/contrib/
138 nullptr,
139 ddline_xy_at_t,
140 ddquad_xy_at_t,
141 ddconic_xy_at_t,
142 ddcubic_xy_at_t
143 };
144
118 static SkPoint fline_xy_at_t(const SkPoint a[2], SkScalar weight, double t) { 145 static SkPoint fline_xy_at_t(const SkPoint a[2], SkScalar weight, double t) {
119 return dline_xy_at_t(a, weight, t).asSkPoint(); 146 return dline_xy_at_t(a, weight, t).asSkPoint();
120 } 147 }
121 148
122 static SkPoint fquad_xy_at_t(const SkPoint a[3], SkScalar weight, double t) { 149 static SkPoint fquad_xy_at_t(const SkPoint a[3], SkScalar weight, double t) {
123 return dquad_xy_at_t(a, weight, t).asSkPoint(); 150 return dquad_xy_at_t(a, weight, t).asSkPoint();
124 } 151 }
125 152
126 static SkPoint fconic_xy_at_t(const SkPoint a[3], SkScalar weight, double t) { 153 static SkPoint fconic_xy_at_t(const SkPoint a[3], SkScalar weight, double t) {
127 return dconic_xy_at_t(a, weight, t).asSkPoint(); 154 return dconic_xy_at_t(a, weight, t).asSkPoint();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 191 }
165 192
166 static SkDVector (* const CurveDSlopeAtT[])(const SkPoint[], SkScalar , double ) = { 193 static SkDVector (* const CurveDSlopeAtT[])(const SkPoint[], SkScalar , double ) = {
167 nullptr, 194 nullptr,
168 dline_dxdy_at_t, 195 dline_dxdy_at_t,
169 dquad_dxdy_at_t, 196 dquad_dxdy_at_t,
170 dconic_dxdy_at_t, 197 dconic_dxdy_at_t,
171 dcubic_dxdy_at_t 198 dcubic_dxdy_at_t
172 }; 199 };
173 200
201 static SkDVector ddline_dxdy_at_t(const SkDCurve& c, double ) {
202 return c.fLine.fPts[1] - c.fLine.fPts[0];
203 }
204
205 static SkDVector ddquad_dxdy_at_t(const SkDCurve& c, double t) {
206 return c.fQuad.dxdyAtT(t);
207 }
208
209 static SkDVector ddconic_dxdy_at_t(const SkDCurve& c, double t) {
210 return c.fConic.dxdyAtT(t);
211 }
212
213 static SkDVector ddcubic_dxdy_at_t(const SkDCurve& c, double t) {
214 return c.fCubic.dxdyAtT(t);
215 }
216
217 static SkDVector (* const CurveDDSlopeAtT[])(const SkDCurve& , double ) = {
218 nullptr,
219 ddline_dxdy_at_t,
220 ddquad_dxdy_at_t,
221 ddconic_dxdy_at_t,
222 ddcubic_dxdy_at_t
223 };
224
174 static SkVector fline_dxdy_at_t(const SkPoint a[2], SkScalar , double ) { 225 static SkVector fline_dxdy_at_t(const SkPoint a[2], SkScalar , double ) {
175 return a[1] - a[0]; 226 return a[1] - a[0];
176 } 227 }
177 228
178 static SkVector fquad_dxdy_at_t(const SkPoint a[3], SkScalar weight, double t) { 229 static SkVector fquad_dxdy_at_t(const SkPoint a[3], SkScalar weight, double t) {
179 return dquad_dxdy_at_t(a, weight, t).asSkVector(); 230 return dquad_dxdy_at_t(a, weight, t).asSkVector();
180 } 231 }
181 232
182 static SkVector fconic_dxdy_at_t(const SkPoint a[3], SkScalar weight, double t) { 233 static SkVector fconic_dxdy_at_t(const SkPoint a[3], SkScalar weight, double t) {
183 return dconic_dxdy_at_t(a, weight, t).asSkVector(); 234 return dconic_dxdy_at_t(a, weight, t).asSkVector();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 313
263 static void (* const CurveIntersectRay[])(const SkPoint[] , SkScalar , const SkD Line& , 314 static void (* const CurveIntersectRay[])(const SkPoint[] , SkScalar , const SkD Line& ,
264 SkIntersections* ) = { 315 SkIntersections* ) = {
265 nullptr, 316 nullptr,
266 line_intersect_ray, 317 line_intersect_ray,
267 quad_intersect_ray, 318 quad_intersect_ray,
268 conic_intersect_ray, 319 conic_intersect_ray,
269 cubic_intersect_ray 320 cubic_intersect_ray
270 }; 321 };
271 322
323 static void dline_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkInters ections* i) {
324 i->intersectRay(c.fLine, ray);
325 }
326
327 static void dquad_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkInterse ctions* i) {
328 i->intersectRay(c.fQuad, ray);
329 }
330
331 static void dconic_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkInters ections* i) {
332 i->intersectRay(c.fConic, ray);
333 }
334
335 static void dcubic_intersect_ray(const SkDCurve& c, const SkDLine& ray, SkInters ections* i) {
336 i->intersectRay(c.fCubic, ray);
337 }
338
339 static void (* const CurveDIntersectRay[])(const SkDCurve& , const SkDLine& , Sk Intersections* ) = {
340 nullptr,
341 dline_intersect_ray,
342 dquad_intersect_ray,
343 dconic_intersect_ray,
344 dcubic_intersect_ray
345 };
346
272 static int line_intercept_h(const SkPoint a[2], SkScalar , SkScalar y, double* r oots) { 347 static int line_intercept_h(const SkPoint a[2], SkScalar , SkScalar y, double* r oots) {
273 SkDLine line; 348 SkDLine line;
274 roots[0] = SkIntersections::HorizontalIntercept(line.set(a), y); 349 roots[0] = SkIntersections::HorizontalIntercept(line.set(a), y);
275 return between(0, roots[0], 1); 350 return between(0, roots[0], 1);
276 } 351 }
277 352
278 static int line_intercept_v(const SkPoint a[2], SkScalar , SkScalar x, double* r oots) { 353 static int line_intercept_v(const SkPoint a[2], SkScalar , SkScalar x, double* r oots) {
279 SkDLine line; 354 SkDLine line;
280 roots[0] = SkIntersections::VerticalIntercept(line.set(a), x); 355 roots[0] = SkIntersections::VerticalIntercept(line.set(a), x);
281 return between(0, roots[0], 1); 356 return between(0, roots[0], 1);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 line_intercept_v, 393 line_intercept_v,
319 quad_intercept_h, 394 quad_intercept_h,
320 quad_intercept_v, 395 quad_intercept_v,
321 conic_intercept_h, 396 conic_intercept_h,
322 conic_intercept_v, 397 conic_intercept_v,
323 cubic_intercept_h, 398 cubic_intercept_h,
324 cubic_intercept_v, 399 cubic_intercept_v,
325 }; 400 };
326 401
327 #endif 402 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698