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

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

Issue 2273293004: path ops stream-lining (Closed)
Patch Set: remove commented out code 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 | « 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } while ((test = test->upCast()->next())); 244 } while ((test = test->upCast()->next()));
245 foundMatch: 245 foundMatch:
246 return opp && !test->contains(opp) ? nullptr : testPtT; 246 return opp && !test->contains(opp) ? nullptr : testPtT;
247 } 247 }
248 248
249 // break the span so that the coincident part does not change the angle of the r emainder 249 // break the span so that the coincident part does not change the angle of the r emainder
250 bool SkOpSegment::addExpanded(double newT, const SkOpSpanBase* test, bool* start Over) { 250 bool SkOpSegment::addExpanded(double newT, const SkOpSpanBase* test, bool* start Over) {
251 if (this->contains(newT)) { 251 if (this->contains(newT)) {
252 return true; 252 return true;
253 } 253 }
254 SkOpPtT* newPtT = this->addT(newT, startOver); 254 this->globalState()->resetAllocatedOpSpan();
255 SkOpPtT* newPtT = this->addT(newT);
256 *startOver |= this->globalState()->allocatedOpSpan();
255 if (!newPtT) { 257 if (!newPtT) {
256 return false; 258 return false;
257 } 259 }
258 newPtT->fPt = this->ptAtT(newT); 260 newPtT->fPt = this->ptAtT(newT);
259 // const cast away to change linked list; pt/t values stays unchanged 261 // const cast away to change linked list; pt/t values stays unchanged
260 SkOpSpanBase* writableTest = const_cast<SkOpSpanBase*>(test); 262 SkOpPtT* oppPrev = test->ptT()->oppPrev(newPtT);
261 if (writableTest->ptT()->addOpp(newPtT)) { 263 if (oppPrev) {
264 SkOpSpanBase* writableTest = const_cast<SkOpSpanBase*>(test);
265 writableTest->ptT()->addOpp(newPtT, oppPrev);
262 writableTest->checkForCollapsedCoincidence(); 266 writableTest->checkForCollapsedCoincidence();
263 } 267 }
264 return true; 268 return true;
265 } 269 }
266 270
267 // Please keep this in sync with debugAddT() 271 // Please keep this in sync with debugAddT()
268 SkOpPtT* SkOpSegment::addT(double t, bool* allocated) { 272 SkOpPtT* SkOpSegment::addT(double t) {
269 debugValidate(); 273 debugValidate();
270 SkPoint pt = this->ptAtT(t); 274 SkPoint pt = this->ptAtT(t);
271 SkOpSpanBase* span = &fHead; 275 SkOpSpanBase* spanBase = &fHead;
272 do { 276 do {
273 SkOpPtT* result = span->ptT(); 277 SkOpPtT* result = spanBase->ptT();
274 SkOpPtT* loop; 278 if (t == result->fT || this->match(result, this, t, pt)) {
275 bool duplicatePt; 279 spanBase->bumpSpanAdds();
276 if (t == result->fT) {
277 goto bumpSpan;
278 }
279 if (this->match(result, this, t, pt)) {
280 // see if any existing alias matches segment, pt, and t
281 loop = result->next();
282 duplicatePt = false;
283 while (loop != result) {
284 bool ptMatch = loop->fPt == pt;
285 if (loop->segment() == this && loop->fT == t && ptMatch) {
286 goto bumpSpan;
287 }
288 duplicatePt |= ptMatch;
289 loop = loop->next();
290 }
291 bumpSpan:
292 span->bumpSpanAdds();
293 return result; 280 return result;
294 } 281 }
295 if (t < result->fT) { 282 if (t < result->fT) {
296 SkOpSpan* prev = result->span()->prev(); 283 SkOpSpan* prev = result->span()->prev();
297 if (!prev) { 284 FAIL_WITH_NULL_IF(!prev);
298 return nullptr; 285 // marks in global state that new op span has been allocated
299 } 286 SkOpSpan* span = this->insert(prev);
300 SkOpSpan* span = insert(prev);
301 span->init(this, prev, t, pt); 287 span->init(this, prev, t, pt);
302 this->debugValidate(); 288 this->debugValidate();
303 #if DEBUG_ADD_T 289 #if DEBUG_ADD_T
304 SkDebugf("%s insert t=%1.9g segID=%d spanID=%d\n", __FUNCTION__, t, 290 SkDebugf("%s insert t=%1.9g segID=%d spanID=%d\n", __FUNCTION__, t,
305 span->segment()->debugID(), span->debugID()); 291 span->segment()->debugID(), span->debugID());
306 #endif 292 #endif
307 span->bumpSpanAdds(); 293 span->bumpSpanAdds();
308 if (allocated) {
309 *allocated = true;
310 }
311 return span->ptT(); 294 return span->ptT();
312 } 295 }
313 if (span == &fTail) { 296 FAIL_WITH_NULL_IF(spanBase == &fTail);
314 return nullptr; 297 } while ((spanBase = spanBase->upCast()->next()));
315 }
316 } while ((span = span->upCast()->next()));
317 SkASSERT(0); 298 SkASSERT(0);
318 return nullptr; 299 return nullptr; // we never get here, but need this to satisfy compiler
319 } 300 }
320 301
321 void SkOpSegment::calcAngles() { 302 void SkOpSegment::calcAngles() {
322 bool activePrior = !fHead.isCanceled(); 303 bool activePrior = !fHead.isCanceled();
323 if (activePrior && !fHead.simple()) { 304 if (activePrior && !fHead.simple()) {
324 addStartSpan(); 305 addStartSpan();
325 } 306 }
326 SkOpSpan* prior = &fHead; 307 SkOpSpan* prior = &fHead;
327 SkOpSpanBase* spanBase = fHead.next(); 308 SkOpSpanBase* spanBase = fHead.next();
328 while (spanBase != &fTail) { 309 while (spanBase != &fTail) {
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 int absOut = SkTAbs(outerWinding); 1766 int absOut = SkTAbs(outerWinding);
1786 int absIn = SkTAbs(innerWinding); 1767 int absIn = SkTAbs(innerWinding);
1787 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; 1768 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn;
1788 return result; 1769 return result;
1789 } 1770 }
1790 1771
1791 int SkOpSegment::windSum(const SkOpAngle* angle) const { 1772 int SkOpSegment::windSum(const SkOpAngle* angle) const {
1792 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); 1773 const SkOpSpan* minSpan = angle->start()->starter(angle->end());
1793 return minSpan->windSum(); 1774 return minSpan->windSum();
1794 } 1775 }
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