| OLD | NEW |
| 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" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 bool activeAngle(int index, int* done, SkTArray<SkOpAngle, true>* angles); | 239 bool activeAngle(int index, int* done, SkTArray<SkOpAngle, true>* angles); |
| 240 SkPoint activeLeftTop(bool onlySortable, int* firstT) const; | 240 SkPoint activeLeftTop(bool onlySortable, int* firstT) const; |
| 241 bool activeOp(int index, int endIndex, int xorMiMask, int xorSuMask, SkPathO
p op); | 241 bool activeOp(int index, int endIndex, int xorMiMask, int xorSuMask, SkPathO
p op); |
| 242 bool activeWinding(int index, int endIndex); | 242 bool activeWinding(int index, int endIndex); |
| 243 void addCubic(const SkPoint pts[4], bool operand, bool evenOdd); | 243 void addCubic(const SkPoint pts[4], bool operand, bool evenOdd); |
| 244 void addCurveTo(int start, int end, SkPathWriter* path, bool active) const; | 244 void addCurveTo(int start, int end, SkPathWriter* path, bool active) const; |
| 245 void addLine(const SkPoint pts[2], bool operand, bool evenOdd); | 245 void addLine(const SkPoint pts[2], bool operand, bool evenOdd); |
| 246 void addOtherT(int index, double otherT, int otherIndex); | 246 void addOtherT(int index, double otherT, int otherIndex); |
| 247 void addQuad(const SkPoint pts[3], bool operand, bool evenOdd); | 247 void addQuad(const SkPoint pts[3], bool operand, bool evenOdd); |
| 248 int addSelfT(SkOpSegment* other, const SkPoint& pt, double newT); | 248 int addSelfT(SkOpSegment* other, const SkPoint& pt, double newT); |
| 249 int addT(SkOpSegment* other, const SkPoint& pt, double newT, bool isNear); | 249 int addT(SkOpSegment* other, const SkPoint& pt, double newT); |
| 250 void addTCancel(const SkPoint& startPt, const SkPoint& endPt, SkOpSegment* o
ther); | 250 void addTCancel(const SkPoint& startPt, const SkPoint& endPt, SkOpSegment* o
ther); |
| 251 void addTCoincident(const SkPoint& startPt, const SkPoint& endPt, double end
T, | 251 void addTCoincident(const SkPoint& startPt, const SkPoint& endPt, double end
T, |
| 252 SkOpSegment* other); | 252 SkOpSegment* other); |
| 253 void addTPair(double t, SkOpSegment* other, double otherT, bool borrowWind,
const SkPoint& pt); | 253 void addTPair(double t, SkOpSegment* other, double otherT, bool borrowWind,
const SkPoint& pt); |
| 254 bool betweenTs(int lesser, double testT, int greater) const; | 254 bool betweenTs(int lesser, double testT, int greater) const; |
| 255 void checkEnds(); | 255 void checkEnds(); |
| 256 bool checkSmall(int index) const; | 256 bool checkSmall(int index) const; |
| 257 void checkTiny(); | 257 void checkTiny(); |
| 258 int computeSum(int startIndex, int endIndex, SkOpAngle::IncludeType includeT
ype, | 258 int computeSum(int startIndex, int endIndex, SkOpAngle::IncludeType includeT
ype, |
| 259 SkTArray<SkOpAngle, true>* angles, SkTArray<SkOpAngle*, true
>* sorted); | 259 SkTArray<SkOpAngle, true>* angles, SkTArray<SkOpAngle*, true
>* sorted); |
| 260 int crossedSpanY(const SkPoint& basePt, SkScalar* bestY, double* hitT, bool*
hitSomething, | 260 int crossedSpanY(const SkPoint& basePt, SkScalar* bestY, double* hitT, bool*
hitSomething, |
| 261 double mid, bool opp, bool current) const; | 261 double mid, bool opp, bool current) const; |
| 262 bool findCoincidentMatch(const SkOpSpan* span, const SkOpSegment* other, int
oStart, int oEnd, | 262 bool findCoincidentMatch(const SkOpSpan* span, const SkOpSegment* other, int
oStart, int oEnd, |
| 263 int step, SkPoint* startPt, SkPoint* endPt, double*
endT) const; | 263 int step, SkPoint* startPt, SkPoint* endPt, double*
endT) const; |
| 264 SkOpSegment* findNextOp(SkTDArray<SkOpSpan*>* chase, int* nextStart, int* ne
xtEnd, | 264 SkOpSegment* findNextOp(SkTDArray<SkOpSpan*>* chase, int* nextStart, int* ne
xtEnd, |
| 265 bool* unsortable, SkPathOp op, const int xorMiMask, | 265 bool* unsortable, SkPathOp op, const int xorMiMask, |
| 266 const int xorSuMask); | 266 const int xorSuMask); |
| 267 SkOpSegment* findNextWinding(SkTDArray<SkOpSpan*>* chase, int* nextStart, in
t* nextEnd, | 267 SkOpSegment* findNextWinding(SkTDArray<SkOpSpan*>* chase, int* nextStart, in
t* nextEnd, |
| 268 bool* unsortable); | 268 bool* unsortable); |
| 269 SkOpSegment* findNextXor(int* nextStart, int* nextEnd, bool* unsortable); | 269 SkOpSegment* findNextXor(int* nextStart, int* nextEnd, bool* unsortable); |
| 270 int findT(double t, const SkOpSegment* ) const; | 270 int findT(double t, const SkOpSegment* ) const; |
| 271 SkOpSegment* findTop(int* tIndex, int* endIndex, bool* unsortable, bool only
Sortable); | 271 SkOpSegment* findTop(int* tIndex, int* endIndex, bool* unsortable, bool only
Sortable); |
| 272 void fixOtherTIndex(); | 272 void fixOtherTIndex(); |
| 273 void initWinding(int start, int end); | 273 void initWinding(int start, int end); |
| 274 void initWinding(int start, int end, double tHit, int winding, SkScalar hitD
x, int oppWind, | 274 void initWinding(int start, int end, double tHit, int winding, SkScalar hitD
x, int oppWind, |
| 275 SkScalar hitOppDx); | 275 SkScalar hitOppDx); |
| 276 bool isMissing(double startT, const SkPoint& pt) const; | 276 bool isMissing(double startT, const SkPoint& pt) const; |
| 277 bool isTiny(const SkOpAngle* angle) const; | 277 bool isTiny(const SkOpAngle* angle) const; |
| 278 bool joinCoincidence(bool end, SkOpSegment* other, double otherT, int step,
bool cancel); | 278 bool joinCoincidence(SkOpSegment* other, double otherT, int step, bool cance
l); |
| 279 SkOpSpan* markAndChaseDoneBinary(int index, int endIndex); | 279 SkOpSpan* markAndChaseDoneBinary(int index, int endIndex); |
| 280 SkOpSpan* markAndChaseDoneUnary(int index, int endIndex); | 280 SkOpSpan* markAndChaseDoneUnary(int index, int endIndex); |
| 281 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, int winding, int oppWi
nding); | 281 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, int winding, int oppWi
nding); |
| 282 SkOpSpan* markAngle(int maxWinding, int sumWinding, int oppMaxWinding, int o
ppSumWinding, | 282 SkOpSpan* markAngle(int maxWinding, int sumWinding, int oppMaxWinding, int o
ppSumWinding, |
| 283 bool activeAngle, const SkOpAngle* angle); | 283 const SkOpAngle* angle); |
| 284 void markDone(int index, int winding); | 284 void markDone(int index, int winding); |
| 285 void markDoneBinary(int index); | 285 void markDoneBinary(int index); |
| 286 void markDoneUnary(int index); | 286 void markDoneUnary(int index); |
| 287 bool nextCandidate(int* start, int* end) const; | 287 bool nextCandidate(int* start, int* end) const; |
| 288 int nextSpan(int from, int step) const; | 288 int nextSpan(int from, int step) const; |
| 289 void setUpWindings(int index, int endIndex, int* sumMiWinding, int* sumSuWin
ding, | 289 void setUpWindings(int index, int endIndex, int* sumMiWinding, int* sumSuWin
ding, |
| 290 int* maxWinding, int* sumWinding, int* oppMaxWinding, int* oppSumWin
ding); | 290 int* maxWinding, int* sumWinding, int* oppMaxWinding, int* oppSumWin
ding); |
| 291 enum SortAngleKind { | 291 enum SortAngleKind { |
| 292 kMustBeOrdered_SortAngleKind, // required for winding calc | 292 kMustBeOrdered_SortAngleKind, // required for winding calc |
| 293 kMayBeUnordered_SortAngleKind // ok for find top | 293 kMayBeUnordered_SortAngleKind // ok for find top |
| (...skipping 28 matching lines...) Expand all Loading... |
| 322 #endif | 322 #endif |
| 323 #if DEBUG_CONCIDENT | 323 #if DEBUG_CONCIDENT |
| 324 void debugShowTs(const char* prefix) const; | 324 void debugShowTs(const char* prefix) const; |
| 325 #endif | 325 #endif |
| 326 #if DEBUG_SHOW_WINDING | 326 #if DEBUG_SHOW_WINDING |
| 327 int debugShowWindingValues(int slotCount, int ofInterest) const; | 327 int debugShowWindingValues(int slotCount, int ofInterest) const; |
| 328 #endif | 328 #endif |
| 329 | 329 |
| 330 private: | 330 private: |
| 331 struct MissingSpan { | 331 struct MissingSpan { |
| 332 enum Command { | |
| 333 kNoAction, | |
| 334 kAddMissing, | |
| 335 kRemoveNear, | |
| 336 kZeroSpan, | |
| 337 } fCommand; | |
| 338 double fT; | 332 double fT; |
| 339 double fEndT; | 333 double fEndT; |
| 340 SkOpSegment* fSegment; | 334 SkOpSegment* fSegment; |
| 341 SkOpSegment* fOther; | 335 SkOpSegment* fOther; |
| 342 double fOtherT; | 336 double fOtherT; |
| 343 SkPoint fPt; | 337 SkPoint fPt; |
| 344 }; | 338 }; |
| 345 | 339 |
| 346 bool activeAngleOther(int index, int* done, SkTArray<SkOpAngle, true>* angle
s); | 340 bool activeAngleOther(int index, int* done, SkTArray<SkOpAngle, true>* angle
s); |
| 347 bool activeAngleInner(int index, int* done, SkTArray<SkOpAngle, true>* angle
s); | 341 bool activeAngleInner(int index, int* done, SkTArray<SkOpAngle, true>* angle
s); |
| 348 bool activeOp(int xorMiMask, int xorSuMask, int index, int endIndex, SkPathO
p op, | 342 bool activeOp(int xorMiMask, int xorSuMask, int index, int endIndex, SkPathO
p op, |
| 349 int* sumMiWinding, int* sumSuWinding, int* maxWinding, int* su
mWinding, | 343 int* sumMiWinding, int* sumSuWinding, int* maxWinding, int* su
mWinding, |
| 350 int* oppMaxWinding, int* oppSumWinding); | 344 int* oppMaxWinding, int* oppSumWinding); |
| 351 bool activeWinding(int index, int endIndex, int* maxWinding, int* sumWinding
); | 345 bool activeWinding(int index, int endIndex, int* maxWinding, int* sumWinding
); |
| 352 void addAngle(SkTArray<SkOpAngle, true>* angles, int start, int end) const; | 346 void addAngle(SkTArray<SkOpAngle, true>* angles, int start, int end) const; |
| 353 void addCancelOutsides(const SkPoint& startPt, const SkPoint& endPt, SkOpSeg
ment* other); | 347 void addCancelOutsides(const SkPoint& startPt, const SkPoint& endPt, SkOpSeg
ment* other); |
| 354 void addCoinOutsides(const SkPoint& startPt, const SkPoint& endPt, SkOpSegme
nt* other); | 348 void addCoinOutsides(const SkPoint& startPt, const SkPoint& endPt, SkOpSegme
nt* other); |
| 355 void addTPair(double t, SkOpSegment* other, double otherT, bool borrowWind,
const SkPoint& pt, | 349 void addTPair(double t, SkOpSegment* other, double otherT, bool borrowWind,
const SkPoint& pt, |
| 356 const SkPoint& oPt); | 350 const SkPoint& oPt); |
| 357 void addTwoAngles(int start, int end, SkTArray<SkOpAngle, true>* angles) con
st; | 351 void addTwoAngles(int start, int end, SkTArray<SkOpAngle, true>* angles) con
st; |
| 358 void adjustMissingNear(const SkPoint& startPt, const SkPoint& endPt, | |
| 359 SkTArray<MissingSpan, true>* ); | |
| 360 void adjustNear(double startT, const SkPoint& endPt, SkTArray<MissingSpan, t
rue>* ); | |
| 361 void adjustOtherNear(double startT, const SkPoint& startPt, const SkPoint& e
ndPt, | |
| 362 SkTArray<MissingSpan, true>* ); | |
| 363 MissingSpan::Command adjustThisNear(double startT, const SkPoint& startPt, c
onst SkPoint& endPt, | |
| 364 SkTArray<MissingSpan, true>* ); | |
| 365 int advanceCoincidentOther(double oEndT, int oIndex); | |
| 366 int advanceCoincidentThis(int index); | |
| 367 bool betweenPoints(double midT, const SkPoint& pt1, const SkPoint& pt2) cons
t; | 352 bool betweenPoints(double midT, const SkPoint& pt1, const SkPoint& pt2) cons
t; |
| 368 bool buildAngles(int index, SkTArray<SkOpAngle, true>* angles, bool includeO
pp) const; | 353 bool buildAngles(int index, SkTArray<SkOpAngle, true>* angles, bool includeO
pp) const; |
| 369 void buildAnglesInner(int index, SkTArray<SkOpAngle, true>* angles) const; | 354 void buildAnglesInner(int index, SkTArray<SkOpAngle, true>* angles) const; |
| 370 void bumpCoincidentThis(const SkOpSpan& oTest, bool binary, int* index, | 355 void bumpCoincidentThis(const SkOpSpan& oTest, bool binary, int* index, |
| 371 SkTArray<SkPoint, true>* outsideTs); | 356 SkTArray<SkPoint, true>* outsideTs); |
| 372 bool bumpCoincident(SkOpSpan* test, bool bigger, bool binary); | |
| 373 void bumpCoincidentOther(const SkOpSpan& oTest, int* index, | 357 void bumpCoincidentOther(const SkOpSpan& oTest, int* index, |
| 374 SkTArray<SkPoint, true>* outsideTs); | 358 SkTArray<SkPoint, true>* outsideTs); |
| 375 bool bumpSpan(SkOpSpan* span, int windDelta, int oppDelta); | 359 bool bumpSpan(SkOpSpan* span, int windDelta, int oppDelta); |
| 376 bool clockwise(int tStart, int tEnd) const; | 360 bool clockwise(int tStart, int tEnd) const; |
| 377 static void ComputeOneSum(const SkOpAngle* baseAngle, SkOpAngle* nextAngle, | 361 static void ComputeOneSum(const SkOpAngle* baseAngle, SkOpAngle* nextAngle, |
| 378 SkOpAngle::IncludeType ); | 362 SkOpAngle::IncludeType ); |
| 379 static void ComputeOneSumReverse(const SkOpAngle* baseAngle, SkOpAngle* next
Angle, | 363 static void ComputeOneSumReverse(const SkOpAngle* baseAngle, SkOpAngle* next
Angle, |
| 380 SkOpAngle::IncludeType ); | 364 SkOpAngle::IncludeType ); |
| 381 bool decrementSpan(SkOpSpan* span); | 365 bool decrementSpan(SkOpSpan* span); |
| 382 int findStartingEdge(const SkTArray<SkOpAngle*, true>& sorted, int start, in
t end); | 366 int findStartingEdge(const SkTArray<SkOpAngle*, true>& sorted, int start, in
t end); |
| 383 void init(const SkPoint pts[], SkPath::Verb verb, bool operand, bool evenOdd
); | 367 void init(const SkPoint pts[], SkPath::Verb verb, bool operand, bool evenOdd
); |
| 384 bool isSimple(int end) const; | 368 bool isSimple(int end) const; |
| 385 bool isTiny(int index) const; | 369 bool isTiny(int index) const; |
| 386 void matchWindingValue(int tIndex, double t, bool borrowWind); | 370 void matchWindingValue(int tIndex, double t, bool borrowWind); |
| 387 SkOpSpan* markAndChaseDone(int index, int endIndex, int winding); | 371 SkOpSpan* markAndChaseDone(int index, int endIndex, int winding); |
| 388 SkOpSpan* markAndChaseDoneBinary(const SkOpAngle* angle, int winding, int op
pWinding); | 372 SkOpSpan* markAndChaseDoneBinary(const SkOpAngle* angle, int winding, int op
pWinding); |
| 389 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, const int winding); | 373 SkOpSpan* markAndChaseWinding(const SkOpAngle* angle, const int winding); |
| 390 SkOpSpan* markAndChaseWinding(int index, int endIndex, int winding, int oppW
inding); | 374 SkOpSpan* markAndChaseWinding(int index, int endIndex, int winding, int oppW
inding); |
| 391 SkOpSpan* markAngle(int maxWinding, int sumWinding, bool activeAngle, const
SkOpAngle* angle); | 375 SkOpSpan* markAngle(int maxWinding, int sumWinding, const SkOpAngle* angle); |
| 392 void markDoneBinary(int index, int winding, int oppWinding); | 376 void markDoneBinary(int index, int winding, int oppWinding); |
| 393 SkOpSpan* markAndChaseDoneUnary(const SkOpAngle* angle, int winding); | 377 SkOpSpan* markAndChaseDoneUnary(const SkOpAngle* angle, int winding); |
| 394 void markOneDone(const char* funName, int tIndex, int winding); | 378 void markOneDone(const char* funName, int tIndex, int winding); |
| 395 void markOneDoneBinary(const char* funName, int tIndex); | 379 void markOneDoneBinary(const char* funName, int tIndex); |
| 396 void markOneDoneBinary(const char* funName, int tIndex, int winding, int opp
Winding); | 380 void markOneDoneBinary(const char* funName, int tIndex, int winding, int opp
Winding); |
| 397 void markOneDoneUnary(const char* funName, int tIndex); | 381 void markOneDoneUnary(const char* funName, int tIndex); |
| 398 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding); | 382 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding); |
| 399 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding, int o
ppWinding); | 383 SkOpSpan* markOneWinding(const char* funName, int tIndex, int winding, int o
ppWinding); |
| 400 void markWinding(int index, int winding); | 384 void markWinding(int index, int winding); |
| 401 void markWinding(int index, int winding, int oppWinding); | 385 void markWinding(int index, int winding, int oppWinding); |
| 402 void markUnsortable(int start, int end); | 386 void markUnsortable(int start, int end); |
| 403 bool monotonicInY(int tStart, int tEnd) const; | 387 bool monotonicInY(int tStart, int tEnd) const; |
| 404 double missingNear(double otherT, const SkOpSegment* other, const SkPoint& s
tartPt, | |
| 405 const SkPoint& endPt) const; | |
| 406 bool multipleSpans(int end) const; | 388 bool multipleSpans(int end) const; |
| 407 SkOpSegment* nextChase(int* index, const int step, int* min, SkOpSpan** last
); | 389 SkOpSegment* nextChase(int* index, const int step, int* min, SkOpSpan** last
); |
| 408 int nextExactSpan(int from, int step) const; | 390 int nextExactSpan(int from, int step) const; |
| 409 bool serpentine(int tStart, int tEnd) const; | 391 bool serpentine(int tStart, int tEnd) const; |
| 410 void setUpWindings(int index, int endIndex, int* sumMiWinding, | 392 void setUpWindings(int index, int endIndex, int* sumMiWinding, |
| 411 int* maxWinding, int* sumWinding); | 393 int* maxWinding, int* sumWinding); |
| 412 void subDivideBounds(int start, int end, SkPathOpsBounds* bounds) const; | 394 void subDivideBounds(int start, int end, SkPathOpsBounds* bounds) const; |
| 413 static void TrackOutsidePair(SkTArray<SkPoint, true>* outsideTs, const SkPoi
nt& endPt, | 395 static void TrackOutsidePair(SkTArray<SkPoint, true>* outsideTs, const SkPoi
nt& endPt, |
| 414 const SkPoint& startPt); | 396 const SkPoint& startPt); |
| 415 static void TrackOutside(SkTArray<SkPoint, true>* outsideTs, const SkPoint&
startPt); | 397 static void TrackOutside(SkTArray<SkPoint, true>* outsideTs, const SkPoint&
startPt); |
| 416 int updateOppWinding(int index, int endIndex) const; | 398 int updateOppWinding(int index, int endIndex) const; |
| 417 int updateOppWinding(const SkOpAngle* angle) const; | 399 int updateOppWinding(const SkOpAngle* angle) const; |
| 418 int updateWinding(int index, int endIndex) const; | 400 int updateWinding(int index, int endIndex) const; |
| 419 int updateWinding(const SkOpAngle* angle) const; | 401 int updateWinding(const SkOpAngle* angle) const; |
| 420 int updateWindingReverse(int index, int endIndex) const; | 402 int updateWindingReverse(int index, int endIndex) const; |
| 421 static bool UseInnerWindingReverse(int outerWinding, int innerWinding); | 403 static bool UseInnerWindingReverse(int outerWinding, int innerWinding); |
| 422 SkOpSpan* verifyOneWinding(const char* funName, int tIndex); | 404 SkOpSpan* verifyOneWinding(const char* funName, int tIndex); |
| 423 SkOpSpan* verifyOneWindingU(const char* funName, int tIndex); | 405 SkOpSpan* verifyOneWindingU(const char* funName, int tIndex); |
| 424 int windValue(const SkOpAngle* angle) const; | |
| 425 int windValueAt(double t) const; | |
| 426 void zeroSpan(SkOpSpan* span); | 406 void zeroSpan(SkOpSpan* span); |
| 427 | 407 |
| 428 #if DEBUG_SWAP_TOP | 408 #if DEBUG_SWAP_TOP |
| 429 bool controlsContainedByEnds(int tStart, int tEnd) const; | 409 bool controlsContainedByEnds(int tStart, int tEnd) const; |
| 430 #endif | 410 #endif |
| 431 #if DEBUG_CONCIDENT | 411 #if DEBUG_CONCIDENT |
| 432 void debugAddTPair(double t, const SkOpSegment& other, double otherT) const
; | 412 void debugAddTPair(double t, const SkOpSegment& other, double otherT) const
; |
| 433 #endif | 413 #endif |
| 434 #if DEBUG_MARK_DONE || DEBUG_UNSORTABLE | 414 #if DEBUG_MARK_DONE || DEBUG_UNSORTABLE |
| 435 void debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding)
; | 415 void debugShowNewWinding(const char* fun, const SkOpSpan& span, int winding)
; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 457 SkPath::Verb fVerb; | 437 SkPath::Verb fVerb; |
| 458 bool fOperand; | 438 bool fOperand; |
| 459 bool fXor; // set if original contour had even-odd fill | 439 bool fXor; // set if original contour had even-odd fill |
| 460 bool fOppXor; // set if opposite operand had even-odd fill | 440 bool fOppXor; // set if opposite operand had even-odd fill |
| 461 #ifdef SK_DEBUG | 441 #ifdef SK_DEBUG |
| 462 int fID; | 442 int fID; |
| 463 #endif | 443 #endif |
| 464 }; | 444 }; |
| 465 | 445 |
| 466 #endif | 446 #endif |
| OLD | NEW |