107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com/*
207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * Copyright 2012 Google Inc.
307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com *
407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * Use of this source code is governed by a BSD-style license that can be
507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com * found in the LICENSE file.
607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com */
707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#ifndef SkOpSpan_DEFINED
807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#define SkOpSpan_DEFINED
907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com
1007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#include "SkPoint.h"
1107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com
12dac1d17027dcaa5596885a9f333979418b35001ccaryclarkclass SkOpAngle;
1307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.comclass SkOpSegment;
1407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com
1507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.comstruct SkOpSpan {
1607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    SkPoint fPt;  // computed when the curves are intersected
1707393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    double fT;
1807393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    double fOtherT;  // value at fOther[fOtherIndex].fT
19dac1d17027dcaa5596885a9f333979418b35001ccaryclark    SkOpSegment* fOther;
20dac1d17027dcaa5596885a9f333979418b35001ccaryclark    SkOpAngle* fFromAngle;  // (if t > 0) index into segment's angle array going negative in t
21dac1d17027dcaa5596885a9f333979418b35001ccaryclark    SkOpAngle* fToAngle;  // (if t < 1) index into segment's angle array going positive in t
2207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    int fOtherIndex;  // can't be used during intersection
2307393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    int fWindSum;  // accumulated from contours surrounding this one.
2407393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    int fOppSum;  // for binary operators: the opposite winding sum
2507393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    int fWindValue;  // 0 == canceled; 1 == normal; >1 == coincident
2607393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    int fOppValue;  // normally 0 -- when binary coincident edges combine, opp value goes here
274431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    bool fChased;  // set after span has been added to chase array
28dac1d17027dcaa5596885a9f333979418b35001ccaryclark    bool fCoincident;  // set if span is bumped -- if set additional points aren't inserted
2907393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com    bool fDone;  // if set, this span to next higher T has been processed
304431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    bool fLoop;  // set when a cubic loops back to this point
31dac1d17027dcaa5596885a9f333979418b35001ccaryclark    bool fMultiple;  // set if this is one of mutiple spans with identical t and pt values
32dac1d17027dcaa5596885a9f333979418b35001ccaryclark    bool fNear;  // set if opposite end point is near but not equal to this one
334431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    bool fSmall;   // if set, consecutive points are almost equal
344431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    bool fTiny;  // if set, consecutive points are equal but consecutive ts are not precisely equal
35570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com
364431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    // available to testing only
374431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    const SkOpSegment* debugToSegment(ptrdiff_t* ) const;
38570863f2e22b8ea7d7c504bd15e4f766af097df2caryclark@google.com    void dump() const;
394431e7757cfcb8cfa99535eed0e9f156dabf95c2commit-bot@chromium.org    void dumpOne() const;
4007393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com};
4107393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com
4207393cab57ce74a4aae89a31fae9aaa9780fc19dcaryclark@google.com#endif
43