OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #ifndef SkPathWriter_DEFINED | 7 #ifndef SkPathWriter_DEFINED |
8 #define SkPathWriter_DEFINED | 8 #define SkPathWriter_DEFINED |
9 | 9 |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
11 #include "SkTArray.h" | 11 #include "SkTArray.h" |
12 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
13 | 13 |
14 class SkOpPtT; | 14 class SkOpPtT; |
15 | 15 |
16 // Construct the path one contour at a time. | 16 // Construct the path one contour at a time. |
17 // If the contour is closed, copy it to the final output. | 17 // If the contour is closed, copy it to the final output. |
18 // Otherwise, keep the partial contour for later assembly. | 18 // Otherwise, keep the partial contour for later assembly. |
19 | 19 |
20 class SkPathWriter { | 20 class SkPathWriter { |
21 public: | 21 public: |
22 SkPathWriter(SkPath& path); | 22 SkPathWriter(SkPath& path); |
23 void assemble(); | 23 void assemble(); |
24 void conicTo(const SkPoint& pt1, const SkOpPtT* pt2, SkScalar weight); | 24 void conicTo(const SkPoint& pt1, const SkOpPtT* pt2, SkScalar weight); |
25 void cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkOpPtT* pt3); | 25 void cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkOpPtT* pt3); |
26 void deferredLine(const SkOpPtT* pt); | 26 bool deferredLine(const SkOpPtT* pt); |
27 void deferredMove(const SkOpPtT* pt); | 27 void deferredMove(const SkOpPtT* pt); |
28 void finishContour(); | 28 void finishContour(); |
29 bool hasMove() const { return !fFirstPtT; } | 29 bool hasMove() const { return !fFirstPtT; } |
30 void init(); | 30 void init(); |
31 bool isClosed() const; | 31 bool isClosed() const; |
32 const SkPath* nativePath() const { return fPathPtr; } | 32 const SkPath* nativePath() const { return fPathPtr; } |
33 void quadTo(const SkPoint& pt1, const SkOpPtT* pt2); | 33 void quadTo(const SkPoint& pt1, const SkOpPtT* pt2); |
34 | 34 |
35 private: | 35 private: |
36 bool changedSlopes(const SkOpPtT* pt) const; | 36 bool changedSlopes(const SkOpPtT* pt) const; |
37 void close(); | 37 void close(); |
38 const SkTDArray<const SkOpPtT*>& endPtTs() const { return fEndPtTs; } | 38 const SkTDArray<const SkOpPtT*>& endPtTs() const { return fEndPtTs; } |
39 void lineTo(); | 39 void lineTo(); |
40 bool matchedLast(const SkOpPtT*) const; | 40 bool matchedLast(const SkOpPtT*) const; |
41 void moveTo(); | 41 void moveTo(); |
42 const SkTArray<SkPath>& partials() const { return fPartials; } | 42 const SkTArray<SkPath>& partials() const { return fPartials; } |
43 bool someAssemblyRequired(); | 43 bool someAssemblyRequired(); |
44 void update(const SkOpPtT* pt); | 44 void update(const SkOpPtT* pt); |
45 | 45 |
46 SkPath fCurrent; // contour under construction | 46 SkPath fCurrent; // contour under construction |
47 SkTArray<SkPath> fPartials; // contours with mismatched starts and ends | 47 SkTArray<SkPath> fPartials; // contours with mismatched starts and ends |
48 SkTDArray<const SkOpPtT*> fEndPtTs; // possible pt values for partial start
s and ends | 48 SkTDArray<const SkOpPtT*> fEndPtTs; // possible pt values for partial start
s and ends |
49 SkPath* fPathPtr; // closed contours are written here | 49 SkPath* fPathPtr; // closed contours are written here |
50 const SkOpPtT* fDefer[2]; // [0] deferred move, [1] deferred line | 50 const SkOpPtT* fDefer[2]; // [0] deferred move, [1] deferred line |
51 const SkOpPtT* fFirstPtT; // first in current contour | 51 const SkOpPtT* fFirstPtT; // first in current contour |
52 }; | 52 }; |
53 | 53 |
54 #endif /* defined(__PathOps__SkPathWriter__) */ | 54 #endif /* defined(__PathOps__SkPathWriter__) */ |
OLD | NEW |