Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
SkOpAngle Class Reference

#include <SkOpAngle.h>

Public Types

enum  IncludeType { kUnaryWinding , kUnaryXor , kBinarySingle , kBinaryOpp }
 

Public Member Functions

const SkOpAngledebugAngle (int id) const
 
const SkOpCoincidencedebugCoincidence () const
 
SkOpContourdebugContour (int id) const
 
int debugID () const
 
const SkOpPtTdebugPtT (int id) const
 
const SkOpSegmentdebugSegment (int id) const
 
int debugSign () const
 
const SkOpSpanBasedebugSpan (int id) const
 
void debugValidate () const
 
void debugValidateNext () const
 
double distEndRatio (double dist) const
 
void dump () const
 
void dumpCurves () const
 
void dumpLoop () const
 
void dumpOne (bool functionHeader) const
 
void dumpTo (const SkOpSegment *fromSeg, const SkOpAngle *) const
 
void dumpTest () const
 
SkOpSpanBaseend () const
 
bool insert (SkOpAngle *)
 
SkOpSpanBaselastMarked () const
 
bool loopContains (const SkOpAngle *) const
 
int loopCount () const
 
SkOpAnglenext () const
 
SkOpAngleprevious () const
 
SkOpSegmentsegment () const
 
void set (SkOpSpanBase *start, SkOpSpanBase *end)
 
void setLastMarked (SkOpSpanBase *marked)
 
SkOpSpanBasestart () const
 
SkOpSpanstarter ()
 
bool tangentsAmbiguous () const
 
bool unorderable () const
 

Detailed Description

Definition at line 32 of file SkOpAngle.h.

Member Enumeration Documentation

◆ IncludeType

Enumerator
kUnaryWinding 
kUnaryXor 
kBinarySingle 
kBinaryOpp 

Definition at line 34 of file SkOpAngle.h.

34 {
39 };
@ kBinaryOpp
Definition: SkOpAngle.h:38
@ kUnaryWinding
Definition: SkOpAngle.h:35
@ kBinarySingle
Definition: SkOpAngle.h:37
@ kUnaryXor
Definition: SkOpAngle.h:36

Member Function Documentation

◆ debugAngle()

const SkOpAngle * SkOpAngle::debugAngle ( int  id) const

Definition at line 524 of file PathOpsDebug.cpp.

524 {
525 return this->segment()->debugAngle(id);
526}
SkOpSegment * segment() const
Definition: SkOpAngle.cpp:969
const SkOpAngle * debugAngle(int id) const

◆ debugCoincidence()

const SkOpCoincidence * SkOpAngle::debugCoincidence ( ) const

Definition at line 528 of file PathOpsDebug.cpp.

528 {
529 return this->segment()->debugCoincidence();
530}
const SkOpCoincidence * debugCoincidence() const

◆ debugContour()

SkOpContour * SkOpAngle::debugContour ( int  id) const

Definition at line 532 of file PathOpsDebug.cpp.

532 {
533 return this->segment()->debugContour(id);
534}
SkOpContour * debugContour(int id) const

◆ debugID()

int SkOpAngle::debugID ( ) const
inline

Definition at line 45 of file SkOpAngle.h.

45 {
46 return SkDEBUGRELEASE(fID, -1);
47 }
#define SkDEBUGRELEASE(a, b)

◆ debugPtT()

const SkOpPtT * SkOpAngle::debugPtT ( int  id) const

Definition at line 536 of file PathOpsDebug.cpp.

536 {
537 return this->segment()->debugPtT(id);
538}
const SkOpPtT * debugPtT(int id) const

◆ debugSegment()

const SkOpSegment * SkOpAngle::debugSegment ( int  id) const

Definition at line 540 of file PathOpsDebug.cpp.

540 {
541 return this->segment()->debugSegment(id);
542}
const SkOpSegment * debugSegment(int id) const

◆ debugSign()

int SkOpAngle::debugSign ( ) const

Definition at line 544 of file PathOpsDebug.cpp.

544 {
545 SkASSERT(fStart->t() != fEnd->t());
546 return fStart->t() < fEnd->t() ? -1 : 1;
547}
#define SkASSERT(cond)
Definition: SkAssert.h:116
double t() const
Definition: SkOpSpan.h:375

◆ debugSpan()

const SkOpSpanBase * SkOpAngle::debugSpan ( int  id) const

Definition at line 549 of file PathOpsDebug.cpp.

549 {
550 return this->segment()->debugSpan(id);
551}
const SkOpSpanBase * debugSpan(int id) const

◆ debugValidate()

void SkOpAngle::debugValidate ( ) const

Definition at line 1323 of file SkPathOpsDebug.cpp.

