Home | History | Annotate | Download | only in pathops
      1 /*
      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"
     12 
     13 class SkOpPtT;
     14 
     15 struct SkCoincidentSpans {
     16     SkCoincidentSpans* fNext;
     17     SkOpPtT* fCoinPtTStart;
     18     SkOpPtT* fCoinPtTEnd;
     19     SkOpPtT* fOppPtTStart;
     20     SkOpPtT* fOppPtTEnd;
     21     bool fFlipped;
     22 
     23     void dump() const;
     24 };
     25 
     26 class SkOpCoincidence {
     27 public:
     28     SkOpCoincidence()
     29         : fHead(NULL) {
     30     }
     31 
     32     void add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
     33              SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator);
     34     bool addMissing(SkChunkAlloc* allocator);
     35     void addMissing(SkCoincidentSpans* check, SkChunkAlloc* allocator);
     36     bool apply();
     37     bool contains(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
     38                   SkOpPtT* oppPtTEnd, bool flipped);
     39     void debugShowCoincidence() const;
     40     void detach(SkCoincidentSpans* );
     41     void dump() const;
     42     void expand();
     43     bool extend(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
     44         SkOpPtT* oppPtTEnd);
     45     void fixUp(SkOpPtT* deleted, SkOpPtT* kept);
     46     void mark();
     47 
     48 private:
     49     bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over1e,
     50                       const SkOpPtT* over2s, const SkOpPtT* over2e, double tStart, double tEnd,
     51                       SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
     52                       SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd,
     53                       SkChunkAlloc* allocator);
     54     bool overlap(const SkOpPtT* coinStart1, const SkOpPtT* coinEnd1,
     55                  const SkOpPtT* coinStart2, const SkOpPtT* coinEnd2,
     56                  double* overS, double* overE) const;
     57 
     58     SkCoincidentSpans* fHead;
     59 };
     60 
     61 #endif
     62