Line data Source code
1 : /*
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 :
13 0 : class SkOpEdgeBuilder {
14 : public:
15 : SkOpEdgeBuilder(const SkPathWriter& path, SkOpContourHead* contours2,
16 : SkOpGlobalState* globalState)
17 : : fGlobalState(globalState)
18 : , fPath(path.nativePath())
19 : , fContourBuilder(contours2)
20 : , fContoursHead(contours2)
21 : , fAllowOpenContours(true) {
22 : init();
23 : }
24 :
25 0 : SkOpEdgeBuilder(const SkPath& path, SkOpContourHead* contours2, SkOpGlobalState* globalState)
26 0 : : fGlobalState(globalState)
27 : , fPath(&path)
28 : , fContourBuilder(contours2)
29 : , fContoursHead(contours2)
30 0 : , fAllowOpenContours(false) {
31 0 : init();
32 0 : }
33 :
34 : void addOperand(const SkPath& path);
35 :
36 0 : void complete() {
37 0 : fContourBuilder.flush();
38 0 : SkOpContour* contour = fContourBuilder.contour();
39 0 : if (contour && contour->count()) {
40 0 : contour->complete();
41 0 : fContourBuilder.setContour(nullptr);
42 : }
43 0 : }
44 :
45 : bool finish();
46 :
47 : const SkOpContour* head() const {
48 : return fContoursHead;
49 : }
50 :
51 : void init();
52 0 : bool unparseable() const { return fUnparseable; }
53 0 : SkPathOpsMask xorMask() const { return fXorMask[fOperand]; }
54 :
55 : private:
56 : void closeContour(const SkPoint& curveEnd, const SkPoint& curveStart);
57 : bool close();
58 : int preFetch();
59 : bool walk();
60 :
61 : SkOpGlobalState* fGlobalState;
62 : const SkPath* fPath;
63 : SkTDArray<SkPoint> fPathPts;
64 : SkTDArray<SkScalar> fWeights;
65 : SkTDArray<uint8_t> fPathVerbs;
66 : SkOpContourBuilder fContourBuilder;
67 : SkOpContourHead* fContoursHead;
68 : SkPathOpsMask fXorMask[2];
69 : int fSecondHalf;
70 : bool fOperand;
71 : bool fAllowOpenContours;
72 : bool fUnparseable;
73 : };
74 :
75 : #endif
|