blob: 83ba70a0f917841c9dcd93a74db2ea56ec739e6c [file] [log] [blame]
caryclark45fa4472015-01-16 07:04:10 -08001/*
2 * Copyright 2013 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 SkOpCoincidence_DEFINED
8#define SkOpCoincidence_DEFINED
9
10#include "SkOpTAllocator.h"
11#include "SkOpSpan.h"
caryclark27c8eb82015-07-06 11:38:33 -070012#include "SkPathOpsTypes.h"
caryclark45fa4472015-01-16 07:04:10 -080013
14class SkOpPtT;
15
16struct SkCoincidentSpans {
17 SkCoincidentSpans* fNext;
18 SkOpPtT* fCoinPtTStart;
19 SkOpPtT* fCoinPtTEnd;
20 SkOpPtT* fOppPtTStart;
21 SkOpPtT* fOppPtTEnd;
22 bool fFlipped;
caryclark54359292015-03-26 07:52:43 -070023
24 void dump() const;
caryclark45fa4472015-01-16 07:04:10 -080025};
26
27class SkOpCoincidence {
28public:
29 SkOpCoincidence()
caryclark27c8eb82015-07-06 11:38:33 -070030 : fHead(NULL)
31 , fTop(NULL)
32 SkDEBUGPARAMS(fDebugState(NULL))
33 {
caryclark45fa4472015-01-16 07:04:10 -080034 }
35
36 void add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
caryclark54359292015-03-26 07:52:43 -070037 SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator);
caryclark27c8eb82015-07-06 11:38:33 -070038 void addExpanded(SkChunkAlloc* allocator PATH_OPS_DEBUG_VALIDATE_PARAMS(SkOpGlobalState* ));
caryclark54359292015-03-26 07:52:43 -070039 bool addMissing(SkChunkAlloc* allocator);
caryclark1049f122015-04-20 08:31:59 -070040 void addMissing(SkCoincidentSpans* check, SkChunkAlloc* allocator);
caryclark54359292015-03-26 07:52:43 -070041 bool apply();
caryclark45fa4472015-01-16 07:04:10 -080042 bool contains(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
43 SkOpPtT* oppPtTEnd, bool flipped);
caryclark27c8eb82015-07-06 11:38:33 -070044
45 const SkOpAngle* debugAngle(int id) const {
46 return SkDEBUGRELEASE(fDebugState->debugAngle(id), NULL);
47 }
48
49 SkOpContour* debugContour(int id) {
50 return SkDEBUGRELEASE(fDebugState->debugContour(id), NULL);
51 }
52
53 const SkOpPtT* debugPtT(int id) const {
54 return SkDEBUGRELEASE(fDebugState->debugPtT(id), NULL);
55 }
56
57 const SkOpSegment* debugSegment(int id) const {
58 return SkDEBUGRELEASE(fDebugState->debugSegment(id), NULL);
59 }
60
61 void debugSetGlobalState(SkOpGlobalState* debugState) {
62 SkDEBUGCODE(fDebugState = debugState);
63 }
64
caryclark624637c2015-05-11 07:21:27 -070065 void debugShowCoincidence() const;
caryclark27c8eb82015-07-06 11:38:33 -070066
67 const SkOpSpanBase* debugSpan(int id) const {
68 return SkDEBUGRELEASE(fDebugState->debugSpan(id), NULL);
69 }
70
caryclark54359292015-03-26 07:52:43 -070071 void detach(SkCoincidentSpans* );
caryclark45fa4472015-01-16 07:04:10 -080072 void dump() const;
caryclark27c8eb82015-07-06 11:38:33 -070073 bool expand();
caryclarkbca19f72015-05-13 08:23:48 -070074 bool extend(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
75 SkOpPtT* oppPtTEnd);
caryclark27c8eb82015-07-06 11:38:33 -070076 void findOverlaps(SkOpCoincidence* , SkChunkAlloc* allocator) const;
77 void fixAligned();
caryclark54359292015-03-26 07:52:43 -070078 void fixUp(SkOpPtT* deleted, SkOpPtT* kept);
caryclark27c8eb82015-07-06 11:38:33 -070079
80 bool isEmpty() const {
81 return !fHead;
82 }
83
caryclark45fa4472015-01-16 07:04:10 -080084 void mark();
85
caryclark54359292015-03-26 07:52:43 -070086private:
caryclark27c8eb82015-07-06 11:38:33 -070087 void addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s, SkOpPtT* over1e,
88 SkChunkAlloc* );
caryclark54359292015-03-26 07:52:43 -070089 bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over1e,
caryclark27c8eb82015-07-06 11:38:33 -070090 const SkOpPtT* over2s, const SkOpPtT* over2e,
91 double tStart, double tEnd,
caryclark54359292015-03-26 07:52:43 -070092 SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
93 SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd,
caryclark27c8eb82015-07-06 11:38:33 -070094 SkChunkAlloc* );
95 void addOverlap(SkOpSegment* seg1, SkOpSegment* seg1o, SkOpSegment* seg2, SkOpSegment* seg2o,
96 SkOpPtT* overS, SkOpPtT* overE, SkChunkAlloc* );
caryclark54359292015-03-26 07:52:43 -070097 bool overlap(const SkOpPtT* coinStart1, const SkOpPtT* coinEnd1,
98 const SkOpPtT* coinStart2, const SkOpPtT* coinEnd2,
99 double* overS, double* overE) const;
100
caryclark27c8eb82015-07-06 11:38:33 -0700101 bool testForCoincidence(const SkCoincidentSpans* outer, SkOpPtT* testS, SkOpPtT* testE) const;
caryclark45fa4472015-01-16 07:04:10 -0800102 SkCoincidentSpans* fHead;
caryclark27c8eb82015-07-06 11:38:33 -0700103 SkCoincidentSpans* fTop;
104 SkDEBUGCODE_(SkOpGlobalState* fDebugState);
caryclark45fa4472015-01-16 07:04:10 -0800105};
106
107#endif