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

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

Issue 2368993002: allow conic chop to fail (Closed)
Patch Set: address comment Created 4 years, 2 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/gpu/batches/GrAAHairLinePathRenderer.cpp ('k') | tests/PathOpsConicIntersectionTest.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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!conic.chopAt(maxCurvature, pair)) {
235 // if result can't be computed, use original
236 fCurrentContour->addConic(pointsPtr, weight);
237 break;
238 }
235 SkPoint cStorage[2][3]; 239 SkPoint cStorage[2][3];
236 SkPath::Verb v1 = SkReduceOrder::Conic(pair[0], cStorage [0]); 240 SkPath::Verb v1 = SkReduceOrder::Conic(pair[0], cStorage [0]);
237 SkPath::Verb v2 = SkReduceOrder::Conic(pair[1], cStorage [1]); 241 SkPath::Verb v2 = SkReduceOrder::Conic(pair[1], cStorage [1]);
238 SkPoint* curve1 = v1 != SkPath::kLine_Verb ? pair[0].fPt s : cStorage[0]; 242 SkPoint* curve1 = v1 != SkPath::kLine_Verb ? pair[0].fPt s : cStorage[0];
239 SkPoint* curve2 = v2 != SkPath::kLine_Verb ? pair[1].fPt s : cStorage[1]; 243 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)) { 244 if (can_add_curve(v1, curve1) && can_add_curve(v2, curve 2)) {
241 fCurrentContour->addCurve(v1, curve1, pair[0].fW); 245 fCurrentContour->addCurve(v1, curve1, pair[0].fW);
242 fCurrentContour->addCurve(v2, curve2, pair[1].fW); 246 fCurrentContour->addCurve(v2, curve2, pair[1].fW);
243 break; 247 break;
244 } 248 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 288 }
285 SkASSERT(fCurrentContour); 289 SkASSERT(fCurrentContour);
286 fCurrentContour->debugValidate(); 290 fCurrentContour->debugValidate();
287 pointsPtr += SkPathOpsVerbToPoints(verb); 291 pointsPtr += SkPathOpsVerbToPoints(verb);
288 } 292 }
289 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo se()) { 293 if (fCurrentContour && fCurrentContour->count() &&!fAllowOpenContours && !clo se()) {
290 return false; 294 return false;
291 } 295 }
292 return true; 296 return true;
293 } 297 }
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAAHairLinePathRenderer.cpp ('k') | tests/PathOpsConicIntersectionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698