michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkOpEdgeBuilder_DEFINED michael@0: #define SkOpEdgeBuilder_DEFINED michael@0: michael@0: #include "SkOpContour.h" michael@0: #include "SkPathWriter.h" michael@0: #include "SkTArray.h" michael@0: michael@0: class SkOpEdgeBuilder { michael@0: public: michael@0: SkOpEdgeBuilder(const SkPathWriter& path, SkTArray& contours) michael@0: : fPath(path.nativePath()) michael@0: , fContours(contours) michael@0: , fAllowOpenContours(true) { michael@0: init(); michael@0: } michael@0: michael@0: SkOpEdgeBuilder(const SkPath& path, SkTArray& contours) michael@0: : fPath(&path) michael@0: , fContours(contours) michael@0: , fAllowOpenContours(false) { michael@0: init(); michael@0: } michael@0: michael@0: void complete() { michael@0: if (fCurrentContour && fCurrentContour->segments().count()) { michael@0: fCurrentContour->complete(); michael@0: fCurrentContour = NULL; michael@0: } michael@0: } michael@0: michael@0: SkPathOpsMask xorMask() const { michael@0: return fXorMask[fOperand]; michael@0: } michael@0: michael@0: void addOperand(const SkPath& path); michael@0: bool finish(); michael@0: void init(); michael@0: michael@0: private: michael@0: void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart); michael@0: bool close(); michael@0: int preFetch(); michael@0: bool walk(); michael@0: michael@0: const SkPath* fPath; michael@0: SkTArray fPathPts; michael@0: SkTArray fPathVerbs; michael@0: SkOpContour* fCurrentContour; michael@0: SkTArray& fContours; michael@0: SkPathOpsMask fXorMask[2]; michael@0: int fSecondHalf; michael@0: bool fOperand; michael@0: bool fAllowOpenContours; michael@0: bool fUnparseable; michael@0: }; michael@0: michael@0: #endif