OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrBezierEffect_DEFINED | 8 #ifndef GrBezierEffect_DEFINED |
9 #define GrBezierEffect_DEFINED | 9 #define GrBezierEffect_DEFINED |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 * that the curves become much thinner and "ropey". If all that was ever rendere
d | 52 * that the curves become much thinner and "ropey". If all that was ever rendere
d |
53 * were "not too thin" curves and ellipses then 2nd order may have an advantage
since | 53 * were "not too thin" curves and ellipses then 2nd order may have an advantage
since |
54 * only one geometry would need to be rendered. However no benches were run comp
aring | 54 * only one geometry would need to be rendered. However no benches were run comp
aring |
55 * chopped first order and non chopped 2nd order. | 55 * chopped first order and non chopped 2nd order. |
56 */ | 56 */ |
57 class GrGLConicEffect; | 57 class GrGLConicEffect; |
58 | 58 |
59 class GrConicEffect : public GrGeometryProcessor { | 59 class GrConicEffect : public GrGeometryProcessor { |
60 public: | 60 public: |
61 static GrGeometryProcessor* Create(GrColor color, | 61 static GrGeometryProcessor* Create(GrColor color, |
| 62 const SkMatrix& viewMatrix, |
62 const GrPrimitiveEdgeType edgeType, | 63 const GrPrimitiveEdgeType edgeType, |
63 const GrDrawTargetCaps& caps, | 64 const GrDrawTargetCaps& caps, |
64 const SkMatrix& localMatrix, | 65 const SkMatrix& localMatrix, |
65 uint8_t coverage = 0xff) { | 66 uint8_t coverage = 0xff) { |
66 switch (edgeType) { | 67 switch (edgeType) { |
67 case kFillAA_GrProcessorEdgeType: | 68 case kFillAA_GrProcessorEdgeType: |
68 if (!caps.shaderDerivativeSupport()) { | 69 if (!caps.shaderDerivativeSupport()) { |
69 return NULL; | 70 return NULL; |
70 } | 71 } |
71 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillAA_GrPro
cessorEdgeType, | 72 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
| 73 kFillAA_GrProcessorEdgeType, |
72 localMatrix)); | 74 localMatrix)); |
73 case kHairlineAA_GrProcessorEdgeType: | 75 case kHairlineAA_GrProcessorEdgeType: |
74 if (!caps.shaderDerivativeSupport()) { | 76 if (!caps.shaderDerivativeSupport()) { |
75 return NULL; | 77 return NULL; |
76 } | 78 } |
77 return SkNEW_ARGS(GrConicEffect, (color, coverage, | 79 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
78 kHairlineAA_GrProcessorEdgeTyp
e, | 80 kHairlineAA_GrProcessorEdgeTyp
e, |
79 localMatrix)); | 81 localMatrix)); |
80 case kFillBW_GrProcessorEdgeType: | 82 case kFillBW_GrProcessorEdgeType: |
81 return SkNEW_ARGS(GrConicEffect, (color, coverage, kFillBW_GrPro
cessorEdgeType, | 83 return SkNEW_ARGS(GrConicEffect, (color, viewMatrix, coverage, |
| 84 kFillBW_GrProcessorEdgeType, |
82 localMatrix)); | 85 localMatrix)); |
83 default: | 86 default: |
84 return NULL; | 87 return NULL; |
85 } | 88 } |
86 } | 89 } |
87 | 90 |
88 virtual ~GrConicEffect(); | 91 virtual ~GrConicEffect(); |
89 | 92 |
90 virtual const char* name() const SK_OVERRIDE { return "Conic"; } | 93 virtual const char* name() const SK_OVERRIDE { return "Conic"; } |
91 | 94 |
92 inline const GrAttribute* inPosition() const { return fInPosition; } | 95 inline const GrAttribute* inPosition() const { return fInPosition; } |
93 inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; } | 96 inline const GrAttribute* inConicCoeffs() const { return fInConicCoeffs; } |
94 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 97 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
95 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 98 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
96 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 99 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
97 | 100 |
98 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 101 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
99 const GrGLCaps& caps, | 102 const GrGLCaps& caps, |
100 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 103 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
101 | 104 |
102 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 105 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
103 | 106 |
104 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; | 107 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; |
105 bool onCanMakeEqual(const GrBatchTracker&, | 108 bool onCanMakeEqual(const GrBatchTracker&, |
106 const GrGeometryProcessor&, | 109 const GrGeometryProcessor&, |
107 const GrBatchTracker&) const SK_OVERRIDE; | 110 const GrBatchTracker&) const SK_OVERRIDE; |
108 | 111 |
109 private: | 112 private: |
110 GrConicEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType, const SkMatrix
& localMatrix); | 113 GrConicEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimi
tiveEdgeType, |
| 114 const SkMatrix& localMatrix); |
111 | 115 |
112 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 116 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
113 | 117 |
114 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 118 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
115 out->setUnknownSingleComponent(); | 119 out->setUnknownSingleComponent(); |
116 } | 120 } |
117 | 121 |
118 uint8_t fCoverageScale; | 122 uint8_t fCoverageScale; |
119 GrPrimitiveEdgeType fEdgeType; | 123 GrPrimitiveEdgeType fEdgeType; |
120 const GrAttribute* fInPosition; | 124 const GrAttribute* fInPosition; |
(...skipping 11 matching lines...) Expand all Loading... |
132 * two components of the vertex attribute. At the three control points that defi
ne | 136 * two components of the vertex attribute. At the three control points that defi
ne |
133 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. | 137 * the Quadratic, u, v have the values {0,0}, {1/2, 0}, and {1, 1} respectively. |
134 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. | 138 * Coverage for AA is min(0, 1-distance). 3rd & 4th cimponent unused. |
135 * Requires shader derivative instruction support. | 139 * Requires shader derivative instruction support. |
136 */ | 140 */ |
137 class GrGLQuadEffect; | 141 class GrGLQuadEffect; |
138 | 142 |
139 class GrQuadEffect : public GrGeometryProcessor { | 143 class GrQuadEffect : public GrGeometryProcessor { |
140 public: | 144 public: |
141 static GrGeometryProcessor* Create(GrColor color, | 145 static GrGeometryProcessor* Create(GrColor color, |
| 146 const SkMatrix& viewMatrix, |
142 const GrPrimitiveEdgeType edgeType, | 147 const GrPrimitiveEdgeType edgeType, |
143 const GrDrawTargetCaps& caps, | 148 const GrDrawTargetCaps& caps, |
144 const SkMatrix& localMatrix, | 149 const SkMatrix& localMatrix, |
145 uint8_t coverage = 0xff) { | 150 uint8_t coverage = 0xff) { |
146 switch (edgeType) { | 151 switch (edgeType) { |
147 case kFillAA_GrProcessorEdgeType: | 152 case kFillAA_GrProcessorEdgeType: |
148 if (!caps.shaderDerivativeSupport()) { | 153 if (!caps.shaderDerivativeSupport()) { |
149 return NULL; | 154 return NULL; |
150 } | 155 } |
151 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillAA_GrProc
essorEdgeType, | 156 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 157 kFillAA_GrProcessorEdgeType, |
152 localMatrix)); | 158 localMatrix)); |
153 case kHairlineAA_GrProcessorEdgeType: | 159 case kHairlineAA_GrProcessorEdgeType: |
154 if (!caps.shaderDerivativeSupport()) { | 160 if (!caps.shaderDerivativeSupport()) { |
155 return NULL; | 161 return NULL; |
156 } | 162 } |
157 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kHairlineAA_Gr
ProcessorEdgeType, | 163 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 164 kHairlineAA_GrProcessorEdgeType
, |
158 localMatrix)); | 165 localMatrix)); |
159 case kFillBW_GrProcessorEdgeType: | 166 case kFillBW_GrProcessorEdgeType: |
160 return SkNEW_ARGS(GrQuadEffect, (color, coverage, kFillBW_GrProc
essorEdgeType, | 167 return SkNEW_ARGS(GrQuadEffect, (color, viewMatrix, coverage, |
| 168 kFillBW_GrProcessorEdgeType, |
161 localMatrix)); | 169 localMatrix)); |
162 default: | 170 default: |
163 return NULL; | 171 return NULL; |
164 } | 172 } |
165 } | 173 } |
166 | 174 |
167 virtual ~GrQuadEffect(); | 175 virtual ~GrQuadEffect(); |
168 | 176 |
169 virtual const char* name() const SK_OVERRIDE { return "Quad"; } | 177 virtual const char* name() const SK_OVERRIDE { return "Quad"; } |
170 | 178 |
171 inline const GrAttribute* inPosition() const { return fInPosition; } | 179 inline const GrAttribute* inPosition() const { return fInPosition; } |
172 inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; } | 180 inline const GrAttribute* inHairQuadEdge() const { return fInHairQuadEdge; } |
173 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 181 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
174 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 182 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
175 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 183 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
176 | 184 |
177 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 185 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
178 const GrGLCaps& caps, | 186 const GrGLCaps& caps, |
179 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 187 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
180 | 188 |
181 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 189 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
182 | 190 |
183 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; | 191 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; |
184 bool onCanMakeEqual(const GrBatchTracker&, | 192 bool onCanMakeEqual(const GrBatchTracker&, |
185 const GrGeometryProcessor&, | 193 const GrGeometryProcessor&, |
186 const GrBatchTracker&) const SK_OVERRIDE; | 194 const GrBatchTracker&) const SK_OVERRIDE; |
187 | 195 |
188 private: | 196 private: |
189 GrQuadEffect(GrColor, uint8_t coverage, GrPrimitiveEdgeType, const SkMatrix&
localMatrix); | 197 GrQuadEffect(GrColor, const SkMatrix& viewMatrix, uint8_t coverage, GrPrimit
iveEdgeType, |
| 198 const SkMatrix& localMatrix); |
190 | 199 |
191 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 200 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
192 | 201 |
193 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 202 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
194 out->setUnknownSingleComponent(); | 203 out->setUnknownSingleComponent(); |
195 } | 204 } |
196 | 205 |
197 uint8_t fCoverageScale; | 206 uint8_t fCoverageScale; |
198 GrPrimitiveEdgeType fEdgeType; | 207 GrPrimitiveEdgeType fEdgeType; |
199 const GrAttribute* fInPosition; | 208 const GrAttribute* fInPosition; |
(...skipping 13 matching lines...) Expand all Loading... |
213 * K, L, and M, are the first three values of the vertex attribute, | 222 * K, L, and M, are the first three values of the vertex attribute, |
214 * the fourth value is not used. Distance is calculated using a | 223 * the fourth value is not used. Distance is calculated using a |
215 * first order approximation from the taylor series. | 224 * first order approximation from the taylor series. |
216 * Coverage for AA is max(0, 1-distance). | 225 * Coverage for AA is max(0, 1-distance). |
217 */ | 226 */ |
218 class GrGLCubicEffect; | 227 class GrGLCubicEffect; |
219 | 228 |
220 class GrCubicEffect : public GrGeometryProcessor { | 229 class GrCubicEffect : public GrGeometryProcessor { |
221 public: | 230 public: |
222 static GrGeometryProcessor* Create(GrColor color, | 231 static GrGeometryProcessor* Create(GrColor color, |
| 232 const SkMatrix& viewMatrix, |
223 const GrPrimitiveEdgeType edgeType, | 233 const GrPrimitiveEdgeType edgeType, |
224 const GrDrawTargetCaps& caps) { | 234 const GrDrawTargetCaps& caps) { |
225 switch (edgeType) { | 235 switch (edgeType) { |
226 case kFillAA_GrProcessorEdgeType: | 236 case kFillAA_GrProcessorEdgeType: |
227 if (!caps.shaderDerivativeSupport()) { | 237 if (!caps.shaderDerivativeSupport()) { |
228 return NULL; | 238 return NULL; |
229 } | 239 } |
230 return SkNEW_ARGS(GrCubicEffect, (color, kFillAA_GrProcessorEdge
Type)); | 240 return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix, kFillAA_GrP
rocessorEdgeType)); |
231 case kHairlineAA_GrProcessorEdgeType: | 241 case kHairlineAA_GrProcessorEdgeType: |
232 if (!caps.shaderDerivativeSupport()) { | 242 if (!caps.shaderDerivativeSupport()) { |
233 return NULL; | 243 return NULL; |
234 } | 244 } |
235 return SkNEW_ARGS(GrCubicEffect, (color, kHairlineAA_GrProcessor
EdgeType)); | 245 return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix, |
| 246 kHairlineAA_GrProcessorEdgeTyp
e)); |
236 case kFillBW_GrProcessorEdgeType: | 247 case kFillBW_GrProcessorEdgeType: |
237 return SkNEW_ARGS(GrCubicEffect, (color, kFillBW_GrProcessorEdge
Type)); | 248 return SkNEW_ARGS(GrCubicEffect, (color, viewMatrix, |
| 249 kFillBW_GrProcessorEdgeType)); |
238 default: | 250 default: |
239 return NULL; | 251 return NULL; |
240 } | 252 } |
241 } | 253 } |
242 | 254 |
243 virtual ~GrCubicEffect(); | 255 virtual ~GrCubicEffect(); |
244 | 256 |
245 virtual const char* name() const SK_OVERRIDE { return "Cubic"; } | 257 virtual const char* name() const SK_OVERRIDE { return "Cubic"; } |
246 | 258 |
247 inline const GrAttribute* inPosition() const { return fInPosition; } | 259 inline const GrAttribute* inPosition() const { return fInPosition; } |
248 inline const GrAttribute* inCubicCoeffs() const { return fInCubicCoeffs; } | 260 inline const GrAttribute* inCubicCoeffs() const { return fInCubicCoeffs; } |
249 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } | 261 inline bool isAntiAliased() const { return GrProcessorEdgeTypeIsAA(fEdgeType
); } |
250 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} | 262 inline bool isFilled() const { return GrProcessorEdgeTypeIsFill(fEdgeType);
} |
251 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } | 263 inline GrPrimitiveEdgeType getEdgeType() const { return fEdgeType; } |
252 | 264 |
253 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 265 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
254 const GrGLCaps& caps, | 266 const GrGLCaps& caps, |
255 GrProcessorKeyBuilder* b) const SK_OVERRIDE; | 267 GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
256 | 268 |
257 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; | 269 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE; |
258 | 270 |
259 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; | 271 void initBatchTracker(GrBatchTracker*, const InitBT&) const SK_OVERRIDE; |
260 bool onCanMakeEqual(const GrBatchTracker&, | 272 bool onCanMakeEqual(const GrBatchTracker&, |
261 const GrGeometryProcessor&, | 273 const GrGeometryProcessor&, |
262 const GrBatchTracker&) const SK_OVERRIDE; | 274 const GrBatchTracker&) const SK_OVERRIDE; |
263 | 275 |
264 private: | 276 private: |
265 GrCubicEffect(GrColor, GrPrimitiveEdgeType); | 277 GrCubicEffect(GrColor, const SkMatrix& viewMatrix, GrPrimitiveEdgeType); |
266 | 278 |
267 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; | 279 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE; |
268 | 280 |
269 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 281 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { |
270 out->setUnknownSingleComponent(); | 282 out->setUnknownSingleComponent(); |
271 } | 283 } |
272 | 284 |
273 GrPrimitiveEdgeType fEdgeType; | 285 GrPrimitiveEdgeType fEdgeType; |
274 const GrAttribute* fInPosition; | 286 const GrAttribute* fInPosition; |
275 const GrAttribute* fInCubicCoeffs; | 287 const GrAttribute* fInCubicCoeffs; |
276 | 288 |
277 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 289 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
278 | 290 |
279 typedef GrGeometryProcessor INHERITED; | 291 typedef GrGeometryProcessor INHERITED; |
280 }; | 292 }; |
281 | 293 |
282 #endif | 294 #endif |
OLD | NEW |