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

Side by Side Diff: src/pathops/SkOpEdgeBuilder.cpp

Issue 2366893003: fix msan bug in pathops (Closed)
Patch Set: Created 4 years, 3 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 | src/pathops/SkPathOpsCurve.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 #include "SkGeometry.h" 7 #include "SkGeometry.h"
8 #include "SkOpEdgeBuilder.h" 8 #include "SkOpEdgeBuilder.h"
9 #include "SkReduceOrder.h" 9 #include "SkReduceOrder.h"
10 10
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 if (SkScalarAbs(pt->fY) < FLT_EPSILON_ORDERABLE_ERR) { 25 if (SkScalarAbs(pt->fY) < FLT_EPSILON_ORDERABLE_ERR) {
26 pt->fY = 0; 26 pt->fY = 0;
27 } 27 }
28 } 28 }
29 29
30 static bool can_add_curve(SkPath::Verb verb, SkPoint* curve) { 30 static bool can_add_curve(SkPath::Verb verb, SkPoint* curve) {
31 if (SkPath::kMove_Verb == verb) { 31 if (SkPath::kMove_Verb == verb) {
32 return false; 32 return false;
33 } 33 }
34 for (int index = 0; index < SkPathOpsVerbToPoints(verb); ++index) { 34 for (int index = 0; index <= SkPathOpsVerbToPoints(verb); ++index) {
35 force_small_to_zero(&curve[index]); 35 force_small_to_zero(&curve[index]);
36 } 36 }
37 return SkPath::kLine_Verb != verb || !SkDPoint::ApproximatelyEqual(curve[0], curve[1]); 37 return SkPath::kLine_Verb != verb || !SkDPoint::ApproximatelyEqual(curve[0], curve[1]);
38 } 38 }
39 39
40 void SkOpEdgeBuilder::addOperand(const SkPath& path) { 40 void SkOpEdgeBuilder::addOperand(const SkPath& path) {
41 SkASSERT(fPathVerbs.count() > 0 && fPathVerbs.end()[-1] == SkPath::kDone_Ver b); 41 SkASSERT(fPathVerbs.count() > 0 && fPathVerbs.end()[-1] == SkPath::kDone_Ver b);
42 fPathVerbs.pop(); 42 fPathVerbs.pop();
43 fPath = &path; 43 fPath = &path;
44 fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask 44 fXorMask[1] = (fPath->getFillType() & 1) ? kEvenOdd_PathOpsMask
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 SkPoint pair[5]; 202 SkPoint pair[5];
203 if (SkChopQuadAtMaxCurvature(pointsPtr, pair) == 1) { 203 if (SkChopQuadAtMaxCurvature(pointsPtr, pair) == 1) {
204 goto addOneQuad; 204 goto addOneQuad;
205 } 205 }
206 if (!SkScalarsAreFinite(&pair[0].fX, SK_ARRAY_COUNT(pair ) * 2)) { 206 if (!SkScalarsAreFinite(&pair[0].fX, SK_ARRAY_COUNT(pair ) * 2)) {
207 return false; 207 return false;
208 } 208 }
209 SkPoint cStorage[2][2]; 209 SkPoint cStorage[2][2];
210 SkPath::Verb v1 = SkReduceOrder::Quad(&pair[0], cStorage [0]); 210 SkPath::Verb v1 = SkReduceOrder::Quad(&pair[0], cStorage [0]);
211 SkPath::Verb v2 = SkReduceOrder::Quad(&pair[2], cStorage [1]); 211 SkPath::Verb v2 = SkReduceOrder::Quad(&pair[2], cStorage [1]);
212 SkPoint* curve1 = v1 == SkPath::kQuad_Verb ? &pair[0] : cStorage[0]; 212 SkPoint* curve1 = v1 != SkPath::kLine_Verb ? &pair[0] : cStorage[0];
213 SkPoint* curve2 = v2 == SkPath::kQuad_Verb ? &pair[2] : cStorage[1]; 213 SkPoint* curve2 = v2 != SkPath::kLine_Verb ? &pair[2] : cStorage[1];
214 if (can_add_curve(v1, curve1) && can_add_curve(v2, curve 2)) { 214 if (can_add_curve(v1, curve1) && can_add_curve(v2, curve 2)) {
215 fCurrentContour->addCurve(v1, curve1); 215 fCurrentContour->addCurve(v1, curve1);
216 fCurrentContour->addCurve(v2, curve2); 216 fCurrentContour->addCurve(v2, curve2);
217 break; 217 break;
218 } 218 }
219 } 219 }
220 } 220 }
221 addOneQuad: 221 addOneQuad:
222 fCurrentContour->addQuad(pointsPtr); 222 fCurrentContour->addQuad(pointsPtr);
223 break; 223 break;
224 case SkPath::kConic_Verb: { 224 case SkPath::kConic_Verb: {
225 SkVector v1 = pointsPtr[1] - pointsPtr[0]; 225 SkVector v1 = pointsPtr[1] - pointsPtr[0];
226 SkVector v2 = pointsPtr[2] - pointsPtr[1]; 226 SkVector v2 = pointsPtr[2] - pointsPtr[1];
227 SkScalar weight = *weightPtr++; 227 SkScalar weight = *weightPtr++;
228 if (v1.dot(v2) < 0) { 228 if (v1.dot(v2) < 0) {
229 // FIXME: max curvature for conics hasn't been implemented; use placeholder 229 // FIXME: max curvature for conics hasn't been implemented; use placeholder
230 SkScalar maxCurvature = SkFindQuadMaxCurvature(pointsPtr); 230 SkScalar maxCurvature = SkFindQuadMaxCurvature(pointsPtr);
231 if (maxCurvature > 0) { 231 if (maxCurvature > 0) {
232 SkConic conic(pointsPtr, weight); 232 SkConic conic(pointsPtr, weight);
233 SkConic pair[2]; 233 SkConic pair[2];
234 conic.chopAt(maxCurvature, pair); 234 conic.chopAt(maxCurvature, pair);
235 SkPoint cStorage[2][3]; 235 SkPoint cStorage[2][3];
236 SkPath::Verb v1 = SkReduceOrder::Conic(pair[0], cStorage [0]); 236 SkPath::Verb v1 = SkReduceOrder::Conic(pair[0], cStorage [0]);
237 SkPath::Verb v2 = SkReduceOrder::Conic(pair[1], cStorage [1]); 237 SkPath::Verb v2 = SkReduceOrder::Conic(pair[1], cStorage [1]);
238 SkPoint* curve1 = v1 == SkPath::kConic_Verb ? pair[0].fP ts : cStorage[0]; 238 SkPoint* curve1 = v1 != SkPath::kLine_Verb ? pair[0].fPt s : cStorage[0];
239 SkPoint* curve2 = v2 == SkPath::kConic_Verb ? pair[1].fP ts : cStorage[1]; 239 SkPoint* curve2 = v2 != SkPath::kLine_Verb ? pair[1].fPt s : cStorage[1];
240 if (can_add_curve(v1, curve1) && can_add_curve(v2, curve 2)) { 240 if (can_add_curve(v1, curve1) && can_add_curve(v2, curve 2)) {
241 fCurrentContour->addCurve(v1, curve1, pair[0].fW); 241 fCurrentContour->addCurve(v1, curve1, pair[0].fW);
242 fCurrentContour->addCurve(v2, curve2, pair[1].fW); 242 fCurrentContour->addCurve(v2, curve2, pair[1].fW);
243 break; 243 break;
244 } 244 }
245 } 245 }
246 } 246 }
247 fCurrentContour->addConic(pointsPtr, weight); 247 fCurrentContour->addConic(pointsPtr, weight);
248 } break; 248 } break;
249 case SkPath::kCubic_Verb: 249 case SkPath::kCubic_Verb:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 284 }
285 SkASSERT(fCurrentContour); 285 SkASSERT(fCurrentContour);
286 fCurrentContour->debugValidate(); 286 fCurrentContour->debugValidate();
287 pointsPtr += SkPathOpsVerbToPoints(verb); 287 pointsPtr += SkPathOpsVerbToPoints(verb);
288 } 288 }
289 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo se()) { 289 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo se()) {
290 return false; 290 return false;
291 } 291 }
292 return true; 292 return true;
293 } 293 }
OLDNEW
« no previous file with comments | « no previous file | src/pathops/SkPathOpsCurve.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698