1323 {
1324#if DEBUG_COINCIDENCE
1325 if (this->globalState()->debugCheckHealth()) {
1326 return;
1327 }
1328#endif
1329#if DEBUG_VALIDATE
1330 const SkOpAngle* first = this;
1331 const SkOpAngle* next = this;
1332 int wind = 0;
1333 int opp = 0;
1334 int lastXor = -1;
1335 int lastOppXor = -1;
1336 do {
1337 if (next->unorderable()) {
1338 return;
1339 }
1340 const SkOpSpan* minSpan = next->start()->starter(next->end());
1341 if (minSpan->windValue() == SK_MinS32) {
1342 return;
1343 }
1344 bool op = next->segment()->operand();
1345 bool isXor = next->segment()->isXor();
1346 bool oppXor = next->segment()->oppXor();
1350 bool useXor = op ? oppXor : isXor;
1351 SkASSERT(lastXor == -1 || lastXor == (int) useXor);
1352 lastXor = (int) useXor;
1353 wind += next->debugSign() * (op ? minSpan->oppValue() : minSpan->windValue());
1354 if (useXor) {
1355 wind &= 1;
1356 }
1357 useXor = op ? isXor : oppXor;
1358 SkASSERT(lastOppXor == -1 || lastOppXor == (int) useXor);
1359 lastOppXor = (int) useXor;
1360 opp += next->debugSign() * (op ? minSpan->windValue() : minSpan->oppValue());
1361 if (useXor) {
1362 opp &= 1;
1363 }
1364 next = next->fNext;
1365 } while (next && next != first);
1366 SkASSERT(wind == 0 || !SkPathOpsDebug::gRunFail);
1367 SkASSERT(opp == 0 || !SkPathOpsDebug::gRunFail);
1368#endif
1369}
static constexpr int32_t SK_MinS32
Definition: SkMath.h:22
#define DEBUG_LIMIT_WIND_SUM
bool between(double a, double b, double c)
bool unorderable() const
Definition: SkOpAngle.h:104
SkOpSpanBase * end() const
Definition: SkOpAngle.h:73
SkOpAngle * next() const
Definition: SkOpAngle.h:82
int debugSign() const
SkOpSpanBase * start() const
Definition: SkOpAngle.h:94
bool operand() const
bool oppXor() const
bool isXor() const
const SkOpSpan * starter(const SkOpSpanBase *end) const
Definition: SkOpSpan.h:347
int oppValue() const
Definition: SkOpSpan.h:505
int windValue() const
Definition: SkOpSpan.h:560
static bool gRunFail

◆ debugValidateNext()

void SkOpAngle::debugValidateNext ( ) const

Definition at line 1371 of file SkPathOpsDebug.cpp.

1371 {
1372#if !FORCE_RELEASE
1373 const SkOpAngle* first = this;
1374 const SkOpAngle* next = first;
1376 do {
1377// SkASSERT_RELEASE(next->fSegment->debugContains(next));
1378 angles.push_back(next);
1379 next = next->next();
1380 if (next == first) {
1381 break;
1382 }
1383 SkASSERT_RELEASE(!angles.contains(next));
1384 if (!next) {
1385 return;
1386 }
1387 } while (true);
1388#endif
1389}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100
void push_back(const T &v)
Definition: SkTDArray.h:219

◆ distEndRatio()

double SkOpAngle::distEndRatio ( double  dist) const

Definition at line 499 of file SkOpAngle.cpp.

499 {
500 double longest = 0;
501 const SkOpSegment& segment = *this->segment();
502 int ptCount = SkPathOpsVerbToPoints(segment.verb());
503 const SkPoint* pts = segment.pts();
504 for (int idx1 = 0; idx1 <= ptCount - 1; ++idx1) {
505 for (int idx2 = idx1 + 1; idx2 <= ptCount; ++idx2) {
506 if (idx1 == idx2) {
507 continue;
508 }
509 SkDVector v;
510 v.set(pts[idx2] - pts[idx1]);
511 double lenSq = v.lengthSquared();
512 longest = std::max(longest, lenSq);
513 }
514 }
515 return sqrt(longest) / dist;
516}
int SkPathOpsVerbToPoints(SkPath::Verb verb)
SkPath::Verb verb() const
Definition: SkOpSegment.h:419
const SkPoint * pts() const
Definition: SkOpSegment.h:327
static float max(float r, float g, float b)
Definition: hsl.cpp:49
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition: SkVx.h:706
SkDVector & set(const SkVector &pt)
double lengthSquared() const

◆ dump()

void SkOpAngle::dump ( ) const

Definition at line 553 of file PathOpsDebug.cpp.

553 {
554 dumpOne(true);
555 SkDebugf("\n");
556}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
void dumpOne(bool functionHeader) const

◆ dumpCurves()

void SkOpAngle::dumpCurves ( ) const

Definition at line 618 of file PathOpsDebug.cpp.

