Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: src/gpu/effects/GrBezierEffect.cpp

Issue 543623004: Removing vertex attrib indices (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: warning fixed Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrBezierEffect.h ('k') | src/gpu/effects/GrCustomCoordsTextureEffect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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& inConicCoeffs = drawEffect.castEffect<GrConicEffect>().in ConicCoeffs();
57 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); 58 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
58 const SkString* attr0Name = 59 vsBuilder->codeAppendf("%s = %s;", vsName, inConicCoeffs.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
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 : fEdgeType(edgeType)
140 fEdgeType = edgeType; 139 , fInConicCoeffs(this->addVertexAttrib(GrShaderVar("inConicCoeffs",
140 kVec4f_GrSLType,
141 GrShaderVar::kAttribute_T ypeModifier))) {
141 } 142 }
142 143
143 bool GrConicEffect::onIsEqual(const GrEffect& other) const { 144 bool GrConicEffect::onIsEqual(const GrEffect& other) const {
144 const GrConicEffect& ce = CastEffect<GrConicEffect>(other); 145 const GrConicEffect& ce = CastEffect<GrConicEffect>(other);
145 return (ce.fEdgeType == fEdgeType); 146 return (ce.fEdgeType == fEdgeType);
146 } 147 }
147 148
148 ////////////////////////////////////////////////////////////////////////////// 149 //////////////////////////////////////////////////////////////////////////////
149 150
150 GR_DEFINE_EFFECT_TEST(GrConicEffect); 151 GR_DEFINE_EFFECT_TEST(GrConicEffect);
151 152
152 GrEffect* GrConicEffect::TestCreate(SkRandom* random, 153 GrEffect* GrConicEffect::TestCreate(SkRandom* random,
153 GrContext*, 154 GrContext*,
154 const GrDrawTargetCaps& caps, 155 const GrDrawTargetCaps& caps,
155 GrTexture*[]) { 156 GrTexture*[]) {
156 GrEffect* effect; 157 GrEffect* effect;
157 do { 158 do {
158 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( 159 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
159 random->nextULessThan(kGrEff ectEdgeTypeCnt)); 160 random->nextULessThan(kGrEff ectEdgeTypeCnt));
160 effect = GrConicEffect::Create(edgeType, caps); 161 effect = GrConicEffect::Create(edgeType, caps);
161 } while (NULL == effect); 162 } while (NULL == effect);
162 return effect; 163 return effect;
163 } 164 }
164 165
165 ////////////////////////////////////////////////////////////////////////////// 166 //////////////////////////////////////////////////////////////////////////////
166 // Quad 167 // Quad
167 ////////////////////////////////////////////////////////////////////////////// 168 //////////////////////////////////////////////////////////////////////////////
168 169
169 class GrGLQuadEffect : public GrGLVertexEffect { 170 class GrGLQuadEffect : public GrGLGeometryProcessor {
170 public: 171 public:
171 GrGLQuadEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 172 GrGLQuadEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
172 173
173 virtual void emitCode(GrGLFullProgramBuilder* builder, 174 virtual void emitCode(GrGLFullProgramBuilder* builder,
174 const GrDrawEffect& drawEffect, 175 const GrDrawEffect& drawEffect,
175 const GrEffectKey& key, 176 const GrEffectKey& key,
176 const char* outputColor, 177 const char* outputColor,
177 const char* inputColor, 178 const char* inputColor,
178 const TransformedCoordsArray&, 179 const TransformedCoordsArray&,
179 const TextureSamplerArray&) SK_OVERRIDE; 180 const TextureSamplerArray&) SK_OVERRIDE;
180 181
181 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*); 182 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*);
182 183
183 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE {} 184 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE {}
184 185
185 private: 186 private:
186 GrEffectEdgeType fEdgeType; 187 GrEffectEdgeType fEdgeType;
187 188
188 typedef GrGLVertexEffect INHERITED; 189 typedef GrGLGeometryProcessor INHERITED;
189 }; 190 };
190 191
191 GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory, 192 GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory,
192 const GrDrawEffect& drawEffect) 193 const GrDrawEffect& drawEffect)
193 : INHERITED (factory) { 194 : INHERITED (factory) {
194 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>(); 195 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>();
195 fEdgeType = ce.getEdgeType(); 196 fEdgeType = ce.getEdgeType();
196 } 197 }
197 198
198 void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder, 199 void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
199 const GrDrawEffect& drawEffect, 200 const GrDrawEffect& drawEffect,
200 const GrEffectKey& key, 201 const GrEffectKey& key,
201 const char* outputColor, 202 const char* outputColor,
202 const char* inputColor, 203 const char* inputColor,
203 const TransformedCoordsArray&, 204 const TransformedCoordsArray&,
204 const TextureSamplerArray& samplers) { 205 const TextureSamplerArray& samplers) {
205 const char *vsName, *fsName; 206 const char *vsName, *fsName;
206 builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName); 207 builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName);
207 208
208 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); 209 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
209 const SkString* attrName = 210 const GrShaderVar& inHairQuadEdge = drawEffect.castEffect<GrQuadEffect>().in HairQuadEdge();
210 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0] ); 211 vsBuilder->codeAppendf("%s = %s;", vsName, inHairQuadEdge.c_str());
211 vsBuilder->codeAppendf("%s = %s;", vsName, attrName->c_str());
212 212
213 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 213 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
214 fsBuilder->codeAppendf("float edgeAlpha;"); 214 fsBuilder->codeAppendf("float edgeAlpha;");
215 215
216 switch (fEdgeType) { 216 switch (fEdgeType) {
217 case kHairlineAA_GrEffectEdgeType: { 217 case kHairlineAA_GrEffectEdgeType: {
218 SkAssertResult(fsBuilder->enableFeature( 218 SkAssertResult(fsBuilder->enableFeature(
219 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 219 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
220 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName); 220 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName);
221 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", fsName); 221 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", fsName);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 265 }
266 266
267 ////////////////////////////////////////////////////////////////////////////// 267 //////////////////////////////////////////////////////////////////////////////
268 268
269 GrQuadEffect::~GrQuadEffect() {} 269 GrQuadEffect::~GrQuadEffect() {}
270 270
271 const GrBackendEffectFactory& GrQuadEffect::getFactory() const { 271 const GrBackendEffectFactory& GrQuadEffect::getFactory() const {
272 return GrTBackendEffectFactory<GrQuadEffect>::getInstance(); 272 return GrTBackendEffectFactory<GrQuadEffect>::getInstance();
273 } 273 }
274 274
275 GrQuadEffect::GrQuadEffect(GrEffectEdgeType edgeType) : GrVertexEffect() { 275 GrQuadEffect::GrQuadEffect(GrEffectEdgeType edgeType)
276 this->addVertexAttrib(kVec4f_GrSLType); 276 : fEdgeType(edgeType)
277 fEdgeType = edgeType; 277 , fInHairQuadEdge(this->addVertexAttrib(GrShaderVar("inCubicCoeffs",
278 kVec4f_GrSLType,
279 GrShaderVar::kAttribute_ TypeModifier))) {
278 } 280 }
279 281
280 bool GrQuadEffect::onIsEqual(const GrEffect& other) const { 282 bool GrQuadEffect::onIsEqual(const GrEffect& other) const {
281 const GrQuadEffect& ce = CastEffect<GrQuadEffect>(other); 283 const GrQuadEffect& ce = CastEffect<GrQuadEffect>(other);
282 return (ce.fEdgeType == fEdgeType); 284 return (ce.fEdgeType == fEdgeType);
283 } 285 }
284 286
285 ////////////////////////////////////////////////////////////////////////////// 287 //////////////////////////////////////////////////////////////////////////////
286 288
287 GR_DEFINE_EFFECT_TEST(GrQuadEffect); 289 GR_DEFINE_EFFECT_TEST(GrQuadEffect);
288 290
289 GrEffect* GrQuadEffect::TestCreate(SkRandom* random, 291 GrEffect* GrQuadEffect::TestCreate(SkRandom* random,
290 GrContext*, 292 GrContext*,
291 const GrDrawTargetCaps& caps, 293 const GrDrawTargetCaps& caps,
292 GrTexture*[]) { 294 GrTexture*[]) {
293 GrEffect* effect; 295 GrEffect* effect;
294 do { 296 do {
295 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( 297 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
296 random->nextULessThan(kGrEff ectEdgeTypeCnt)); 298 random->nextULessThan(kGrEff ectEdgeTypeCnt));
297 effect = GrQuadEffect::Create(edgeType, caps); 299 effect = GrQuadEffect::Create(edgeType, caps);
298 } while (NULL == effect); 300 } while (NULL == effect);
299 return effect; 301 return effect;
300 } 302 }
301 303
302 ////////////////////////////////////////////////////////////////////////////// 304 //////////////////////////////////////////////////////////////////////////////
303 // Cubic 305 // Cubic
304 ////////////////////////////////////////////////////////////////////////////// 306 //////////////////////////////////////////////////////////////////////////////
305 307
306 class GrGLCubicEffect : public GrGLVertexEffect { 308 class GrGLCubicEffect : public GrGLGeometryProcessor {
307 public: 309 public:
308 GrGLCubicEffect(const GrBackendEffectFactory&, const GrDrawEffect&); 310 GrGLCubicEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
309 311
310 virtual void emitCode(GrGLFullProgramBuilder* builder, 312 virtual void emitCode(GrGLFullProgramBuilder* builder,
311 const GrDrawEffect& drawEffect, 313 const GrDrawEffect& drawEffect,
312 const GrEffectKey& key, 314 const GrEffectKey& key,
313 const char* outputColor, 315 const char* outputColor,
314 const char* inputColor, 316 const char* inputColor,
315 const TransformedCoordsArray&, 317 const TransformedCoordsArray&,
316 const TextureSamplerArray&) SK_OVERRIDE; 318 const TextureSamplerArray&) SK_OVERRIDE;
317 319
318 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*); 320 static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyB uilder*);
319 321
320 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE {} 322 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_ OVERRIDE {}
321 323
322 private: 324 private:
323 GrEffectEdgeType fEdgeType; 325 GrEffectEdgeType fEdgeType;
324 326
325 typedef GrGLVertexEffect INHERITED; 327 typedef GrGLGeometryProcessor INHERITED;
326 }; 328 };
327 329
328 GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory, 330 GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory,
329 const GrDrawEffect& drawEffect) 331 const GrDrawEffect& drawEffect)
330 : INHERITED (factory) { 332 : INHERITED (factory) {
331 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>(); 333 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>();
332 fEdgeType = ce.getEdgeType(); 334 fEdgeType = ce.getEdgeType();
333 } 335 }
334 336
335 void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder, 337 void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
336 const GrDrawEffect& drawEffect, 338 const GrDrawEffect& drawEffect,
337 const GrEffectKey& key, 339 const GrEffectKey& key,
338 const char* outputColor, 340 const char* outputColor,
339 const char* inputColor, 341 const char* inputColor,
340 const TransformedCoordsArray&, 342 const TransformedCoordsArray&,
341 const TextureSamplerArray& samplers) { 343 const TextureSamplerArray& samplers) {
342 const char *vsName, *fsName; 344 const char *vsName, *fsName;
343 345
344 builder->addVarying(kVec4f_GrSLType, "CubicCoeffs", 346 builder->addVarying(kVec4f_GrSLType, "CubicCoeffs",
345 &vsName, &fsName, GrGLShaderVar::kHigh_Precision); 347 &vsName, &fsName, GrGLShaderVar::kHigh_Precision);
346 348
347 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); 349 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
348 const SkString* attr0Name = 350 const GrShaderVar& inCubicCoeffs = drawEffect.castEffect<GrCubicEffect>().in CubicCoeffs();
349 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0] ); 351 vsBuilder->codeAppendf("%s = %s;", vsName, inCubicCoeffs.c_str());
350 vsBuilder->codeAppendf("%s = %s;", vsName, attr0Name->c_str());
351 352
352 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 353 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
353 354
354 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig h_Precision); 355 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig h_Precision);
355 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision); 356 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision);
356 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision); 357 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision);
357 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n); 358 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
358 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n); 359 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
359 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision); 360 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
360 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision) ; 361 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision) ;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 445 }
445 446
446 ////////////////////////////////////////////////////////////////////////////// 447 //////////////////////////////////////////////////////////////////////////////
447 448
448 GrCubicEffect::~GrCubicEffect() {} 449 GrCubicEffect::~GrCubicEffect() {}
449 450
450 const GrBackendEffectFactory& GrCubicEffect::getFactory() const { 451 const GrBackendEffectFactory& GrCubicEffect::getFactory() const {
451 return GrTBackendEffectFactory<GrCubicEffect>::getInstance(); 452 return GrTBackendEffectFactory<GrCubicEffect>::getInstance();
452 } 453 }
453 454
454 GrCubicEffect::GrCubicEffect(GrEffectEdgeType edgeType) : GrVertexEffect() { 455 GrCubicEffect::GrCubicEffect(GrEffectEdgeType edgeType)
455 this->addVertexAttrib(kVec4f_GrSLType); 456 : fEdgeType(edgeType)
456 fEdgeType = edgeType; 457 , fInCubicCoeffs(this->addVertexAttrib(GrShaderVar("inCubicCoeffs",
458 kVec4f_GrSLType,
459 GrShaderVar::kAttribute_T ypeModifier))) {
457 } 460 }
458 461
459 bool GrCubicEffect::onIsEqual(const GrEffect& other) const { 462 bool GrCubicEffect::onIsEqual(const GrEffect& other) const {
460 const GrCubicEffect& ce = CastEffect<GrCubicEffect>(other); 463 const GrCubicEffect& ce = CastEffect<GrCubicEffect>(other);
461 return (ce.fEdgeType == fEdgeType); 464 return (ce.fEdgeType == fEdgeType);
462 } 465 }
463 466
464 ////////////////////////////////////////////////////////////////////////////// 467 //////////////////////////////////////////////////////////////////////////////
465 468
466 GR_DEFINE_EFFECT_TEST(GrCubicEffect); 469 GR_DEFINE_EFFECT_TEST(GrCubicEffect);
467 470
468 GrEffect* GrCubicEffect::TestCreate(SkRandom* random, 471 GrEffect* GrCubicEffect::TestCreate(SkRandom* random,
469 GrContext*, 472 GrContext*,
470 const GrDrawTargetCaps& caps, 473 const GrDrawTargetCaps& caps,
471 GrTexture*[]) { 474 GrTexture*[]) {
472 GrEffect* effect; 475 GrEffect* effect;
473 do { 476 do {
474 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( 477 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
475 random->nextULessThan(kGrEff ectEdgeTypeCnt)); 478 random->nextULessThan(kGrEff ectEdgeTypeCnt));
476 effect = GrCubicEffect::Create(edgeType, caps); 479 effect = GrCubicEffect::Create(edgeType, caps);
477 } while (NULL == effect); 480 } while (NULL == effect);
478 return effect; 481 return effect;
479 } 482 }
480 483
OLDNEW
« no previous file with comments | « src/gpu/effects/GrBezierEffect.h ('k') | src/gpu/effects/GrCustomCoordsTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698