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

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

Issue 16195004: add asserts to point<-->verb helpers (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLPath.cpp ('k') | src/pathops/SkOpContour.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 #include "SkIntersections.h" 7 #include "SkIntersections.h"
8 #include "SkOpAngle.h" 8 #include "SkOpAngle.h"
9 #include "SkPathOpsCurve.h" 9 #include "SkPathOpsCurve.h"
10 #include "SkTSort.h" 10 #include "SkTSort.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 int roots, rroots; 106 int roots, rroots;
107 bool flip = false; 107 bool flip = false;
108 bool useThis; 108 bool useThis;
109 bool leftLessThanRight = fSide > 0; 109 bool leftLessThanRight = fSide > 0;
110 do { 110 do {
111 useThis = (len < rlen) ^ flip; 111 useThis = (len < rlen) ^ flip;
112 const SkDCubic& part = useThis ? fCurvePart : rh.fCurvePart; 112 const SkDCubic& part = useThis ? fCurvePart : rh.fCurvePart;
113 SkPath::Verb partVerb = useThis ? fVerb : rh.fVerb; 113 SkPath::Verb partVerb = useThis ? fVerb : rh.fVerb;
114 ray[0] = partVerb == SkPath::kCubic_Verb && part[0].approximatelyEqual(p art[1]) ? 114 ray[0] = partVerb == SkPath::kCubic_Verb && part[0].approximatelyEqual(p art[1]) ?
115 part[2] : part[1]; 115 part[2] : part[1];
116 ray[1].fX = (part[0].fX + part[partVerb].fX) / 2; 116 ray[1].fX = (part[0].fX + part[SkPathOpsVerbToPoints(partVerb)].fX) / 2;
117 ray[1].fY = (part[0].fY + part[partVerb].fY) / 2; 117 ray[1].fY = (part[0].fY + part[SkPathOpsVerbToPoints(partVerb)].fY) / 2;
118 SkASSERT(ray[0] != ray[1]); 118 SkASSERT(ray[0] != ray[1]);
119 roots = (i.*CurveRay[fVerb])(fPts, ray); 119 roots = (i.*CurveRay[SkPathOpsVerbToPoints(fVerb)])(fPts, ray);
120 rroots = (ri.*CurveRay[rh.fVerb])(rh.fPts, ray); 120 rroots = (ri.*CurveRay[SkPathOpsVerbToPoints(rh.fVerb)])(rh.fPts, ray);
121 } while ((roots == 0 || rroots == 0) && (flip ^= true)); 121 } while ((roots == 0 || rroots == 0) && (flip ^= true));
122 if (roots == 0 || rroots == 0) { 122 if (roots == 0 || rroots == 0) {
123 // FIXME: we don't have a solution in this case. The interim solution 123 // FIXME: we don't have a solution in this case. The interim solution
124 // is to mark the edges as unsortable, exclude them from this and 124 // is to mark the edges as unsortable, exclude them from this and
125 // future computations, and allow the returned path to be fragmented 125 // future computations, and allow the returned path to be fragmented
126 fUnsortable = true; 126 fUnsortable = true;
127 rh.fUnsortable = true; 127 rh.fUnsortable = true;
128 return this < &rh; // even with no solution, return a stable sort 128 return this < &rh; // even with no solution, return a stable sort
129 } 129 }
130 SkASSERT(fSide != 0 && rh.fSide != 0); 130 SkASSERT(fSide != 0 && rh.fSide != 0);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 for (int index = fStart; index != fEnd; index += step) { 307 for (int index = fStart; index != fEnd; index += step) {
308 #if 1 308 #if 1
309 const SkOpSpan& thisSpan = (*fSpans)[index]; 309 const SkOpSpan& thisSpan = (*fSpans)[index];
310 const SkOpSpan& nextSpan = (*fSpans)[index + step]; 310 const SkOpSpan& nextSpan = (*fSpans)[index + step];
311 if (thisSpan.fTiny || precisely_equal(thisSpan.fT, nextSpan.fT)) { 311 if (thisSpan.fTiny || precisely_equal(thisSpan.fT, nextSpan.fT)) {
312 continue; 312 continue;
313 } 313 }
314 fUnsortable = step > 0 ? thisSpan.fUnsortableStart : nextSpan.fUnsortabl eEnd; 314 fUnsortable = step > 0 ? thisSpan.fUnsortableStart : nextSpan.fUnsortabl eEnd;
315 #if DEBUG_UNSORTABLE 315 #if DEBUG_UNSORTABLE
316 if (fUnsortable) { 316 if (fUnsortable) {
317 SkPoint iPt = (*CurvePointAtT[fVerb])(fPts, thisSpan.fT); 317 SkPoint iPt = (*CurvePointAtT[SkPathOpsVerbToPoints(fVerb)])(fPts, t hisSpan.fT);
318 SkPoint ePt = (*CurvePointAtT[fVerb])(fPts, nextSpan.fT); 318 SkPoint ePt = (*CurvePointAtT[SkPathOpsVerbToPoints(fVerb)])(fPts, n extSpan.fT);
319 SkDebugf("%s unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", __ FUNCTION__, 319 SkDebugf("%s unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", __ FUNCTION__,
320 index, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY); 320 index, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY);
321 } 321 }
322 #endif 322 #endif
323 return; 323 return;
324 #else 324 #else
325 if ((*fSpans)[index].fUnsortableStart) { 325 if ((*fSpans)[index].fUnsortableStart) {
326 fUnsortable = true; 326 fUnsortable = true;
327 return; 327 return;
328 } 328 }
329 #endif 329 #endif
330 } 330 }
331 #if 1 331 #if 1
332 #if DEBUG_UNSORTABLE 332 #if DEBUG_UNSORTABLE
333 SkPoint iPt = (*CurvePointAtT[fVerb])(fPts, startT); 333 SkPoint iPt = (*CurvePointAtT[SkPathOpsVerbToPoints(fVerb)])(fPts, startT);
334 SkPoint ePt = (*CurvePointAtT[fVerb])(fPts, endT); 334 SkPoint ePt = (*CurvePointAtT[SkPathOpsVerbToPoints(fVerb)])(fPts, endT);
335 SkDebugf("%s all tiny unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", _ _FUNCTION__, 335 SkDebugf("%s all tiny unsortable [%d] (%1.9g,%1.9g) [%d] (%1.9g,%1.9g)\n", _ _FUNCTION__,
336 fStart, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY); 336 fStart, iPt.fX, iPt.fY, fEnd, ePt.fX, ePt.fY);
337 #endif 337 #endif
338 fUnsortable = true; 338 fUnsortable = true;
339 #endif 339 #endif
340 } 340 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLPath.cpp ('k') | src/pathops/SkOpContour.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698