1792 {
1793#if DEBUG_T_SECT_DUMP > 1
1795#endif
1798 intersections->
reset();
1800 SkTSpan* span1 = sect1->fHead;
1801 SkTSpan* span2 = sect2->fHead;
1802 int oppSect, sect = sect1->intersects(span1, sect2, span2, &oppSect);
1803
1804 if (!sect) {
1805 return;
1806 }
1807 if (sect == 2 && oppSect == 2) {
1808 (void) EndsEqual(sect1, sect2, intersections);
1809 return;
1810 }
1813 const int kMaxCoinLoopCount = 8;
1814 int coinLoopCount = kMaxCoinLoopCount;
1817 do {
1818
1819 SkTSpan* largest1 = sect1->boundsMax();
1820 if (!largest1) {
1821 if (sect1->fHung) {
1822 return;
1823 }
1824 break;
1825 }
1826 SkTSpan* largest2 = sect2->boundsMax();
1827
1828 if (!largest2 || (largest1 && (largest1->fBoundsMax > largest2->fBoundsMax
1829 || (!largest1->fCollapsed && largest2->fCollapsed)))) {
1830 if (sect2->fHung) {
1831 return;
1832 }
1833 if (largest1->fCollapsed) {
1834 break;
1835 }
1836 sect1->resetRemovedEnds();
1837 sect2->resetRemovedEnds();
1838
1839 SkTSpan* half1 = sect1->addOne();
1840 SkDEBUGCODE(half1->debugSetGlobalState(sect1->globalState()));
1841 if (!half1->
split(largest1, §1->fHeap)) {
1842 break;
1843 }
1844 if (!sect1->trim(largest1, sect2)) {
1846 return;
1847 }
1848 if (!sect1->trim(half1, sect2)) {
1850 return;
1851 }
1852 } else {
1853 if (largest2->fCollapsed) {
1854 break;
1855 }
1856 sect1->resetRemovedEnds();
1857 sect2->resetRemovedEnds();
1858
1861 if (!
half2->split(largest2, §2->fHeap)) {
1862 break;
1863 }
1864 if (!sect2->trim(largest2, sect1)) {
1866 return;
1867 }
1868 if (!sect2->trim(
half2, sect1)) {
1870 return;
1871 }
1872 }
1873 sect1->validate();
1874 sect2->validate();
1875#if DEBUG_T_SECT_LOOP_COUNT
1877#endif
1878
1881 if (coinLoopCount == kMaxCoinLoopCount) {
1882 start1s = sect1->fHead->fStartT;
1883 start1e = sect1->tail()->fEndT;
1884 }
1885 if (!sect1->coincidentCheck(sect2)) {
1886 return;
1887 }
1888 sect1->validate();
1889 sect2->validate();
1890#if DEBUG_T_SECT_LOOP_COUNT
1892#endif
1893 if (!--coinLoopCount && sect1->fHead && sect2->fHead) {
1894
1895
1896
1897
1898
1899 sect1->coincidentForce(sect2, start1s, start1e);
1900 sect1->validate();
1901 sect2->validate();
1902 }
1903 }
1906 if (!sect1->fHead) {
1907 return;
1908 }
1909 sect1->computePerpendiculars(sect2, sect1->fHead, sect1->tail());
1910 if (!sect2->fHead) {
1911 return;
1912 }
1913 sect2->computePerpendiculars(sect1, sect2->fHead, sect2->tail());
1914 if (!sect1->removeByPerpendicular(sect2)) {
1915 return;
1916 }
1917 sect1->validate();
1918 sect2->validate();
1919#if DEBUG_T_SECT_LOOP_COUNT
1921#endif
1923 break;
1924 }
1925 }
1926#if DEBUG_T_SECT_DUMP
1928#endif
1929 if (!sect1->fHead || !sect2->fHead) {
1930 break;
1931 }
1932 } while (true);
1935
1937 sect1->mergeCoincidence(sect2);
1939 }
1941 do {
1943 return;
1944 }
1946 continue;
1947 }
1949 continue;
1950 }
1951 double perpT =
coincident->fCoinStart.perpT();
1952 if (perpT < 0) {
1953 return;
1954 }
1959 coincident->pointLast()) < 0) && index >= 0) {
1961 }
1963 }
1964 int zeroOneSet = EndsEqual(sect1, sect2, intersections);
1965
1966
1967 if (sect1->fRemovedStartT && !(zeroOneSet & kZeroS1Set)) {
1969 perp.
setPerp(sect1->fCurve, 0, sect1->fCurve[0], sect2->fCurve);
1972 }
1973 }
1974 if (sect1->fRemovedEndT && !(zeroOneSet & kOneS1Set)) {
1976 perp.
setPerp(sect1->fCurve, 1, sect1->pointLast(), sect2->fCurve);
1979 }
1980 }
1981 if (sect2->fRemovedStartT && !(zeroOneSet & kZeroS2Set)) {
1983 perp.
setPerp(sect2->fCurve, 0, sect2->fCurve[0], sect1->fCurve);
1986 }
1987 }
1988 if (sect2->fRemovedEndT && !(zeroOneSet & kOneS2Set)) {
1990 perp.
setPerp(sect2->fCurve, 1, sect2->pointLast(), sect1->fCurve);
1993 }
1994 }
1995
1996 if (!sect1->fHead || !sect2->fHead) {
1997 return;
1998 }
1999 sect1->recoverCollapsed();
2000 sect2->recoverCollapsed();
2001 SkTSpan* result1 = sect1->fHead;
2002
2003 const SkTSpan* head1 = result1;
2005 const SkDPoint& start1 = sect1->fCurve[0];
2009 intersections->
insert(0, t, start1);
2010 }
2011 }
2012 }
2013 const SkTSpan* head2 = sect2->fHead;
2015 const SkDPoint& start2 = sect2->fCurve[0];
2019 intersections->
insert(t, 0, start2);
2020 }
2021 }
2022 }
2023 if (!(zeroOneSet & kOneS1Set)) {
2024 const SkTSpan* tail1 = sect1->tail();
2025 if (!tail1) {
2026 return;
2027 }
2029 const SkDPoint& end1 = sect1->pointLast();
2033 intersections->
insert(1, t, end1);
2034 }
2035 }
2036 }
2037 }
2038 if (!(zeroOneSet & kOneS2Set)) {
2039 const SkTSpan* tail2 = sect2->tail();
2040 if (!tail2) {
2041 return;
2042 }
2044 const SkDPoint& end2 = sect2->pointLast();
2048 intersections->
insert(t, 1, end2);
2049 }
2050 }
2051 }
2052 }
2054 do {
2055 while (result1 && result1->fCoinStart.
isMatch() && result1->fCoinEnd.
isMatch()) {
2056 result1 = result1->fNext;
2057 }
2058 if (!result1) {
2059 break;
2060 }
2061 SkTSpan* result2 = sect2->fHead;
2062 while (result2) {
2064 result2 = result2->fNext;
2065 }
2066 } while ((result1 = result1->fNext));
2067 closest.
finish(intersections);
2068
2069 int last = intersections->
used() - 1;
2070 for (int index = 0; index < last; ) {
2072 ++index;
2073 continue;
2074 }
2075 double midT = ((*intersections)[0][index] + (*intersections)[0][index + 1]) / 2;
2077
2079 perp.
setPerp(sect1->fCurve, midT, midPt, sect2->fCurve);
2081 ++index;
2082 continue;
2083 }
2086 --last;
2089 --last;
2090 } else {
2092 }
2094 }
2096}
static bool coincident(const SkPoint &a, const SkPoint &b)
#define SK_INIT_TO_AVOID_WARNING
#define COINCIDENT_SPAN_COUNT
bool approximately_less_than_zero(double x)
bool approximately_greater_than_one(double x)
#define SkOPOBJASSERT(obj, cond)
int insert(double one, double two, const SkDPoint &pt)
void removeOne(int index)
int insertCoincident(double one, double two, const SkDPoint &pt)
void debugBumpLoopCount(DebugLoop)
void setCoincident(int index)
bool isCoincident(int index)
void clearCoincidence(int index)
const SkDPoint & perpPt() const
void setPerp(const SkTCurve &c1, double t, const SkDPoint &cPt, const SkTCurve &)
virtual SkDPoint ptAtT(double t) const =0
virtual int maxIntersections() const =0
void dumpBoth(SkTSect *) const
void addBounded(SkTSpan *, SkArenaAlloc *)
bool split(SkTSpan *work, SkArenaAlloc *heap)
double closestBoundedT(const SkDPoint &pt) const
bool find(const SkTSpan *span1, const SkTSpan *span2 SkDEBUGPARAMS(SkIntersections *i))
void finish(SkIntersections *intersections) const
bool approximatelyEqual(const SkDPoint &a) const