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

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

Issue 1405383004: fix path op conic bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix w cast Created 5 years, 1 month 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/SkOpSegment.h ('k') | src/pathops/SkOpSpan.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 "SkOpCoincidence.h" 7 #include "SkOpCoincidence.h"
8 #include "SkOpContour.h" 8 #include "SkOpContour.h"
9 #include "SkOpSegment.h" 9 #include "SkOpSegment.h"
10 #include "SkPathWriter.h" 10 #include "SkPathWriter.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 SkOpPtT* ptT = segment->addT(i[0][0], SkOpSegment::kAllowAlias, allocator); 233 SkOpPtT* ptT = segment->addT(i[0][0], SkOpSegment::kAllowAlias, allocator);
234 ptT->fPt = newPt; 234 ptT->fPt = newPt;
235 endPtT.addOpp(ptT); 235 endPtT.addOpp(ptT);
236 } 236 }
237 nextSegment: 237 nextSegment:
238 ; 238 ;
239 } while ((segment = segment->next())); 239 } while ((segment = segment->next()));
240 } while ((current = current->next())); 240 } while ((current = current->next()));
241 } 241 }
242 242
243 void SkOpSegment::addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end, 243 bool SkOpSegment::addCurveTo(const SkOpSpanBase* start, const SkOpSpanBase* end,
244 SkPathWriter* path, bool active) const { 244 SkPathWriter* path) const {
245 if (start->starter(end)->alreadyAdded()) {
246 return false;
247 }
245 SkOpCurve edge; 248 SkOpCurve edge;
246 const SkPoint* ePtr; 249 const SkPoint* ePtr;
247 SkScalar eWeight; 250 SkScalar eWeight;
248 if ((start == &fHead && end == &fTail) || (start == &fTail && end == &fHead) ) { 251 if ((start == &fHead && end == &fTail) || (start == &fTail && end == &fHead) ) {
249 ePtr = fPts; 252 ePtr = fPts;
250 eWeight = fWeight; 253 eWeight = fWeight;
251 } else { 254 } else {
252 // OPTIMIZE? if not active, skip remainder and return xyAtT(end) 255 // OPTIMIZE? if not active, skip remainder and return xyAtT(end)
253 subDivide(start, end, &edge); 256 subDivide(start, end, &edge);
254 ePtr = edge.fPts; 257 ePtr = edge.fPts;
255 eWeight = edge.fWeight; 258 eWeight = edge.fWeight;
256 } 259 }
257 if (active) { 260 bool reverse = ePtr == fPts && start != &fHead;
258 bool reverse = ePtr == fPts && start != &fHead; 261 if (reverse) {
259 if (reverse) { 262 path->deferredMoveLine(ePtr[SkPathOpsVerbToPoints(fVerb)]);
260 path->deferredMoveLine(ePtr[SkPathOpsVerbToPoints(fVerb)]); 263 switch (fVerb) {
261 switch (fVerb) { 264 case SkPath::kLine_Verb:
262 case SkPath::kLine_Verb: 265 path->deferredLine(ePtr[0]);
263 path->deferredLine(ePtr[0]); 266 break;
264 break; 267 case SkPath::kQuad_Verb:
265 case SkPath::kQuad_Verb: 268 path->quadTo(ePtr[1], ePtr[0]);
266 path->quadTo(ePtr[1], ePtr[0]); 269 break;
267 break; 270 case SkPath::kConic_Verb:
268 case SkPath::kConic_Verb: 271 path->conicTo(ePtr[1], ePtr[0], eWeight);
269 path->conicTo(ePtr[1], ePtr[0], eWeight); 272 break;
270 break; 273 case SkPath::kCubic_Verb:
271 case SkPath::kCubic_Verb: 274 path->cubicTo(ePtr[2], ePtr[1], ePtr[0]);
272 path->cubicTo(ePtr[2], ePtr[1], ePtr[0]); 275 break;
273 break; 276 default:
274 default: 277 SkASSERT(0);
275 SkASSERT(0); 278 }
276 } 279 } else {
277 } else { 280 path->deferredMoveLine(ePtr[0]);
278 path->deferredMoveLine(ePtr[0]); 281 switch (fVerb) {
279 switch (fVerb) { 282 case SkPath::kLine_Verb:
280 case SkPath::kLine_Verb: 283 path->deferredLine(ePtr[1]);
281 path->deferredLine(ePtr[1]); 284 break;
282 break; 285 case SkPath::kQuad_Verb:
283 case SkPath::kQuad_Verb: 286 path->quadTo(ePtr[1], ePtr[2]);
284 path->quadTo(ePtr[1], ePtr[2]); 287 break;
285 break; 288 case SkPath::kConic_Verb:
286 case SkPath::kConic_Verb: 289 path->conicTo(ePtr[1], ePtr[2], eWeight);
287 path->conicTo(ePtr[1], ePtr[2], eWeight); 290 break;
288 break; 291 case SkPath::kCubic_Verb:
289 case SkPath::kCubic_Verb: 292 path->cubicTo(ePtr[1], ePtr[2], ePtr[3]);
290 path->cubicTo(ePtr[1], ePtr[2], ePtr[3]); 293 break;
291 break; 294 default:
292 default: 295 SkASSERT(0);
293 SkASSERT(0);
294 }
295 } 296 }
296 } 297 }
298 return true;
297 } 299 }
298 300
299 SkOpPtT* SkOpSegment::addMissing(double t, SkOpSegment* opp, SkChunkAlloc* alloc ator) { 301 SkOpPtT* SkOpSegment::addMissing(double t, SkOpSegment* opp, SkChunkAlloc* alloc ator) {
300 SkOpSpanBase* existing = nullptr; 302 SkOpSpanBase* existing = nullptr;
301 SkOpSpanBase* test = &fHead; 303 SkOpSpanBase* test = &fHead;
302 double testT; 304 double testT;
303 do { 305 do {
304 if ((testT = test->ptT()->fT) >= t) { 306 if ((testT = test->ptT()->fT) >= t) {
305 if (testT == t) { 307 if (testT == t) {
306 existing = test; 308 existing = test;
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 int absOut = SkTAbs(outerWinding); 1771 int absOut = SkTAbs(outerWinding);
1770 int absIn = SkTAbs(innerWinding); 1772 int absIn = SkTAbs(innerWinding);
1771 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; 1773 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn;
1772 return result; 1774 return result;
1773 } 1775 }
1774 1776
1775 int SkOpSegment::windSum(const SkOpAngle* angle) const { 1777 int SkOpSegment::windSum(const SkOpAngle* angle) const {
1776 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); 1778 const SkOpSpan* minSpan = angle->start()->starter(angle->end());
1777 return minSpan->windSum(); 1779 return minSpan->windSum();
1778 } 1780 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpSegment.h ('k') | src/pathops/SkOpSpan.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698