OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 SkEdgeBuilder_DEFINED | 7 #ifndef SkEdgeBuilder_DEFINED |
8 #define SkEdgeBuilder_DEFINED | 8 #define SkEdgeBuilder_DEFINED |
9 | 9 |
10 #include "SkChunkAlloc.h" | 10 #include "SkChunkAlloc.h" |
11 #include "SkRect.h" | 11 #include "SkRect.h" |
12 #include "SkTDArray.h" | 12 #include "SkTDArray.h" |
13 | 13 |
14 struct SkEdge; | 14 struct SkEdge; |
15 struct SkAnalyticEdge; | |
16 class SkEdgeClipper; | 15 class SkEdgeClipper; |
17 class SkPath; | 16 class SkPath; |
18 | 17 |
19 class SkEdgeBuilder { | 18 class SkEdgeBuilder { |
20 public: | 19 public: |
21 SkEdgeBuilder(); | 20 SkEdgeBuilder(); |
22 | 21 |
23 // returns the number of built edges. The array of those edge pointers | 22 // returns the number of built edges. The array of those edge pointers |
24 // is returned from edgeList(). | 23 // is returned from edgeList(). |
25 int build(const SkPath& path, const SkIRect* clip, int shiftUp, bool clipToT
heRight, | 24 int build(const SkPath& path, const SkIRect* clip, int shiftUp, bool clipToT
heRight); |
26 bool analyticAA = false); | |
27 | 25 |
28 SkEdge** edgeList() { return (SkEdge**)fEdgeList; } | 26 SkEdge** edgeList() { return fEdgeList; } |
29 SkAnalyticEdge** analyticEdgeList() { return (SkAnalyticEdge**)fEdgeList; } | |
30 | 27 |
31 private: | 28 private: |
32 enum Combine { | 29 enum Combine { |
33 kNo_Combine, | 30 kNo_Combine, |
34 kPartial_Combine, | 31 kPartial_Combine, |
35 kTotal_Combine | 32 kTotal_Combine |
36 }; | 33 }; |
37 | 34 |
38 Combine CombineVertical(const SkEdge* edge, SkEdge* last); | 35 static Combine CombineVertical(const SkEdge* edge, SkEdge* last); |
39 Combine CombineVertical(const SkAnalyticEdge* edge, SkAnalyticEdge* last); | |
40 Combine checkVertical(const SkEdge* edge, SkEdge** edgePtr); | 36 Combine checkVertical(const SkEdge* edge, SkEdge** edgePtr); |
41 Combine checkVertical(const SkAnalyticEdge* edge, SkAnalyticEdge** edgePtr); | |
42 bool vertical_line(const SkEdge* edge); | |
43 bool vertical_line(const SkAnalyticEdge* edge); | |
44 | 37 |
45 SkChunkAlloc fAlloc; | 38 SkChunkAlloc fAlloc; |
46 SkTDArray<void*> fList; | 39 SkTDArray<SkEdge*> fList; |
47 | 40 |
48 /* | 41 /* |
49 * If we're in general mode, we allcoate the pointers in fList, and this | 42 * If we're in general mode, we allcoate the pointers in fList, and this |
50 * will point at fList.begin(). If we're in polygon mode, fList will be | 43 * will point at fList.begin(). If we're in polygon mode, fList will be |
51 * empty, as we will have preallocated room for the pointers in fAlloc's | 44 * empty, as we will have preallocated room for the pointers in fAlloc's |
52 * block, and fEdgeList will point into that. | 45 * block, and fEdgeList will point into that. |
53 */ | 46 */ |
54 void** fEdgeList; | 47 SkEdge** fEdgeList; |
55 | 48 |
56 int fShiftUp; | 49 int fShiftUp; |
57 bool fAnalyticAA; | |
58 | 50 |
59 public: | 51 public: |
60 void addLine(const SkPoint pts[]); | 52 void addLine(const SkPoint pts[]); |
61 void addQuad(const SkPoint pts[]); | 53 void addQuad(const SkPoint pts[]); |
62 void addCubic(const SkPoint pts[]); | 54 void addCubic(const SkPoint pts[]); |
63 void addClipper(SkEdgeClipper*); | 55 void addClipper(SkEdgeClipper*); |
64 | 56 |
65 int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp, bool cli
pToTheRight); | 57 int buildPoly(const SkPath& path, const SkIRect* clip, int shiftUp, bool cli
pToTheRight); |
66 }; | 58 }; |
67 | 59 |
68 #endif | 60 #endif |
OLD | NEW |