blob: df0795b0c85827176c36a23c56d977c0902ff674 [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
2 * Copyright 2012 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 SkOpEdgeBuilder_DEFINED
8#define SkOpEdgeBuilder_DEFINED
9
10#include "SkOpContour.h"
11#include "SkPathWriter.h"
12#include "SkTArray.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +000013
14class SkOpEdgeBuilder {
15public:
16 SkOpEdgeBuilder(const SkPathWriter& path, SkTArray<SkOpContour>& contours)
17 : fPath(path.nativePath())
caryclark@google.com66560ca2013-04-26 19:51:16 +000018 , fContours(contours)
19 , fAllowOpenContours(true) {
caryclark@google.com07393ca2013-04-08 11:47:37 +000020 init();
21 }
22
23 SkOpEdgeBuilder(const SkPath& path, SkTArray<SkOpContour>& contours)
24 : fPath(&path)
caryclark@google.com66560ca2013-04-26 19:51:16 +000025 , fContours(contours)
26 , fAllowOpenContours(false) {
caryclark@google.com07393ca2013-04-08 11:47:37 +000027 init();
28 }
29
30 void complete() {
31 if (fCurrentContour && fCurrentContour->segments().count()) {
32 fCurrentContour->complete();
33 fCurrentContour = NULL;
34 }
35 }
36
37 SkPathOpsMask xorMask() const {
38 return fXorMask[fOperand];
39 }
40
41 void addOperand(const SkPath& path);
caryclark@google.com66560ca2013-04-26 19:51:16 +000042 bool finish();
caryclark@google.com07393ca2013-04-08 11:47:37 +000043 void init();
44
45private:
caryclark@google.com07e97fc2013-07-08 17:17:02 +000046 void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart);
caryclark@google.com66560ca2013-04-26 19:51:16 +000047 bool close();
caryclark@google.com07393ca2013-04-08 11:47:37 +000048 int preFetch();
caryclark@google.com66560ca2013-04-26 19:51:16 +000049 bool walk();
caryclark@google.com07393ca2013-04-08 11:47:37 +000050
51 const SkPath* fPath;
caryclark@google.comd892bd82013-06-17 14:10:36 +000052 SkTArray<SkPoint, true> fPathPts;
53 SkTArray<uint8_t, true> fPathVerbs;
caryclark@google.com07393ca2013-04-08 11:47:37 +000054 SkOpContour* fCurrentContour;
55 SkTArray<SkOpContour>& fContours;
caryclark@google.com07393ca2013-04-08 11:47:37 +000056 SkPathOpsMask fXorMask[2];
57 int fSecondHalf;
58 bool fOperand;
caryclark@google.com66560ca2013-04-26 19:51:16 +000059 bool fAllowOpenContours;
60 bool fUnparseable;
caryclark@google.com07393ca2013-04-08 11:47:37 +000061};
62
63#endif