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

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

Issue 16951017: convert pathops to use SkSTArray where possible. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: pathops use SkTArray 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/pathops/SkOpEdgeBuilder.cpp ('k') | src/pathops/SkOpSegment.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 #ifndef SkOpSegment_DEFINE 7 #ifndef SkOpSegment_DEFINE
8 #define SkOpSegment_DEFINE 8 #define SkOpSegment_DEFINE
9 9
10 #include "SkOpAngle.h" 10 #include "SkOpAngle.h"
11 #include "SkOpSpan.h" 11 #include "SkOpSpan.h"
12 #include "SkPathOpsBounds.h" 12 #include "SkPathOpsBounds.h"
13 #include "SkPathOpsCurve.h" 13 #include "SkPathOpsCurve.h"
14 #include "SkTArray.h"
14 #include "SkTDArray.h" 15 #include "SkTDArray.h"
15 16
16 class SkPathWriter; 17 class SkPathWriter;
17 18
18 class SkOpSegment { 19 class SkOpSegment {
19 public: 20 public:
20 SkOpSegment() { 21 SkOpSegment() {
21 #if DEBUG_DUMP 22 #if DEBUG_DUMP
22 fID = ++gSegmentID; 23 fID = ++gSegmentID;
23 #endif 24 #endif
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 224 }
224 225
225 SkScalar yAtT(int index) const { 226 SkScalar yAtT(int index) const {
226 return yAtT(&fTs[index]); 227 return yAtT(&fTs[index]);
227 } 228 }
228 229
229 SkScalar yAtT(const SkOpSpan* span) const { 230 SkScalar yAtT(const SkOpSpan* span) const {
230 return xyAtT(span).fY; 231 return xyAtT(span).fY;
231 } 232 }
232 233
233 bool activeAngle(int index, int* done, SkTDArray<SkOpAngle>* angles); 234 bool activeAngle(int index, int* done, SkTArray<SkOpAngle, true>* angles);
234 SkPoint activeLeftTop(bool onlySortable, int* firstT) const; 235 SkPoint activeLeftTop(bool onlySortable, int* firstT) const;
235 bool activeOp(int index, int endIndex, int xorMiMask, int xorSuMask, SkPathO p op); 236 bool activeOp(int index, int endIndex, int xorMiMask, int xorSuMask, SkPathO p op);
236 bool activeOp(int xorMiMask, int xorSuMask, int index, int endIndex, SkPathO p op, 237 bool activeOp(int xorMiMask, int xorSuMask, int index, int endIndex, SkPathO p op,
237 int* sumMiWinding, int* sumSuWinding, int* maxWinding, int* su mWinding, 238 int* sumMiWinding, int* sumSuWinding, int* maxWinding, int* su mWinding,
238 int* oppMaxWinding, int* oppSumWinding); 239 int* oppMaxWinding, int* oppSumWinding);
239 bool activeWinding(int index, int endIndex); 240 bool activeWinding(int index, int endIndex);
240 bool activeWinding(int index, int endIndex, int* maxWinding, int* sumWinding ); 241 bool activeWinding(int index, int endIndex, int* maxWinding, int* sumWinding );
241 void addCubic(const SkPoint pts[4], bool operand, bool evenOdd); 242 void addCubic(const SkPoint pts[4], bool operand, bool evenOdd);
242 void addCurveTo(int start, int end, SkPathWriter* path, bool active) const; 243 void addCurveTo(int start, int end, SkPathWriter* path, bool active) const;
243 void addLine(const SkPoint pts[2], bool operand, bool evenOdd); 244 void addLine(const SkPoint pts[2], bool operand, bool evenOdd);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 void markWinding(int index, int winding, int oppWinding); 288 void markWinding(int index, int winding, int oppWinding);
288 bool nextCandidate(int* start, int* end) const; 289 bool nextCandidate(int* start, int* end) const;
289 int nextExactSpan(int from, int step) const; 290 int nextExactSpan(int from, int step) const;
290 int nextSpan(int from, int step) const; 291 int nextSpan(int from, int step) const;
291 void setUpWindings(int index, int endIndex, int* sumMiWinding, int* sumSuWin ding, 292 void setUpWindings(int index, int endIndex, int* sumMiWinding, int* sumSuWin ding,
292 int* maxWinding, int* sumWinding, int* oppMaxWinding, int* oppSumWin ding); 293 int* maxWinding, int* sumWinding, int* oppMaxWinding, int* oppSumWin ding);
293 enum SortAngleKind { 294 enum SortAngleKind {
294 kMustBeOrdered_SortAngleKind, // required for winding calc 295 kMustBeOrdered_SortAngleKind, // required for winding calc
295 kMayBeUnordered_SortAngleKind // ok for find top 296 kMayBeUnordered_SortAngleKind // ok for find top
296 }; 297 };
297 static bool SortAngles(const SkTDArray<SkOpAngle>& angles, SkTDArray<SkOpAng le*>* angleList, 298 static bool SortAngles(const SkTArray<SkOpAngle, true>& angles,
299 SkTArray<SkOpAngle*, true>* angleList,
298 SortAngleKind ); 300 SortAngleKind );
299 bool subDivide(int start, int end, SkPoint edge[4]) const; 301 bool subDivide(int start, int end, SkPoint edge[4]) const;
300 bool subDivide(int start, int end, SkDCubic* result) const; 302 bool subDivide(int start, int end, SkDCubic* result) const;
301 void undoneSpan(int* start, int* end); 303 void undoneSpan(int* start, int* end);
302 int updateOppWindingReverse(const SkOpAngle* angle) const; 304 int updateOppWindingReverse(const SkOpAngle* angle) const;
303 int updateWindingReverse(const SkOpAngle* angle) const; 305 int updateWindingReverse(const SkOpAngle* angle) const;
304 static bool UseInnerWinding(int outerWinding, int innerWinding); 306 static bool UseInnerWinding(int outerWinding, int innerWinding);
305 int windingAtT(double tHit, int tIndex, bool crossOpp, SkScalar* dx) const; 307 int windingAtT(double tHit, int tIndex, bool crossOpp, SkScalar* dx) const;
306 int windSum(const SkOpAngle* angle) const; 308 int windSum(const SkOpAngle* angle) const;
307 int windValue(const SkOpAngle* angle) const; 309 int windValue(const SkOpAngle* angle) const;
308 310
309 #if DEBUG_DUMP 311 #if DEBUG_DUMP
310 int debugID() const { 312 int debugID() const {
311 return fID; 313 return fID;
312 } 314 }
313 #endif 315 #endif
314 #if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY 316 #if DEBUG_ACTIVE_SPANS || DEBUG_ACTIVE_SPANS_FIRST_ONLY
315 void debugShowActiveSpans() const; 317 void debugShowActiveSpans() const;
316 #endif 318 #endif
317 #if DEBUG_SORT || DEBUG_SWAP_TOP 319 #if DEBUG_SORT || DEBUG_SWAP_TOP
318 void debugShowSort(const char* fun, const SkTDArray<SkOpAngle*>& angles, int first, 320 void debugShowSort(const char* fun, const SkTArray<SkOpAngle*, true>& angles , int first,
319 const int contourWinding, const int oppContourWinding) const; 321 const int contourWinding, const int oppContourWinding) const;
320 void debugShowSort(const char* fun, const SkTDArray<SkOpAngle*>& angles, int first); 322 void debugShowSort(const char* fun, const SkTArray<SkOpAngle*, true>& angles , int first);
321 #endif 323 #endif
322 #if DEBUG_CONCIDENT 324 #if DEBUG_CONCIDENT
323 void debugShowTs() const; 325 void debugShowTs() const;
324 #endif 326 #endif
325 #if DEBUG_SHOW_WINDING 327 #if DEBUG_SHOW_WINDING
326 int debugShowWindingValues(int slotCount, int ofInterest) const; 328 int debugShowWindingValues(int slotCount, int ofInterest) const;
327 #endif 329 #endif
328 330
329 private: 331 private:
330 bool activeAngleOther(int index, int* done, SkTDArray<SkOpAngle>* angles); 332 bool activeAngleOther(int index, int* done, SkTArray<SkOpAngle, true>* angle s);
331 bool activeAngleInner(int index, int* done, SkTDArray<SkOpAngle>* angles); 333 bool activeAngleInner(int index, int* done, SkTArray<SkOpAngle, true>* angle s);
332 void addAngle(SkTDArray<SkOpAngle>* angles, int start, int end) const; 334 void addAngle(SkTArray<SkOpAngle, true>* angles, int start, int end) const;
333 void addCancelOutsides(double tStart, double oStart, SkOpSegment* other, dou ble oEnd); 335 void addCancelOutsides(double tStart, double oStart, SkOpSegment* other, dou ble oEnd);
334 void addCoinOutsides(const SkTDArray<double>& outsideTs, SkOpSegment* other, double oEnd); 336 void addCoinOutsides(const SkTArray<double, true>& outsideTs, SkOpSegment* o ther, double oEnd);
335 void addTwoAngles(int start, int end, SkTDArray<SkOpAngle>* angles) const; 337 void addTwoAngles(int start, int end, SkTArray<SkOpAngle, true>* angles) con st;
336 int advanceCoincidentOther(const SkOpSpan* test, double oEndT, int oIndex); 338 int advanceCoincidentOther(const SkOpSpan* test, double oEndT, int oIndex);
337 int advanceCoincidentThis(const SkOpSpan* oTest, bool opp, int index); 339 int advanceCoincidentThis(const SkOpSpan* oTest, bool opp, int index);
338 void buildAngles(int index, SkTDArray<SkOpAngle>* angles, bool includeOpp) c onst; 340 void buildAngles(int index, SkTArray<SkOpAngle, true>* angles, bool includeO pp) const;
339 void buildAnglesInner(int index, SkTDArray<SkOpAngle>* angles) const; 341 void buildAnglesInner(int index, SkTArray<SkOpAngle, true>* angles) const;
340 int bumpCoincidentThis(const SkOpSpan& oTest, bool opp, int index, 342 int bumpCoincidentThis(const SkOpSpan& oTest, bool opp, int index,
341 SkTDArray<double>* outsideTs); 343 SkTArray<double, true>* outsideTs);
342 int bumpCoincidentOther(const SkOpSpan& test, double oEndT, int& oIndex, 344 int bumpCoincidentOther(const SkOpSpan& test, double oEndT, int& oIndex,
343 SkTDArray<double>* oOutsideTs); 345 SkTArray<double, true>* oOutsideTs);
344 bool bumpSpan(SkOpSpan* span, int windDelta, int oppDelta); 346 bool bumpSpan(SkOpSpan* span, int windDelta, int oppDelta);
345 bool clockwise(int tStart, int tEnd) const; 347 bool clockwise(int tStart, int tEnd) const;
346 void decrementSpan(SkOpSpan* span); 348 void decrementSpan(SkOpSpan* span);
347 bool equalPoints(int greaterTIndex, int lesserTIndex); 349 bool equalPoints(int greaterTIndex, int lesserTIndex);
348 int findStartingEdge(const SkTDArray<SkOpAngle*>& sorted, int start, int end ); 350 int findStartingEdge(const SkTArray<SkOpAngle*, true>& sorted, int start, in t end);
349 void init(const SkPoint pts[], SkPath::Verb verb, bool operand, bool evenOdd ); 351 void init(const SkPoint pts[], SkPath::Verb verb, bool operand, bool evenOdd );
350 void matchWindingValue(int tIndex, double t, bool borrowWind); 352 void matchWindingValue(int tIndex, double t, bool borrowWind);
351 SkOpSpan* markAndChaseDone(int index, int endIndex, int winding); 353 SkOpSpan* markAndChaseDone(int index, int endIndex, int winding);
352 SkOpSpan* markAndChaseDoneBinary(const SkOpAngle* angle, int winding, int op pWinding); 354 SkOpSpan* markAndChaseDoneBinary(const SkOpAngle* angle, int winding, int op pWinding);
353 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, const int winding); 355 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, const int winding);
354 SkOpSpan* markAndChaseWinding(int index, int endIndex, int winding, int oppW inding); 356 SkOpSpan* markAndChaseWinding(int index, int endIndex, int winding, int oppW inding);
355 SkOpSpan* markAngle(int maxWinding, int sumWinding, bool activeAngle, const SkOpAngle* angle); 357 SkOpSpan* markAngle(int maxWinding, int sumWinding, bool activeAngle, const SkOpAngle* angle);
356 void markDoneBinary(int index, int winding, int oppWinding); 358 void markDoneBinary(int index, int winding, int oppWinding);
357 SkOpSpan* markAndChaseDoneUnary(const SkOpAngle* angle, int winding); 359 SkOpSpan* markAndChaseDoneUnary(const SkOpAngle* angle, int winding);
358 void markOneDone(const char* funName, int tIndex, int winding); 360 void markOneDone(const char* funName, int tIndex, int winding);
359 void markOneDoneBinary(const char* funName, int tIndex); 361 void markOneDoneBinary(const char* funName, int tIndex);
360 void markOneDoneBinary(const char* funName, int tIndex, int winding, int opp Winding); 362 void markOneDoneBinary(const char* funName, int tIndex, int winding, int opp Winding);
361 void markOneDoneUnary(const char* funName, int tIndex); 363 void markOneDoneUnary(const char* funName, int tIndex);
362 void markUnsortable(int start, int end); 364 void markUnsortable(int start, int end);
363 bool monotonicInY(int tStart, int tEnd) const; 365 bool monotonicInY(int tStart, int tEnd) const;
364 bool multipleSpans(int end) const; 366 bool multipleSpans(int end) const;
365 SkOpSegment* nextChase(int* index, const int step, int* min, SkOpSpan** last ); 367 SkOpSegment* nextChase(int* index, const int step, int* min, SkOpSpan** last );
366 bool serpentine(int tStart, int tEnd) const; 368 bool serpentine(int tStart, int tEnd) const;
367 void subDivideBounds(int start, int end, SkPathOpsBounds* bounds) const; 369 void subDivideBounds(int start, int end, SkPathOpsBounds* bounds) const;
368 static void TrackOutside(SkTDArray<double>* outsideTs, double end, double st art); 370 static void TrackOutside(SkTArray<double, true>* outsideTs, double end, doub le start);
369 int updateOppWinding(int index, int endIndex) const; 371 int updateOppWinding(int index, int endIndex) const;
370 int updateOppWinding(const SkOpAngle* angle) const; 372 int updateOppWinding(const SkOpAngle* angle) const;
371 int updateWinding(int index, int endIndex) const; 373 int updateWinding(int index, int endIndex) const;
372 int updateWinding(const SkOpAngle* angle) const; 374 int updateWinding(const SkOpAngle* angle) const;
373 SkOpSpan* verifyOneWinding(const char* funName, int tIndex); 375 SkOpSpan* verifyOneWinding(const char* funName, int tIndex);
374 SkOpSpan* verifyOneWindingU(const char* funName, int tIndex); 376 SkOpSpan* verifyOneWindingU(const char* funName, int tIndex);
375 int windValueAt(double t) const; 377 int windValueAt(double t) const;
376 void zeroSpan(SkOpSpan* span); 378 void zeroSpan(SkOpSpan* span);
377 379
378 #if DEBUG_SWAP_TOP 380 #if DEBUG_SWAP_TOP
379 bool controlsContainedByEnds(int tStart, int tEnd) const; 381 bool controlsContainedByEnds(int tStart, int tEnd) const;
380 #endif 382 #endif
381 #if DEBUG_CONCIDENT 383 #if DEBUG_CONCIDENT
382 void debugAddTPair(double t, const SkOpSegment& other, double otherT) const ; 384 void debugAddTPair(double t, const SkOpSegment& other, double otherT) const ;
383 #endif 385 #endif
384 #if DEBUG_MARK_DONE || DEBUG_UNSORTABLE 386 #if DEBUG_MARK_DONE || DEBUG_UNSORTABLE
385 void debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding) ; 387 void debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding) ;
386 void debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding, int oppWinding); 388 void debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding, int oppWinding);
387 #endif 389 #endif
388 #if DEBUG_WINDING 390 #if DEBUG_WINDING
389 static char as_digit(int value) { 391 static char as_digit(int value) {
390 return value < 0 ? '?' : value <= 9 ? '0' + value : '+'; 392 return value < 0 ? '?' : value <= 9 ? '0' + value : '+';
391 } 393 }
392 #endif 394 #endif
393 395
394 const SkPoint* fPts; 396 const SkPoint* fPts;
395 SkPathOpsBounds fBounds; 397 SkPathOpsBounds fBounds;
398 // FIXME: can't convert to SkTArray because it uses insert
396 SkTDArray<SkOpSpan> fTs; // two or more (always includes t=0 t=1) 399 SkTDArray<SkOpSpan> fTs; // two or more (always includes t=0 t=1)
397 // OPTIMIZATION: could pack donespans, verb, operand, xor into 1 int-sized v alue 400 // OPTIMIZATION: could pack donespans, verb, operand, xor into 1 int-sized v alue
398 int fDoneSpans; // quick check that segment is finished 401 int fDoneSpans; // quick check that segment is finished
399 // OPTIMIZATION: force the following to be byte-sized 402 // OPTIMIZATION: force the following to be byte-sized
400 SkPath::Verb fVerb; 403 SkPath::Verb fVerb;
401 bool fOperand; 404 bool fOperand;
402 bool fXor; // set if original contour had even-odd fill 405 bool fXor; // set if original contour had even-odd fill
403 bool fOppXor; // set if opposite operand had even-odd fill 406 bool fOppXor; // set if opposite operand had even-odd fill
404 #if DEBUG_DUMP 407 #if DEBUG_DUMP
405 int fID; 408 int fID;
406 #endif 409 #endif
407 }; 410 };
408 411
409 #endif 412 #endif
OLDNEW
« no previous file with comments | « src/pathops/SkOpEdgeBuilder.cpp ('k') | src/pathops/SkOpSegment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698