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 #include "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
9 #include "GrBezierEffect.h" | 9 #include "GrBezierEffect.h" |
10 | 10 |
11 #include "gl/GrGLEffect.h" | 11 #include "gl/GrGLEffect.h" |
12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
13 #include "gl/GrGLVertexEffect.h" | 13 #include "gl/GrGLGeometryProcessor.h" |
14 #include "GrTBackendEffectFactory.h" | 14 #include "GrTBackendEffectFactory.h" |
15 | 15 |
16 class GrGLConicEffect : public GrGLVertexEffect { | 16 // Shader variable local constants |
| 17 const GrShaderVar kAttrConicCoeffs("aConicCoeffs", |
| 18 kVec4f_GrSLType, |
| 19 GrShaderVar::kAttribute_TypeModifier); |
| 20 |
| 21 class GrGLConicEffect : public GrGLGeometryProcessor { |
17 public: | 22 public: |
18 GrGLConicEffect(const GrBackendEffectFactory&, const GrDrawEffect&); | 23 GrGLConicEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
19 | 24 |
20 virtual void emitCode(GrGLFullProgramBuilder* builder, | 25 virtual void emitCode(GrGLFullProgramBuilder* builder, |
21 const GrDrawEffect& drawEffect, | 26 const GrDrawEffect& drawEffect, |
22 const GrEffectKey& key, | 27 const GrEffectKey& key, |
23 const char* outputColor, | 28 const char* outputColor, |
24 const char* inputColor, | 29 const char* inputColor, |
25 const TransformedCoordsArray&, | 30 const TransformedCoordsArray&, |
26 const TextureSamplerArray&) SK_OVERRIDE; | 31 const TextureSamplerArray&) SK_OVERRIDE; |
27 | 32 |
28 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); | 33 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); |
29 | 34 |
30 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE {} | 35 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE {} |
31 | 36 |
32 private: | 37 private: |
33 GrEffectEdgeType fEdgeType; | 38 GrEffectEdgeType fEdgeType; |
34 | 39 |
35 typedef GrGLVertexEffect INHERITED; | 40 typedef GrGLGeometryProcessor INHERITED; |
36 }; | 41 }; |
37 | 42 |
38 GrGLConicEffect::GrGLConicEffect(const GrBackendEffectFactory& factory, | 43 GrGLConicEffect::GrGLConicEffect(const GrBackendEffectFactory& factory, |
39 const GrDrawEffect& drawEffect) | 44 const GrDrawEffect& drawEffect) |
40 : INHERITED (factory) { | 45 : INHERITED (factory) { |
41 const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>(); | 46 const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>(); |
42 fEdgeType = ce.getEdgeType(); | 47 fEdgeType = ce.getEdgeType(); |
43 } | 48 } |
44 | 49 |
45 void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder, | 50 void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder, |
46 const GrDrawEffect& drawEffect, | 51 const GrDrawEffect& drawEffect, |
47 const GrEffectKey& key, | 52 const GrEffectKey& key, |
48 const char* outputColor, | 53 const char* outputColor, |
49 const char* inputColor, | 54 const char* inputColor, |
50 const TransformedCoordsArray&, | 55 const TransformedCoordsArray&, |
51 const TextureSamplerArray& samplers) { | 56 const TextureSamplerArray& samplers) { |
52 const char *vsName, *fsName; | 57 const char *vsName, *fsName; |
53 | 58 |
54 builder->addVarying(kVec4f_GrSLType, "ConicCoeffs", | 59 builder->addVarying(kVec4f_GrSLType, "ConicCoeffs", |
55 &vsName, &fsName); | 60 &vsName, &fsName); |
56 | 61 |
57 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); | 62 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); |
58 const SkString* attr0Name = | 63 vsBuilder->codeAppendf("%s = %s;", vsName, kAttrConicCoeffs.c_str()); |
59 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]
); | |
60 vsBuilder->codeAppendf("%s = %s;", vsName, attr0Name->c_str()); | |
61 | 64 |
62 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 65 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
63 fsBuilder->codeAppend("float edgeAlpha;"); | 66 fsBuilder->codeAppend("float edgeAlpha;"); |
64 | 67 |
65 switch (fEdgeType) { | 68 switch (fEdgeType) { |
66 case kHairlineAA_GrEffectEdgeType: { | 69 case kHairlineAA_GrEffectEdgeType: { |
67 SkAssertResult(fsBuilder->enableFeature( | 70 SkAssertResult(fsBuilder->enableFeature( |
68 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 71 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
69 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName); | 72 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName); |
70 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName); | 73 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 131 } |
129 | 132 |
130 ////////////////////////////////////////////////////////////////////////////// | 133 ////////////////////////////////////////////////////////////////////////////// |
131 | 134 |
132 GrConicEffect::~GrConicEffect() {} | 135 GrConicEffect::~GrConicEffect() {} |
133 | 136 |
134 const GrBackendEffectFactory& GrConicEffect::getFactory() const { | 137 const GrBackendEffectFactory& GrConicEffect::getFactory() const { |
135 return GrTBackendEffectFactory<GrConicEffect>::getInstance(); | 138 return GrTBackendEffectFactory<GrConicEffect>::getInstance(); |
136 } | 139 } |
137 | 140 |
138 GrConicEffect::GrConicEffect(GrEffectEdgeType edgeType) : GrVertexEffect() { | 141 GrConicEffect::GrConicEffect(GrEffectEdgeType edgeType) : GrGeometryProcessor()
{ |
139 this->addVertexAttrib(kVec4f_GrSLType); | 142 this->addVertexAttrib(kAttrConicCoeffs); |
140 fEdgeType = edgeType; | 143 fEdgeType = edgeType; |
141 } | 144 } |
142 | 145 |
143 bool GrConicEffect::onIsEqual(const GrEffect& other) const { | 146 bool GrConicEffect::onIsEqual(const GrEffect& other) const { |
144 const GrConicEffect& ce = CastEffect<GrConicEffect>(other); | 147 const GrConicEffect& ce = CastEffect<GrConicEffect>(other); |
145 return (ce.fEdgeType == fEdgeType); | 148 return (ce.fEdgeType == fEdgeType); |
146 } | 149 } |
147 | 150 |
148 ////////////////////////////////////////////////////////////////////////////// | 151 ////////////////////////////////////////////////////////////////////////////// |
149 | 152 |
150 GR_DEFINE_EFFECT_TEST(GrConicEffect); | 153 GR_DEFINE_EFFECT_TEST(GrConicEffect); |
151 | 154 |
152 GrEffect* GrConicEffect::TestCreate(SkRandom* random, | 155 GrEffect* GrConicEffect::TestCreate(SkRandom* random, |
153 GrContext*, | 156 GrContext*, |
154 const GrDrawTargetCaps& caps, | 157 const GrDrawTargetCaps& caps, |
155 GrTexture*[]) { | 158 GrTexture*[]) { |
156 GrEffect* effect; | 159 GrEffect* effect; |
157 do { | 160 do { |
158 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( | 161 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( |
159 random->nextULessThan(kGrEff
ectEdgeTypeCnt)); | 162 random->nextULessThan(kGrEff
ectEdgeTypeCnt)); |
160 effect = GrConicEffect::Create(edgeType, caps); | 163 effect = GrConicEffect::Create(edgeType, caps); |
161 } while (NULL == effect); | 164 } while (NULL == effect); |
162 return effect; | 165 return effect; |
163 } | 166 } |
164 | 167 |
165 ////////////////////////////////////////////////////////////////////////////// | 168 ////////////////////////////////////////////////////////////////////////////// |
166 // Quad | 169 // Quad |
167 ////////////////////////////////////////////////////////////////////////////// | 170 ////////////////////////////////////////////////////////////////////////////// |
168 | 171 |
169 class GrGLQuadEffect : public GrGLVertexEffect { | 172 const GrShaderVar kAttrHairQuadEdge("aHairQuadEdge", |
| 173 kVec4f_GrSLType, |
| 174 GrShaderVar::kAttribute_TypeModifier); |
| 175 |
| 176 class GrGLQuadEffect : public GrGLGeometryProcessor { |
170 public: | 177 public: |
171 GrGLQuadEffect(const GrBackendEffectFactory&, const GrDrawEffect&); | 178 GrGLQuadEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
172 | 179 |
173 virtual void emitCode(GrGLFullProgramBuilder* builder, | 180 virtual void emitCode(GrGLFullProgramBuilder* builder, |
174 const GrDrawEffect& drawEffect, | 181 const GrDrawEffect& drawEffect, |
175 const GrEffectKey& key, | 182 const GrEffectKey& key, |
176 const char* outputColor, | 183 const char* outputColor, |
177 const char* inputColor, | 184 const char* inputColor, |
178 const TransformedCoordsArray&, | 185 const TransformedCoordsArray&, |
179 const TextureSamplerArray&) SK_OVERRIDE; | 186 const TextureSamplerArray&) SK_OVERRIDE; |
180 | 187 |
181 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); | 188 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); |
182 | 189 |
183 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE {} | 190 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE {} |
184 | 191 |
185 private: | 192 private: |
186 GrEffectEdgeType fEdgeType; | 193 GrEffectEdgeType fEdgeType; |
187 | 194 |
188 typedef GrGLVertexEffect INHERITED; | 195 typedef GrGLGeometryProcessor INHERITED; |
189 }; | 196 }; |
190 | 197 |
191 GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory, | 198 GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory, |
192 const GrDrawEffect& drawEffect) | 199 const GrDrawEffect& drawEffect) |
193 : INHERITED (factory) { | 200 : INHERITED (factory) { |
194 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>(); | 201 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>(); |
195 fEdgeType = ce.getEdgeType(); | 202 fEdgeType = ce.getEdgeType(); |
196 } | 203 } |
197 | 204 |
198 void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder, | 205 void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder, |
199 const GrDrawEffect& drawEffect, | 206 const GrDrawEffect& drawEffect, |
200 const GrEffectKey& key, | 207 const GrEffectKey& key, |
201 const char* outputColor, | 208 const char* outputColor, |
202 const char* inputColor, | 209 const char* inputColor, |
203 const TransformedCoordsArray&, | 210 const TransformedCoordsArray&, |
204 const TextureSamplerArray& samplers) { | 211 const TextureSamplerArray& samplers) { |
205 const char *vsName, *fsName; | 212 const char *vsName, *fsName; |
206 builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName); | 213 builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName); |
207 | 214 |
208 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); | 215 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); |
209 const SkString* attrName = | 216 vsBuilder->codeAppendf("%s = %s;", vsName, kAttrHairQuadEdge.c_str()); |
210 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]
); | |
211 vsBuilder->codeAppendf("%s = %s;", vsName, attrName->c_str()); | |
212 | 217 |
213 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 218 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
214 fsBuilder->codeAppendf("float edgeAlpha;"); | 219 fsBuilder->codeAppendf("float edgeAlpha;"); |
215 | 220 |
216 switch (fEdgeType) { | 221 switch (fEdgeType) { |
217 case kHairlineAA_GrEffectEdgeType: { | 222 case kHairlineAA_GrEffectEdgeType: { |
218 SkAssertResult(fsBuilder->enableFeature( | 223 SkAssertResult(fsBuilder->enableFeature( |
219 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 224 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
220 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName); | 225 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName); |
221 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", fsName); | 226 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", fsName); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 } | 270 } |
266 | 271 |
267 ////////////////////////////////////////////////////////////////////////////// | 272 ////////////////////////////////////////////////////////////////////////////// |
268 | 273 |
269 GrQuadEffect::~GrQuadEffect() {} | 274 GrQuadEffect::~GrQuadEffect() {} |
270 | 275 |
271 const GrBackendEffectFactory& GrQuadEffect::getFactory() const { | 276 const GrBackendEffectFactory& GrQuadEffect::getFactory() const { |
272 return GrTBackendEffectFactory<GrQuadEffect>::getInstance(); | 277 return GrTBackendEffectFactory<GrQuadEffect>::getInstance(); |
273 } | 278 } |
274 | 279 |
275 GrQuadEffect::GrQuadEffect(GrEffectEdgeType edgeType) : GrVertexEffect() { | 280 GrQuadEffect::GrQuadEffect(GrEffectEdgeType edgeType) : GrGeometryProcessor() { |
276 this->addVertexAttrib(kVec4f_GrSLType); | 281 this->addVertexAttrib(kAttrHairQuadEdge); |
277 fEdgeType = edgeType; | 282 fEdgeType = edgeType; |
278 } | 283 } |
279 | 284 |
280 bool GrQuadEffect::onIsEqual(const GrEffect& other) const { | 285 bool GrQuadEffect::onIsEqual(const GrEffect& other) const { |
281 const GrQuadEffect& ce = CastEffect<GrQuadEffect>(other); | 286 const GrQuadEffect& ce = CastEffect<GrQuadEffect>(other); |
282 return (ce.fEdgeType == fEdgeType); | 287 return (ce.fEdgeType == fEdgeType); |
283 } | 288 } |
284 | 289 |
285 ////////////////////////////////////////////////////////////////////////////// | 290 ////////////////////////////////////////////////////////////////////////////// |
286 | 291 |
287 GR_DEFINE_EFFECT_TEST(GrQuadEffect); | 292 GR_DEFINE_EFFECT_TEST(GrQuadEffect); |
288 | 293 |
289 GrEffect* GrQuadEffect::TestCreate(SkRandom* random, | 294 GrEffect* GrQuadEffect::TestCreate(SkRandom* random, |
290 GrContext*, | 295 GrContext*, |
291 const GrDrawTargetCaps& caps, | 296 const GrDrawTargetCaps& caps, |
292 GrTexture*[]) { | 297 GrTexture*[]) { |
293 GrEffect* effect; | 298 GrEffect* effect; |
294 do { | 299 do { |
295 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( | 300 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( |
296 random->nextULessThan(kGrEff
ectEdgeTypeCnt)); | 301 random->nextULessThan(kGrEff
ectEdgeTypeCnt)); |
297 effect = GrQuadEffect::Create(edgeType, caps); | 302 effect = GrQuadEffect::Create(edgeType, caps); |
298 } while (NULL == effect); | 303 } while (NULL == effect); |
299 return effect; | 304 return effect; |
300 } | 305 } |
301 | 306 |
302 ////////////////////////////////////////////////////////////////////////////// | 307 ////////////////////////////////////////////////////////////////////////////// |
303 // Cubic | 308 // Cubic |
304 ////////////////////////////////////////////////////////////////////////////// | 309 ////////////////////////////////////////////////////////////////////////////// |
305 | 310 |
306 class GrGLCubicEffect : public GrGLVertexEffect { | 311 const GrShaderVar kAttrCubicCoeffs("aCubicCoeffs", |
| 312 kVec4f_GrSLType, |
| 313 GrShaderVar::kAttribute_TypeModifier); |
| 314 |
| 315 class GrGLCubicEffect : public GrGLGeometryProcessor { |
307 public: | 316 public: |
308 GrGLCubicEffect(const GrBackendEffectFactory&, const GrDrawEffect&); | 317 GrGLCubicEffect(const GrBackendEffectFactory&, const GrDrawEffect&); |
309 | 318 |
310 virtual void emitCode(GrGLFullProgramBuilder* builder, | 319 virtual void emitCode(GrGLFullProgramBuilder* builder, |
311 const GrDrawEffect& drawEffect, | 320 const GrDrawEffect& drawEffect, |
312 const GrEffectKey& key, | 321 const GrEffectKey& key, |
313 const char* outputColor, | 322 const char* outputColor, |
314 const char* inputColor, | 323 const char* inputColor, |
315 const TransformedCoordsArray&, | 324 const TransformedCoordsArray&, |
316 const TextureSamplerArray&) SK_OVERRIDE; | 325 const TextureSamplerArray&) SK_OVERRIDE; |
317 | 326 |
318 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); | 327 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB
uilder*); |
319 | 328 |
320 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE {} | 329 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE {} |
321 | 330 |
322 private: | 331 private: |
323 GrEffectEdgeType fEdgeType; | 332 GrEffectEdgeType fEdgeType; |
324 | 333 |
325 typedef GrGLVertexEffect INHERITED; | 334 typedef GrGLGeometryProcessor INHERITED; |
326 }; | 335 }; |
327 | 336 |
328 GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory, | 337 GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory, |
329 const GrDrawEffect& drawEffect) | 338 const GrDrawEffect& drawEffect) |
330 : INHERITED (factory) { | 339 : INHERITED (factory) { |
331 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>(); | 340 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>(); |
332 fEdgeType = ce.getEdgeType(); | 341 fEdgeType = ce.getEdgeType(); |
333 } | 342 } |
334 | 343 |
335 void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder, | 344 void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder, |
336 const GrDrawEffect& drawEffect, | 345 const GrDrawEffect& drawEffect, |
337 const GrEffectKey& key, | 346 const GrEffectKey& key, |
338 const char* outputColor, | 347 const char* outputColor, |
339 const char* inputColor, | 348 const char* inputColor, |
340 const TransformedCoordsArray&, | 349 const TransformedCoordsArray&, |
341 const TextureSamplerArray& samplers) { | 350 const TextureSamplerArray& samplers) { |
342 const char *vsName, *fsName; | 351 const char *vsName, *fsName; |
343 | 352 |
344 builder->addVarying(kVec4f_GrSLType, "CubicCoeffs", | 353 builder->addVarying(kVec4f_GrSLType, "CubicCoeffs", |
345 &vsName, &fsName, GrGLShaderVar::kHigh_Precision); | 354 &vsName, &fsName, GrGLShaderVar::kHigh_Precision); |
346 | 355 |
347 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); | 356 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); |
348 const SkString* attr0Name = | 357 vsBuilder->codeAppendf("%s = %s;", vsName, kAttrCubicCoeffs.c_str()); |
349 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0]
); | |
350 vsBuilder->codeAppendf("%s = %s;", vsName, attr0Name->c_str()); | |
351 | 358 |
352 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 359 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
353 | 360 |
354 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); | 361 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); |
355 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); | 362 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); |
356 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); | 363 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); |
357 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); | 364 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); |
358 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); | 365 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); |
359 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision); | 366 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision); |
360 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision)
; | 367 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision)
; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 451 } |
445 | 452 |
446 ////////////////////////////////////////////////////////////////////////////// | 453 ////////////////////////////////////////////////////////////////////////////// |
447 | 454 |
448 GrCubicEffect::~GrCubicEffect() {} | 455 GrCubicEffect::~GrCubicEffect() {} |
449 | 456 |
450 const GrBackendEffectFactory& GrCubicEffect::getFactory() const { | 457 const GrBackendEffectFactory& GrCubicEffect::getFactory() const { |
451 return GrTBackendEffectFactory<GrCubicEffect>::getInstance(); | 458 return GrTBackendEffectFactory<GrCubicEffect>::getInstance(); |
452 } | 459 } |
453 | 460 |
454 GrCubicEffect::GrCubicEffect(GrEffectEdgeType edgeType) : GrVertexEffect() { | 461 GrCubicEffect::GrCubicEffect(GrEffectEdgeType edgeType) : GrGeometryProcessor()
{ |
455 this->addVertexAttrib(kVec4f_GrSLType); | 462 this->addVertexAttrib(kAttrCubicCoeffs); |
456 fEdgeType = edgeType; | 463 fEdgeType = edgeType; |
457 } | 464 } |
458 | 465 |
459 bool GrCubicEffect::onIsEqual(const GrEffect& other) const { | 466 bool GrCubicEffect::onIsEqual(const GrEffect& other) const { |
460 const GrCubicEffect& ce = CastEffect<GrCubicEffect>(other); | 467 const GrCubicEffect& ce = CastEffect<GrCubicEffect>(other); |
461 return (ce.fEdgeType == fEdgeType); | 468 return (ce.fEdgeType == fEdgeType); |
462 } | 469 } |
463 | 470 |
464 ////////////////////////////////////////////////////////////////////////////// | 471 ////////////////////////////////////////////////////////////////////////////// |
465 | 472 |
466 GR_DEFINE_EFFECT_TEST(GrCubicEffect); | 473 GR_DEFINE_EFFECT_TEST(GrCubicEffect); |
467 | 474 |
468 GrEffect* GrCubicEffect::TestCreate(SkRandom* random, | 475 GrEffect* GrCubicEffect::TestCreate(SkRandom* random, |
469 GrContext*, | 476 GrContext*, |
470 const GrDrawTargetCaps& caps, | 477 const GrDrawTargetCaps& caps, |
471 GrTexture*[]) { | 478 GrTexture*[]) { |
472 GrEffect* effect; | 479 GrEffect* effect; |
473 do { | 480 do { |
474 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( | 481 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( |
475 random->nextULessThan(kGrEff
ectEdgeTypeCnt)); | 482 random->nextULessThan(kGrEff
ectEdgeTypeCnt)); |
476 effect = GrCubicEffect::Create(edgeType, caps); | 483 effect = GrCubicEffect::Create(edgeType, caps); |
477 } while (NULL == effect); | 484 } while (NULL == effect); |
478 return effect; | 485 return effect; |
479 } | 486 } |
480 | 487 |
OLD | NEW |