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