618 {
619 const SkOpAngle* first = this;
620 const SkOpAngle* next = this;
621 do {
622 next->fPart.fCurve.dumpID(next->segment()->debugID());
623 next = next->fNext;
624 } while (next && next != first);
625}
SkDCurve fCurve
int debugID() const
Definition: SkOpSegment.h:154
void dumpID(int) const

◆ dumpLoop()

void SkOpAngle::dumpLoop ( ) const

Definition at line 627 of file PathOpsDebug.cpp.

627 {
628 const SkOpAngle* first = this;
629 const SkOpAngle* next = this;
630 do {
631 next->dumpOne(false);
632 SkDebugf("\n");
633 next = next->fNext;
634 } while (next && next != first);
635}

◆ dumpOne()

void SkOpAngle::dumpOne ( bool  functionHeader) const

Definition at line 558 of file PathOpsDebug.cpp.

558 {
559// fSegment->debugValidate();
560 const SkOpSegment* segment = this->segment();
561 const SkOpSpan& mSpan = *fStart->starter(fEnd);
562 if (functionHeader) {
563 SkDebugf("%s ", __FUNCTION__);
564 }
565 SkDebugf("[%d", segment->debugID());
566 SkDebugf("/%d", debugID());
567 SkDebugf("] next=");
568 if (fNext) {
569 SkDebugf("%d", fNext->fStart->segment()->debugID());
570 SkDebugf("/%d", fNext->debugID());
571 } else {
572 SkDebugf("?");
573 }
574 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
575 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
576 fEnd->t(), fEnd->debugID());
577 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
578
579 SkDebugf(" windSum=");
581 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
582 SkDebugf(" oppVal=%d", mSpan.oppValue());
583 SkDebugf(" oppSum=");
585 }
586 if (mSpan.done()) {
587 SkDebugf(" done");
588 }
589 if (unorderable()) {
590 SkDebugf(" unorderable");
591 }
592 if (segment->operand()) {
593 SkDebugf(" operand");
594 }
595}
int debugID() const
Definition: SkOpAngle.h:45
int debugID() const
Definition: SkOpSpan.h:224
SkOpSegment * segment() const
Definition: SkOpSpan.h:318
int windSum() const
Definition: SkOpSpan.h:555
int oppSum() const
Definition: SkOpSpan.h:500
bool done() const
Definition: SkOpSpan.h:459
static void WindingPrintf(int winding)

◆ dumpTest()

void SkOpAngle::dumpTest ( ) const

Definition at line 637 of file PathOpsDebug.cpp.

637 {
638 const SkOpAngle* first = this;
639 const SkOpAngle* next = this;
640 do {
641 SkDebugf("{ ");
643 segment->dumpPts();
644 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
645 next->start()->t(), next->end()->t());
646 next = next->fNext;
647 } while (next && next != first);
648}
void dumpPts(const char *prefix="seg") const

◆ dumpTo()

void SkOpAngle::dumpTo ( const SkOpSegment fromSeg,
const SkOpAngle to 
) const

Definition at line 597 of file PathOpsDebug.cpp.

597 {
598 const SkOpAngle* first = this;
599 const SkOpAngle* next = this;
600 const char* indent = "";
601 do {
602 SkDebugf("%s", indent);
603 next->dumpOne(false);
604 if (segment == next->fStart->segment()) {
605 if (this == fNext) {
606 SkDebugf(" << from");
607 }
608 if (to == fNext) {
609 SkDebugf(" << to");
610 }
611 }
612 SkDebugf("\n");
613 indent = " ";
614 next = next->fNext;
615 } while (next && next != first);
616}

◆ end()

SkOpSpanBase * SkOpAngle::end ( ) const
inline

Definition at line 73 of file SkOpAngle.h.

73 {
74 return fEnd;
75 }

◆ insert()

bool SkOpAngle::insert ( SkOpAngle angle)

Definition at line 749 of file SkOpAngle.cpp.

749 {
750 if (angle->fNext) {
751 if (loopCount() >= angle->loopCount()) {
752 if (!merge(angle)) {
753 return true;
754 }
755 } else if (fNext) {
756 if (!angle->merge(this)) {
757 return true;
758 }
759 } else {
760 angle->insert(this);
761 }
762 return true;
763 }
764 bool singleton = nullptr == fNext;
765 if (singleton) {
766 fNext = this;
767 }
768 SkOpAngle* next = fNext;
769 if (next->fNext == this) {
770 if (singleton || angle->after(this)) {
771 this->fNext = angle;
772 angle->fNext = next;
773 } else {
774 next->fNext = angle;
775 angle->fNext = this;
776 }
778 return true;
779 }
780 SkOpAngle* last = this;
781 bool flipAmbiguity = false;
782 do {
783 SkASSERT(last->fNext == next);
784 if (angle->after(last) ^ (angle->tangentsAmbiguous() & flipAmbiguity)) {
785 last->fNext = angle;
786 angle->fNext = next;
788 break;
789 }
790 last = next;
791 if (last == this) {
792 FAIL_IF(flipAmbiguity);
793 // We're in a loop. If a sort was ambiguous, flip it to end the loop.
794 flipAmbiguity = true;
795 }
796 next = next->fNext;
797 } while (true);
798 return true;
799}
#define FAIL_IF(cond)
int loopCount() const
Definition: SkOpAngle.cpp:837
void debugValidateNext() const
bool tangentsAmbiguous() const
Definition: SkOpAngle.h:100
bool insert(SkOpAngle *)
Definition: SkOpAngle.cpp:749

