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 | 7 |
8 #ifndef GrAARectRenderer_DEFINED | 8 #ifndef GrAARectRenderer_DEFINED |
9 #define GrAARectRenderer_DEFINED | 9 #define GrAARectRenderer_DEFINED |
10 | 10 |
11 #include "SkMatrix.h" | 11 #include "SkMatrix.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
| 14 #include "SkStrokeRec.h" |
14 | 15 |
15 class GrGpu; | 16 class GrGpu; |
16 class GrDrawTarget; | 17 class GrDrawTarget; |
17 class GrIndexBuffer; | 18 class GrIndexBuffer; |
18 | 19 |
19 /* | 20 /* |
20 * This class wraps helper functions that draw AA rects (filled & stroked) | 21 * This class wraps helper functions that draw AA rects (filled & stroked) |
21 */ | 22 */ |
22 class GrAARectRenderer : public SkRefCnt { | 23 class GrAARectRenderer : public SkRefCnt { |
23 public: | 24 public: |
24 SK_DECLARE_INST_COUNT(GrAARectRenderer) | 25 SK_DECLARE_INST_COUNT(GrAARectRenderer) |
25 | 26 |
26 GrAARectRenderer() | 27 GrAARectRenderer() |
27 : fAAFillRectIndexBuffer(NULL) | 28 : fAAFillRectIndexBuffer(NULL) |
28 , fAAStrokeRectIndexBuffer(NULL) { | 29 , fAAMiterStrokeRectIndexBuffer(NULL) |
| 30 , fAABevelStrokeRectIndexBuffer(NULL) { |
29 } | 31 } |
30 | 32 |
31 void reset(); | 33 void reset(); |
32 | 34 |
33 ~GrAARectRenderer() { | 35 ~GrAARectRenderer() { |
34 this->reset(); | 36 this->reset(); |
35 } | 37 } |
36 | 38 |
37 // TODO: potentialy fuse the fill & stroke methods and differentiate | 39 // TODO: potentialy fuse the fill & stroke methods and differentiate |
38 // between them by passing in strokeWidth (<0 means fill). | 40 // between them by passing in stroke (==NULL means fill). |
39 | 41 |
40 void fillAARect(GrGpu* gpu, | 42 void fillAARect(GrGpu* gpu, |
41 GrDrawTarget* target, | 43 GrDrawTarget* target, |
42 const SkRect& rect, | 44 const SkRect& rect, |
43 const SkMatrix& combinedMatrix, | 45 const SkMatrix& combinedMatrix, |
44 const SkRect& devRect, | 46 const SkRect& devRect, |
45 bool useVertexCoverage) { | 47 bool useVertexCoverage) { |
46 #ifdef SHADER_AA_FILL_RECT | 48 #ifdef SHADER_AA_FILL_RECT |
47 if (combinedMatrix.rectStaysRect()) { | 49 if (combinedMatrix.rectStaysRect()) { |
48 this->shaderFillAlignedAARect(gpu, target, | 50 this->shaderFillAlignedAARect(gpu, target, |
49 rect, combinedMatrix); | 51 rect, combinedMatrix); |
50 } else { | 52 } else { |
51 this->shaderFillAARect(gpu, target, | 53 this->shaderFillAARect(gpu, target, |
52 rect, combinedMatrix); | 54 rect, combinedMatrix); |
53 } | 55 } |
54 #else | 56 #else |
55 this->geometryFillAARect(gpu, target, | 57 this->geometryFillAARect(gpu, target, |
56 rect, combinedMatrix, | 58 rect, combinedMatrix, |
57 devRect, useVertexCoverage); | 59 devRect, useVertexCoverage); |
58 #endif | 60 #endif |
59 } | 61 } |
60 | 62 |
61 void strokeAARect(GrGpu* gpu, | 63 void strokeAARect(GrGpu* gpu, |
62 GrDrawTarget* target, | 64 GrDrawTarget* target, |
63 const SkRect& rect, | 65 const SkRect& rect, |
64 const SkMatrix& combinedMatrix, | 66 const SkMatrix& combinedMatrix, |
65 const SkRect& devRect, | 67 const SkRect& devRect, |
66 SkScalar width, | 68 const SkStrokeRec* stroke, |
67 bool useVertexCoverage); | 69 bool useVertexCoverage); |
68 | 70 |
69 // First rect is outer; second rect is inner | 71 // First rect is outer; second rect is inner |
70 void fillAANestedRects(GrGpu* gpu, | 72 void fillAANestedRects(GrGpu* gpu, |
71 GrDrawTarget* target, | 73 GrDrawTarget* target, |
72 const SkRect rects[2], | 74 const SkRect rects[2], |
73 const SkMatrix& combinedMatrix, | 75 const SkMatrix& combinedMatrix, |
74 bool useVertexCoverage); | 76 bool useVertexCoverage); |
75 | 77 |
76 private: | 78 private: |
77 GrIndexBuffer* fAAFillRectIndexBuffer; | 79 GrIndexBuffer* fAAFillRectIndexBuffer; |
78 GrIndexBuffer* fAAStrokeRectIndexBuffer; | 80 GrIndexBuffer* fAAMiterStrokeRectIndexBuffer; |
| 81 GrIndexBuffer* fAABevelStrokeRectIndexBuffer; |
79 | 82 |
80 GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu); | 83 GrIndexBuffer* aaFillRectIndexBuffer(GrGpu* gpu); |
81 | 84 |
82 static int aaStrokeRectIndexCount(); | 85 static int aaStrokeRectIndexCount(bool miterStroke); |
83 GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu); | 86 GrIndexBuffer* aaStrokeRectIndexBuffer(GrGpu* gpu, bool miterStroke); |
84 | 87 |
85 // TODO: Remove the useVertexCoverage boolean. Just use it all the time | 88 // TODO: Remove the useVertexCoverage boolean. Just use it all the time |
86 // since we now have a coverage vertex attribute | 89 // since we now have a coverage vertex attribute |
87 void geometryFillAARect(GrGpu* gpu, | 90 void geometryFillAARect(GrGpu* gpu, |
88 GrDrawTarget* target, | 91 GrDrawTarget* target, |
89 const SkRect& rect, | 92 const SkRect& rect, |
90 const SkMatrix& combinedMatrix, | 93 const SkMatrix& combinedMatrix, |
91 const SkRect& devRect, | 94 const SkRect& devRect, |
92 bool useVertexCoverage); | 95 bool useVertexCoverage); |
93 | 96 |
94 void shaderFillAARect(GrGpu* gpu, | 97 void shaderFillAARect(GrGpu* gpu, |
95 GrDrawTarget* target, | 98 GrDrawTarget* target, |
96 const SkRect& rect, | 99 const SkRect& rect, |
97 const SkMatrix& combinedMatrix); | 100 const SkMatrix& combinedMatrix); |
98 | 101 |
99 void shaderFillAlignedAARect(GrGpu* gpu, | 102 void shaderFillAlignedAARect(GrGpu* gpu, |
100 GrDrawTarget* target, | 103 GrDrawTarget* target, |
101 const SkRect& rect, | 104 const SkRect& rect, |
102 const SkMatrix& combinedMatrix); | 105 const SkMatrix& combinedMatrix); |
103 | 106 |
104 void geometryStrokeAARect(GrGpu* gpu, | 107 void geometryStrokeAARect(GrGpu* gpu, |
105 GrDrawTarget* target, | 108 GrDrawTarget* target, |
106 const SkRect& devOutside, | 109 const SkRect& devOutside, |
| 110 const SkRect& devOutsideAssist, |
107 const SkRect& devInside, | 111 const SkRect& devInside, |
108 bool useVertexCoverage); | 112 bool useVertexCoverage, |
| 113 bool miterStroke); |
109 | 114 |
110 typedef SkRefCnt INHERITED; | 115 typedef SkRefCnt INHERITED; |
111 }; | 116 }; |
112 | 117 |
113 #endif // GrAARectRenderer_DEFINED | 118 #endif // GrAARectRenderer_DEFINED |
OLD | NEW |