2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 #ifndef Intersections_DEFINE
8 #define Intersections_DEFINE
20 bzero(fPt, sizeof(fPt));
21 bzero(fT, sizeof(fT));
22 bzero(fIsCoincident, sizeof(fIsCoincident));
27 int coincidentUsed() const {
28 if (!fIsCoincident[0]) {
29 SkASSERT(!fIsCoincident[0]);
33 SkDEBUGCODE(int count2 = 0;)
34 for (int index = 0; index < fUsed; ++index) {
35 if (fIsCoincident[0] & (1 << index)) {
39 if (fIsCoincident[1] & (1 << index)) {
44 SkASSERT(count == count2);
48 void offset(int base, double start, double end) {
49 for (int index = base; index < fUsed; ++index) {
50 double val = fT[fSwap][index];
53 fT[fSwap][index] = val;
57 // FIXME : does not respect swap
58 int insert(double one, double two, const _Point& pt);
60 // start if index == 0 : end if index == 1
61 void insertCoincident(double one, double two, const _Point& pt) {
62 int index = insertSwap(one, two, pt);
64 fIsCoincident[0] |= bit;
65 fIsCoincident[1] |= bit;
68 void insertCoincidentPair(double s1, double e1, double s2, double e2,
69 const _Point& startPt, const _Point& endPt);
71 int insertSwap(double one, double two, const _Point& pt) {
73 return insert(two, one, pt);
75 return insert(one, two, pt);
79 bool intersected() const {
83 void removeOne(int index);
85 // leaves flip, swap alone
97 for (index = 0; index < fUsed; ++index) {
98 SkTSwap(fT[0][index], fT[1][index]);
102 bool swapped() const {
106 bool unsortable() const {
115 SkASSERT(--fDepth >= 0);
119 SkASSERT(++fDepth < 16);
130 unsigned short fIsCoincident[2]; // bit arrays, one bit set for each coincident T
138 // used by addCoincident to remove ordinary intersections in range
139 void remove(double one, double two, const _Point& startPt, const _Point& endPt);