◆ lastMarked()

SkOpSpanBase * SkOpAngle::lastMarked ( ) const

Definition at line 801 of file SkOpAngle.cpp.

801 {
802 if (fLastMarked) {
803 if (fLastMarked->chased()) {
804 return nullptr;
805 }
806 fLastMarked->setChased(true);
807 }
808 return fLastMarked;
809}
void setChased(bool chased)
Definition: SkOpSpan.h:326
bool chased() const
Definition: SkOpSpan.h:192

◆ loopContains()

bool SkOpAngle::loopContains ( const SkOpAngle angle) const

Definition at line 811 of file SkOpAngle.cpp.

811 {
812 if (!fNext) {
813 return false;
814 }
815 const SkOpAngle* first = this;
816 const SkOpAngle* loop = this;
817 const SkOpSegment* tSegment = angle->fStart->segment();
818 double tStart = angle->fStart->t();
819 double tEnd = angle->fEnd->t();
820 do {
821 const SkOpSegment* lSegment = loop->fStart->segment();
822 if (lSegment != tSegment) {
823 continue;
824 }
825 double lStart = loop->fStart->t();
826 if (lStart != tEnd) {
827 continue;
828 }
829 double lEnd = loop->fEnd->t();
830 if (lEnd == tStart) {
831 return true;
832 }
833 } while ((loop = loop->fNext) != first);
834 return false;
835}

◆ loopCount()

int SkOpAngle::loopCount ( ) const

Definition at line 837 of file SkOpAngle.cpp.

837 {
838 int count = 0;
839 const SkOpAngle* first = this;
840 const SkOpAngle* next = this;
841 do {
842 next = next->fNext;
843 ++count;
844 } while (next && next != first);
845 return count;
846}
int count
Definition: FontMgrTest.cpp:50

◆ next()

SkOpAngle * SkOpAngle::next ( ) const
inline

Definition at line 82 of file SkOpAngle.h.

82 {
83 return fNext;
84 }

◆ previous()

SkOpAngle * SkOpAngle::previous ( ) const

Definition at line 958 of file SkOpAngle.cpp.

958 {
959 SkOpAngle* last = fNext;
960 do {
961 SkOpAngle* next = last->fNext;
962 if (next == this) {
963 return last;
964 }
965 last = next;
966 } while (true);
967}

◆ segment()

SkOpSegment * SkOpAngle::segment ( ) const

Definition at line 969 of file SkOpAngle.cpp.

969 {
970 return fStart->segment();
971}

◆ set()

void SkOpAngle::set ( SkOpSpanBase start,
SkOpSpanBase end 
)

Definition at line 973 of file SkOpAngle.cpp.

973 {
974 fStart = start;
975 fComputedEnd = fEnd = end;
976 SkASSERT(start != end);
977 fNext = nullptr;
978 fComputeSector = fComputedSector = fCheckCoincidence = fTangentsAmbiguous = false;
979 setSpans();
980 setSector();
981 SkDEBUGCODE(fID = start ? start->globalState()->nextAngleID() : -1);
982}
SkOpGlobalState * globalState() const
Definition: SkOpSpan.cpp:239

◆ setLastMarked()

void SkOpAngle::setLastMarked ( SkOpSpanBase marked)
inline

Definition at line 90 of file SkOpAngle.h.

90 {
91 fLastMarked = marked;
92 }

◆ start()

SkOpSpanBase * SkOpAngle::start ( ) const
inline

Definition at line 94 of file SkOpAngle.h.

94 {
95 return fStart;
96 }

◆ starter()

SkOpSpan * SkOpAngle::starter ( )

Definition at line 1125 of file SkOpAngle.cpp.

1125 {
1126 return fStart->starter(fEnd);
1127}

◆ tangentsAmbiguous()

bool SkOpAngle::tangentsAmbiguous ( ) const
inline

Definition at line 100 of file SkOpAngle.h.

100 {
101 return fTangentsAmbiguous;
102 }

◆ unorderable()

bool SkOpAngle::unorderable ( ) const
inline

Definition at line 104 of file SkOpAngle.h.

104 {
105 return fUnorderable;
106 }

The documentation for this class was generated from the following files: