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 | 7 |
8 #include "GrDefaultPathRenderer.h" | 8 #include "GrDefaultPathRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 : fSeparateStencil(separateStencilSupport) | 28 : fSeparateStencil(separateStencilSupport) |
29 , fStencilWrapOps(stencilWrapOpsSupport) { | 29 , fStencilWrapOps(stencilWrapOpsSupport) { |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
34 // Stencil rules for paths | 34 // Stencil rules for paths |
35 | 35 |
36 ////// Even/Odd | 36 ////// Even/Odd |
37 | 37 |
38 GR_STATIC_CONST_SAME_STENCIL(gEOStencilPass, | 38 static constexpr GrStencilSettings gEOStencilPass( |
39 kInvert_StencilOp, | 39 kInvert_StencilOp, |
40 kKeep_StencilOp, | 40 kKeep_StencilOp, |
41 kAlwaysIfInClip_StencilFunc, | 41 kAlwaysIfInClip_StencilFunc, |
42 0xffff, | 42 0xffff, |
43 0xffff, | 43 0xffff, |
44 0xffff); | 44 0xffff); |
45 | 45 |
46 // ok not to check clip b/c stencil pass only wrote inside clip | 46 // ok not to check clip b/c stencil pass only wrote inside clip |
47 GR_STATIC_CONST_SAME_STENCIL(gEOColorPass, | 47 static constexpr GrStencilSettings gEOColorPass( |
48 kZero_StencilOp, | 48 kZero_StencilOp, |
49 kZero_StencilOp, | 49 kZero_StencilOp, |
50 kNotEqual_StencilFunc, | 50 kNotEqual_StencilFunc, |
51 0xffff, | 51 0xffff, |
52 0x0000, | 52 0x0000, |
53 0xffff); | 53 0xffff); |
54 | 54 |
55 // have to check clip b/c outside clip will always be zero. | 55 // have to check clip b/c outside clip will always be zero. |
56 GR_STATIC_CONST_SAME_STENCIL(gInvEOColorPass, | 56 static constexpr GrStencilSettings gInvEOColorPass( |
57 kZero_StencilOp, | 57 kZero_StencilOp, |
58 kZero_StencilOp, | 58 kZero_StencilOp, |
59 kEqualIfInClip_StencilFunc, | 59 kEqualIfInClip_StencilFunc, |
60 0xffff, | 60 0xffff, |
61 0x0000, | 61 0x0000, |
62 0xffff); | 62 0xffff); |
63 | 63 |
64 ////// Winding | 64 ////// Winding |
65 | 65 |
66 // when we have separate stencil we increment front faces / decrement back faces | 66 // when we have separate stencil we increment front faces / decrement back faces |
67 // when we don't have wrap incr and decr we use the stencil test to simulate | 67 // when we don't have wrap incr and decr we use the stencil test to simulate |
68 // them. | 68 // them. |
69 | 69 |
70 GR_STATIC_CONST_STENCIL(gWindStencilSeparateWithWrap, | 70 static constexpr GrStencilSettings gWindStencilSeparateWithWrap( |
71 kIncWrap_StencilOp, kDecWrap_StencilOp, | 71 kIncWrap_StencilOp, kDecWrap_StencilOp, |
72 kKeep_StencilOp, kKeep_StencilOp, | 72 kKeep_StencilOp, kKeep_StencilOp, |
73 kAlwaysIfInClip_StencilFunc, kAlwaysIfInClip_StencilFunc, | 73 kAlwaysIfInClip_StencilFunc, kAlwaysIfInClip_StencilFunc, |
74 0xffff, 0xffff, | 74 0xffff, 0xffff, |
75 0xffff, 0xffff, | 75 0xffff, 0xffff, |
76 0xffff, 0xffff); | 76 0xffff, 0xffff); |
77 | 77 |
78 // if inc'ing the max value, invert to make 0 | 78 // if inc'ing the max value, invert to make 0 |
79 // if dec'ing zero invert to make all ones. | 79 // if dec'ing zero invert to make all ones. |
80 // we can't avoid touching the stencil on both passing and | 80 // we can't avoid touching the stencil on both passing and |
81 // failing, so we can't resctrict ourselves to the clip. | 81 // failing, so we can't resctrict ourselves to the clip. |
82 GR_STATIC_CONST_STENCIL(gWindStencilSeparateNoWrap, | 82 static constexpr GrStencilSettings gWindStencilSeparateNoWrap( |
83 kInvert_StencilOp, kInvert_StencilOp, | 83 kInvert_StencilOp, kInvert_StencilOp, |
84 kIncClamp_StencilOp, kDecClamp_StencilOp, | 84 kIncClamp_StencilOp, kDecClamp_StencilOp, |
85 kEqual_StencilFunc, kEqual_StencilFunc, | 85 kEqual_StencilFunc, kEqual_StencilFunc, |
86 0xffff, 0xffff, | 86 0xffff, 0xffff, |
87 0xffff, 0x0000, | 87 0xffff, 0x0000, |
88 0xffff, 0xffff); | 88 0xffff, 0xffff); |
89 | 89 |
90 // When there are no separate faces we do two passes to setup the winding rule | 90 // When there are no separate faces we do two passes to setup the winding rule |
91 // stencil. First we draw the front faces and inc, then we draw the back faces | 91 // stencil. First we draw the front faces and inc, then we draw the back faces |
92 // and dec. These are same as the above two split into the incrementing and | 92 // and dec. These are same as the above two split into the incrementing and |
93 // decrementing passes. | 93 // decrementing passes. |
94 GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilWithWrapInc, | 94 static constexpr GrStencilSettings gWindSingleStencilWithWrapInc( |
95 kIncWrap_StencilOp, | 95 kIncWrap_StencilOp, |
96 kKeep_StencilOp, | 96 kKeep_StencilOp, |
97 kAlwaysIfInClip_StencilFunc, | 97 kAlwaysIfInClip_StencilFunc, |
98 0xffff, | 98 0xffff, |
99 0xffff, | 99 0xffff, |
100 0xffff); | 100 0xffff); |
101 | 101 |
102 GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilWithWrapDec, | 102 static constexpr GrStencilSettings gWindSingleStencilWithWrapDec( |
103 kDecWrap_StencilOp, | 103 kDecWrap_StencilOp, |
104 kKeep_StencilOp, | 104 kKeep_StencilOp, |
105 kAlwaysIfInClip_StencilFunc, | 105 kAlwaysIfInClip_StencilFunc, |
106 0xffff, | 106 0xffff, |
107 0xffff, | 107 0xffff, |
108 0xffff); | 108 0xffff); |
109 | 109 |
110 GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilNoWrapInc, | 110 static constexpr GrStencilSettings gWindSingleStencilNoWrapInc( |
111 kInvert_StencilOp, | 111 kInvert_StencilOp, |
112 kIncClamp_StencilOp, | 112 kIncClamp_StencilOp, |
113 kEqual_StencilFunc, | 113 kEqual_StencilFunc, |
114 0xffff, | 114 0xffff, |
115 0xffff, | 115 0xffff, |
116 0xffff); | 116 0xffff); |
117 | 117 |
118 GR_STATIC_CONST_SAME_STENCIL(gWindSingleStencilNoWrapDec, | 118 static constexpr GrStencilSettings gWindSingleStencilNoWrapDec( |
119 kInvert_StencilOp, | 119 kInvert_StencilOp, |
120 kDecClamp_StencilOp, | 120 kDecClamp_StencilOp, |
121 kEqual_StencilFunc, | 121 kEqual_StencilFunc, |
122 0xffff, | 122 0xffff, |
123 0x0000, | 123 0x0000, |
124 0xffff); | 124 0xffff); |
125 | 125 |
126 // Color passes are the same whether we use the two-sided stencil or two passes | 126 // Color passes are the same whether we use the two-sided stencil or two passes |
127 | 127 |
128 GR_STATIC_CONST_SAME_STENCIL(gWindColorPass, | 128 static constexpr GrStencilSettings gWindColorPass( |
129 kZero_StencilOp, | 129 kZero_StencilOp, |
130 kZero_StencilOp, | 130 kZero_StencilOp, |
131 kNonZeroIfInClip_StencilFunc, | 131 kNonZeroIfInClip_StencilFunc, |
132 0xffff, | 132 0xffff, |
133 0x0000, | 133 0x0000, |
134 0xffff); | 134 0xffff); |
135 | 135 |
136 GR_STATIC_CONST_SAME_STENCIL(gInvWindColorPass, | 136 static constexpr GrStencilSettings gInvWindColorPass( |
137 kZero_StencilOp, | 137 kZero_StencilOp, |
138 kZero_StencilOp, | 138 kZero_StencilOp, |
139 kEqualIfInClip_StencilFunc, | 139 kEqualIfInClip_StencilFunc, |
140 0xffff, | 140 0xffff, |
141 0x0000, | 141 0x0000, |
142 0xffff); | 142 0xffff); |
143 | 143 |
144 ////// Normal render to stencil | 144 ////// Normal render to stencil |
145 | 145 |
146 // Sometimes the default path renderer can draw a path directly to the stencil | 146 // Sometimes the default path renderer can draw a path directly to the stencil |
147 // buffer without having to first resolve the interior / exterior. | 147 // buffer without having to first resolve the interior / exterior. |
148 GR_STATIC_CONST_SAME_STENCIL(gDirectToStencil, | 148 static constexpr GrStencilSettings gDirectToStencil( |
149 kZero_StencilOp, | 149 kZero_StencilOp, |
150 kIncClamp_StencilOp, | 150 kIncClamp_StencilOp, |
151 kAlwaysIfInClip_StencilFunc, | 151 kAlwaysIfInClip_StencilFunc, |
152 0xffff, | 152 0xffff, |
153 0x0000, | 153 0x0000, |
154 0xffff); | 154 0xffff); |
155 | 155 |
156 //////////////////////////////////////////////////////////////////////////////// | 156 //////////////////////////////////////////////////////////////////////////////// |
157 // Helpers for drawPath | 157 // Helpers for drawPath |
158 | 158 |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 geometry.fColor = color; | 767 geometry.fColor = color; |
768 geometry.fPath = path; | 768 geometry.fPath = path; |
769 geometry.fTolerance = srcSpaceTol; | 769 geometry.fTolerance = srcSpaceTol; |
770 | 770 |
771 viewMatrix.mapRect(&bounds); | 771 viewMatrix.mapRect(&bounds); |
772 uint8_t coverage = GrRandomCoverage(random); | 772 uint8_t coverage = GrRandomCoverage(random); |
773 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); | 773 return DefaultPathBatch::Create(geometry, coverage, viewMatrix, true, bounds
); |
774 } | 774 } |
775 | 775 |
776 #endif | 776 #endif |
OLD | NEW |