diff options
Diffstat (limited to 'src/pathops/SkPathOpsTypes.h')
-rw-r--r-- | src/pathops/SkPathOpsTypes.h | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/pathops/SkPathOpsTypes.h b/src/pathops/SkPathOpsTypes.h index 00c3e5fe93..ad2ad463e6 100644 --- a/src/pathops/SkPathOpsTypes.h +++ b/src/pathops/SkPathOpsTypes.h @@ -22,6 +22,7 @@ enum SkPathOpsMask { kEvenOdd_PathOpsMask = 1 }; +class SkChunkAlloc; class SkOpCoincidence; class SkOpContour; class SkOpContourHead; @@ -30,8 +31,8 @@ class SkIntersectionHelper; class SkOpGlobalState { public: - SkOpGlobalState(SkOpCoincidence* coincidence, SkOpContourHead* head - SkDEBUGPARAMS(bool debugSkipAssert) + SkOpGlobalState(SkOpContourHead* head, + SkChunkAlloc* allocator SkDEBUGPARAMS(bool debugSkipAssert) SkDEBUGPARAMS(const char* testName)); enum Phase { @@ -44,6 +45,10 @@ public: kMaxWindingTries = 10 }; + SkChunkAlloc* allocator() { + return fAllocator; + } + bool angleCoincidence() const { return fAngleCoincidence; } @@ -65,7 +70,8 @@ public: } #ifdef SK_DEBUG - const struct SkOpAngle* debugAngle(int id) const; + const class SkOpAngle* debugAngle(int id) const; + const SkOpCoincidence* debugCoincidence() const; SkOpContour* debugContour(int id); const class SkOpPtT* debugPtT(int id) const; bool debugRunFail() const; @@ -83,6 +89,11 @@ public: void debugResetLoopCounts(); #endif +#if DEBUG_COINCIDENCE + void debugSetCheckHealth(bool check) { fDebugCheckHealth = check; } + bool debugCheckHealth() const { return fDebugCheckHealth; } +#endif + int nested() const { return fNested; } @@ -120,6 +131,10 @@ public: void setAngleCoincidence() { fAngleCoincidence = true; } + + void setCoincidence(SkOpCoincidence* coincidence) { + fCoincidence = coincidence; + } void setContourHead(SkOpContourHead* contourHead) { fContourHead = contourHead; @@ -140,6 +155,7 @@ public: } private: + SkChunkAlloc* fAllocator; SkOpCoincidence* fCoincidence; SkOpContourHead* fContourHead; int fNested; @@ -162,6 +178,9 @@ private: SkPoint fDebugWorstPts[24]; float fDebugWorstWeight[6]; #endif +#if DEBUG_COINCIDENCE + bool fDebugCheckHealth; +#endif }; // Use Almost Equal when comparing coordinates. Use epsilon to compare T values. @@ -170,6 +189,11 @@ inline bool AlmostEqualUlps(double a, double b) { return AlmostEqualUlps(SkDoubleToScalar(a), SkDoubleToScalar(b)); } +bool AlmostEqualUlpsNoNormalCheck(float a, float b); +inline bool AlmostEqualUlpsNoNormalCheck(double a, double b) { + return AlmostEqualUlpsNoNormalCheck(SkDoubleToScalar(a), SkDoubleToScalar(b)); +} + bool AlmostEqualUlps_Pin(float a, float b); inline bool AlmostEqualUlps_Pin(double a, double b) { return AlmostEqualUlps_Pin(SkDoubleToScalar(a), SkDoubleToScalar(b)); @@ -246,6 +270,8 @@ const double MORE_ROUGH_EPSILON = FLT_EPSILON * 256; const double WAY_ROUGH_EPSILON = FLT_EPSILON * 2048; const double BUMP_EPSILON = FLT_EPSILON * 4096; +const SkScalar INVERSE_NUMBER_RANGE = FLT_EPSILON_ORDERABLE_ERR; + inline bool zero_or_one(double x) { return x == 0 || x == 1; } @@ -298,7 +324,6 @@ inline bool approximately_zero_inverse(double x) { return fabs(x) > FLT_EPSILON_INVERSE; } -// OPTIMIZATION: if called multiple times with the same denom, we want to pass 1/y instead inline bool approximately_zero_when_compared_to(double x, double y) { return x == 0 || fabs(x) < fabs(y * FLT_EPSILON); } @@ -307,6 +332,10 @@ inline bool precisely_zero_when_compared_to(double x, double y) { return x == 0 || fabs(x) < fabs(y * DBL_EPSILON); } +inline bool roughly_zero_when_compared_to(double x, double y) { + return x == 0 || fabs(x) < fabs(y * ROUGH_EPSILON); +} + // Use this for comparing Ts in the range of 0 to 1. For general numbers (larger and smaller) use // AlmostEqualUlps instead. inline bool approximately_equal(double x, double y) { |