SkOpAngle.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright 2012 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef SkOpAngle_DEFINED
  8. #define SkOpAngle_DEFINED
  9. #include "src/pathops/SkLineParameters.h"
  10. #include "src/pathops/SkPathOpsCurve.h"
  11. #if DEBUG_ANGLE
  12. #include "include/core/SkString.h"
  13. #endif
  14. class SkOpContour;
  15. class SkOpPtT;
  16. class SkOpSegment;
  17. class SkOpSpanBase;
  18. class SkOpSpan;
  19. class SkOpAngle {
  20. public:
  21. enum IncludeType {
  22. kUnaryWinding,
  23. kUnaryXor,
  24. kBinarySingle,
  25. kBinaryOpp,
  26. };
  27. const SkOpAngle* debugAngle(int id) const;
  28. const SkOpCoincidence* debugCoincidence() const;
  29. SkOpContour* debugContour(int id) const;
  30. int debugID() const {
  31. return SkDEBUGRELEASE(fID, -1);
  32. }
  33. #if DEBUG_SORT
  34. void debugLoop() const;
  35. #endif
  36. #if DEBUG_ANGLE
  37. bool debugCheckCoincidence() const { return fCheckCoincidence; }
  38. void debugCheckNearCoincidence() const;
  39. SkString debugPart() const;
  40. #endif
  41. const SkOpPtT* debugPtT(int id) const;
  42. const SkOpSegment* debugSegment(int id) const;
  43. int debugSign() const;
  44. const SkOpSpanBase* debugSpan(int id) const;
  45. void debugValidate() const;
  46. void debugValidateNext() const; // in debug builds, verify that angle loop is uncorrupted
  47. double distEndRatio(double dist) const;
  48. // available to testing only
  49. void dump() const;
  50. void dumpCurves() const;
  51. void dumpLoop() const;
  52. void dumpOne(bool functionHeader) const;
  53. void dumpTo(const SkOpSegment* fromSeg, const SkOpAngle* ) const;
  54. void dumpTest() const;
  55. SkOpSpanBase* end() const {
  56. return fEnd;
  57. }
  58. bool insert(SkOpAngle* );
  59. SkOpSpanBase* lastMarked() const;
  60. bool loopContains(const SkOpAngle* ) const;
  61. int loopCount() const;
  62. SkOpAngle* next() const {
  63. return fNext;
  64. }
  65. SkOpAngle* previous() const;
  66. SkOpSegment* segment() const;
  67. void set(SkOpSpanBase* start, SkOpSpanBase* end);
  68. void setLastMarked(SkOpSpanBase* marked) {
  69. fLastMarked = marked;
  70. }
  71. SkOpSpanBase* start() const {
  72. return fStart;
  73. }
  74. SkOpSpan* starter();
  75. bool tangentsAmbiguous() const {
  76. return fTangentsAmbiguous;
  77. }
  78. bool unorderable() const {
  79. return fUnorderable;
  80. }
  81. private:
  82. bool after(SkOpAngle* test);
  83. void alignmentSameSide(const SkOpAngle* test, int* order) const;
  84. bool checkCrossesZero() const;
  85. bool checkParallel(SkOpAngle* );
  86. bool computeSector();
  87. int convexHullOverlaps(const SkOpAngle* );
  88. bool endToSide(const SkOpAngle* rh, bool* inside) const;
  89. bool endsIntersect(SkOpAngle* );
  90. int findSector(SkPath::Verb verb, double x, double y) const;
  91. SkOpGlobalState* globalState() const;
  92. int lineOnOneSide(const SkDPoint& origin, const SkDVector& line, const SkOpAngle* test,
  93. bool useOriginal) const;
  94. int lineOnOneSide(const SkOpAngle* test, bool useOriginal);
  95. int linesOnOriginalSide(const SkOpAngle* test);
  96. bool merge(SkOpAngle* );
  97. double midT() const;
  98. bool midToSide(const SkOpAngle* rh, bool* inside) const;
  99. bool oppositePlanes(const SkOpAngle* rh) const;
  100. int orderable(SkOpAngle* rh); // false == this < rh ; true == this > rh; -1 == unorderable
  101. void setSector();
  102. void setSpans();
  103. bool tangentsDiverge(const SkOpAngle* rh, double s0xt0);
  104. SkDCurve fOriginalCurvePart; // the curve from start to end
  105. SkDCurveSweep fPart; // the curve from start to end offset as needed
  106. double fSide;
  107. SkLineParameters fTangentHalf; // used only to sort a pair of lines or line-like sections
  108. SkOpAngle* fNext;
  109. SkOpSpanBase* fLastMarked;
  110. SkOpSpanBase* fStart;
  111. SkOpSpanBase* fEnd;
  112. SkOpSpanBase* fComputedEnd;
  113. int fSectorMask;
  114. int8_t fSectorStart; // in 32nds of a circle
  115. int8_t fSectorEnd;
  116. bool fUnorderable;
  117. bool fComputeSector;
  118. bool fComputedSector;
  119. bool fCheckCoincidence;
  120. bool fTangentsAmbiguous;
  121. SkDEBUGCODE(int fID);
  122. friend class PathOpsAngleTester;
  123. };
  124. #endif