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 "GrBezierEffect.h" | 8 #include "GrBezierEffect.h" |
9 | 9 |
10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 }; | 30 }; |
31 | 31 |
32 GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory, | 32 GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory, |
33 const GrProcessor& effect) | 33 const GrProcessor& effect) |
34 : INHERITED (factory) { | 34 : INHERITED (factory) { |
35 const GrConicEffect& ce = effect.cast<GrConicEffect>(); | 35 const GrConicEffect& ce = effect.cast<GrConicEffect>(); |
36 fEdgeType = ce.getEdgeType(); | 36 fEdgeType = ce.getEdgeType(); |
37 } | 37 } |
38 | 38 |
39 void GrGLConicEffect::emitCode(const EmitArgs& args) { | 39 void GrGLConicEffect::emitCode(const EmitArgs& args) { |
| 40 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 41 const GrConicEffect& gp = args.fGP.cast<GrConicEffect>(); |
| 42 |
40 GrGLVertToFrag v(kVec4f_GrSLType); | 43 GrGLVertToFrag v(kVec4f_GrSLType); |
41 args.fPB->addVarying("ConicCoeffs", &v); | 44 args.fPB->addVarying("ConicCoeffs", &v); |
| 45 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName); |
42 | 46 |
43 const GrShaderVar& inConicCoeffs = args.fGP.cast<GrConicEffect>().inConicCoe
ffs(); | 47 // setup coord outputs |
44 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 48 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); |
45 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), inConicCoeffs.c_str()); | 49 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); |
46 | 50 |
47 // setup position varying | 51 // setup position varying |
48 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), | 52 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), |
49 vsBuilder->inPosition()); | 53 gp.inPosition()->fName); |
50 | 54 |
51 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 55 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
52 fsBuilder->codeAppend("float edgeAlpha;"); | 56 fsBuilder->codeAppend("float edgeAlpha;"); |
53 | 57 |
54 switch (fEdgeType) { | 58 switch (fEdgeType) { |
55 case kHairlineAA_GrProcessorEdgeType: { | 59 case kHairlineAA_GrProcessorEdgeType: { |
56 SkAssertResult(fsBuilder->enableFeature( | 60 SkAssertResult(fsBuilder->enableFeature( |
57 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 61 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
58 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); | 62 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); |
59 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn()); | 63 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 case kFillBW_GrProcessorEdgeType: { | 102 case kFillBW_GrProcessorEdgeType: { |
99 fsBuilder->codeAppendf("edgeAlpha = %s.x * %s.x - %s.y * %s.z;", v.f
sIn(), v.fsIn(), | 103 fsBuilder->codeAppendf("edgeAlpha = %s.x * %s.x - %s.y * %s.z;", v.f
sIn(), v.fsIn(), |
100 v.fsIn(), v.fsIn()); | 104 v.fsIn(), v.fsIn()); |
101 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); | 105 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); |
102 break; | 106 break; |
103 } | 107 } |
104 default: | 108 default: |
105 SkFAIL("Shouldn't get here"); | 109 SkFAIL("Shouldn't get here"); |
106 } | 110 } |
107 | 111 |
108 fsBuilder->codeAppendf("%s = %s;", args.fOutput, | 112 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); |
109 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha"))
.c_str()); | |
110 } | 113 } |
111 | 114 |
112 void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, | 115 void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, |
113 GrProcessorKeyBuilder* b) { | 116 GrProcessorKeyBuilder* b) { |
114 const GrConicEffect& ce = processor.cast<GrConicEffect>(); | 117 const GrConicEffect& ce = processor.cast<GrConicEffect>(); |
115 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 118 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
116 b->add32(key); | 119 b->add32(key); |
117 } | 120 } |
118 | 121 |
119 ////////////////////////////////////////////////////////////////////////////// | 122 ////////////////////////////////////////////////////////////////////////////// |
120 | 123 |
121 GrConicEffect::~GrConicEffect() {} | 124 GrConicEffect::~GrConicEffect() {} |
122 | 125 |
123 const GrBackendGeometryProcessorFactory& GrConicEffect::getFactory() const { | 126 const GrBackendGeometryProcessorFactory& GrConicEffect::getFactory() const { |
124 return GrTBackendGeometryProcessorFactory<GrConicEffect>::getInstance(); | 127 return GrTBackendGeometryProcessorFactory<GrConicEffect>::getInstance(); |
125 } | 128 } |
126 | 129 |
127 GrConicEffect::GrConicEffect(GrPrimitiveEdgeType edgeType) | 130 GrConicEffect::GrConicEffect(GrPrimitiveEdgeType edgeType) |
128 : fEdgeType(edgeType) | 131 : fEdgeType(edgeType) { |
129 , fInConicCoeffs(this->addVertexAttrib(GrShaderVar("inConicCoeffs", | 132 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
130 kVec4f_GrSLType, | 133 fInConicCoeffs = &this->addVertexAttrib(GrAttribute("inConicCoeffs", |
131 GrShaderVar::kAttribute_T
ypeModifier))) { | 134 kVec4f_GrVertexAttribTyp
e)); |
132 } | 135 } |
133 | 136 |
134 bool GrConicEffect::onIsEqual(const GrGeometryProcessor& other) const { | 137 bool GrConicEffect::onIsEqual(const GrGeometryProcessor& other) const { |
135 const GrConicEffect& ce = other.cast<GrConicEffect>(); | 138 const GrConicEffect& ce = other.cast<GrConicEffect>(); |
136 return (ce.fEdgeType == fEdgeType); | 139 return (ce.fEdgeType == fEdgeType); |
137 } | 140 } |
138 | 141 |
139 ////////////////////////////////////////////////////////////////////////////// | 142 ////////////////////////////////////////////////////////////////////////////// |
140 | 143 |
141 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); | 144 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrConicEffect); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 }; | 177 }; |
175 | 178 |
176 GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory, | 179 GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory, |
177 const GrProcessor& effect) | 180 const GrProcessor& effect) |
178 : INHERITED (factory) { | 181 : INHERITED (factory) { |
179 const GrQuadEffect& ce = effect.cast<GrQuadEffect>(); | 182 const GrQuadEffect& ce = effect.cast<GrQuadEffect>(); |
180 fEdgeType = ce.getEdgeType(); | 183 fEdgeType = ce.getEdgeType(); |
181 } | 184 } |
182 | 185 |
183 void GrGLQuadEffect::emitCode(const EmitArgs& args) { | 186 void GrGLQuadEffect::emitCode(const EmitArgs& args) { |
| 187 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 188 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); |
| 189 |
184 GrGLVertToFrag v(kVec4f_GrSLType); | 190 GrGLVertToFrag v(kVec4f_GrSLType); |
185 args.fPB->addVarying("HairQuadEdge", &v); | 191 args.fPB->addVarying("HairQuadEdge", &v); |
| 192 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); |
186 | 193 |
187 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 194 // setup coord outputs |
188 const GrShaderVar& inHairQuadEdge = args.fGP.cast<GrQuadEffect>().inHairQuad
Edge(); | 195 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); |
189 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), inHairQuadEdge.c_str()); | 196 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); |
190 | 197 |
191 // setup position varying | 198 // setup position varying |
192 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), | 199 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), |
193 vsBuilder->inPosition()); | 200 gp.inPosition()->fName); |
194 | 201 |
195 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 202 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
196 fsBuilder->codeAppendf("float edgeAlpha;"); | 203 fsBuilder->codeAppendf("float edgeAlpha;"); |
197 | 204 |
198 switch (fEdgeType) { | 205 switch (fEdgeType) { |
199 case kHairlineAA_GrProcessorEdgeType: { | 206 case kHairlineAA_GrProcessorEdgeType: { |
200 SkAssertResult(fsBuilder->enableFeature( | 207 SkAssertResult(fsBuilder->enableFeature( |
201 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 208 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
202 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 209 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
203 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 210 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
(...skipping 24 matching lines...) Expand all Loading... |
228 } | 235 } |
229 case kFillBW_GrProcessorEdgeType: { | 236 case kFillBW_GrProcessorEdgeType: { |
230 fsBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);", v.fsIn()
, v.fsIn(), v.fsIn()); | 237 fsBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);", v.fsIn()
, v.fsIn(), v.fsIn()); |
231 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); | 238 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); |
232 break; | 239 break; |
233 } | 240 } |
234 default: | 241 default: |
235 SkFAIL("Shouldn't get here"); | 242 SkFAIL("Shouldn't get here"); |
236 } | 243 } |
237 | 244 |
238 fsBuilder->codeAppendf("%s = %s;", args.fOutput, | 245 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage); |
239 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha"))
.c_str()); | |
240 } | 246 } |
241 | 247 |
242 void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, | 248 void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, |
243 GrProcessorKeyBuilder* b) { | 249 GrProcessorKeyBuilder* b) { |
244 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); | 250 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); |
245 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 251 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
246 b->add32(key); | 252 b->add32(key); |
247 } | 253 } |
248 | 254 |
249 ////////////////////////////////////////////////////////////////////////////// | 255 ////////////////////////////////////////////////////////////////////////////// |
250 | 256 |
251 GrQuadEffect::~GrQuadEffect() {} | 257 GrQuadEffect::~GrQuadEffect() {} |
252 | 258 |
253 const GrBackendGeometryProcessorFactory& GrQuadEffect::getFactory() const { | 259 const GrBackendGeometryProcessorFactory& GrQuadEffect::getFactory() const { |
254 return GrTBackendGeometryProcessorFactory<GrQuadEffect>::getInstance(); | 260 return GrTBackendGeometryProcessorFactory<GrQuadEffect>::getInstance(); |
255 } | 261 } |
256 | 262 |
257 GrQuadEffect::GrQuadEffect(GrPrimitiveEdgeType edgeType) | 263 GrQuadEffect::GrQuadEffect(GrPrimitiveEdgeType edgeType) |
258 : fEdgeType(edgeType) | 264 : fEdgeType(edgeType) { |
259 , fInHairQuadEdge(this->addVertexAttrib(GrShaderVar("inCubicCoeffs", | 265 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
260 kVec4f_GrSLType, | 266 fInHairQuadEdge = &this->addVertexAttrib(GrAttribute("inHairQuadEdge", |
261 GrShaderVar::kAttribute_
TypeModifier))) { | 267 kVec4f_GrVertexAttribTyp
e)); |
262 } | 268 } |
263 | 269 |
264 bool GrQuadEffect::onIsEqual(const GrGeometryProcessor& other) const { | 270 bool GrQuadEffect::onIsEqual(const GrGeometryProcessor& other) const { |
265 const GrQuadEffect& ce = other.cast<GrQuadEffect>(); | 271 const GrQuadEffect& ce = other.cast<GrQuadEffect>(); |
266 return (ce.fEdgeType == fEdgeType); | 272 return (ce.fEdgeType == fEdgeType); |
267 } | 273 } |
268 | 274 |
269 ////////////////////////////////////////////////////////////////////////////// | 275 ////////////////////////////////////////////////////////////////////////////// |
270 | 276 |
271 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); | 277 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrQuadEffect); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 }; | 310 }; |
305 | 311 |
306 GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory, | 312 GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory, |
307 const GrProcessor& processor) | 313 const GrProcessor& processor) |
308 : INHERITED (factory) { | 314 : INHERITED (factory) { |
309 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 315 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
310 fEdgeType = ce.getEdgeType(); | 316 fEdgeType = ce.getEdgeType(); |
311 } | 317 } |
312 | 318 |
313 void GrGLCubicEffect::emitCode(const EmitArgs& args) { | 319 void GrGLCubicEffect::emitCode(const EmitArgs& args) { |
| 320 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 321 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); |
| 322 |
314 GrGLVertToFrag v(kVec4f_GrSLType); | 323 GrGLVertToFrag v(kVec4f_GrSLType); |
315 args.fPB->addVarying("CubicCoeffs", &v, GrGLShaderVar::kHigh_Precision); | 324 args.fPB->addVarying("CubicCoeffs", &v); |
| 325 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); |
316 | 326 |
317 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 327 // setup coord outputs |
318 const GrShaderVar& inCubicCoeffs = args.fGP.cast<GrCubicEffect>().inCubicCoe
ffs(); | 328 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); |
319 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), inCubicCoeffs.c_str()); | 329 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); |
320 | 330 |
321 // setup position varying | 331 // setup position varying |
322 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), | 332 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), |
323 vsBuilder->inPosition()); | 333 gp.inPosition()->fName); |
324 | 334 |
325 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 335 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
326 | 336 |
327 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); | 337 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); |
328 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); | 338 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); |
329 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); | 339 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); |
330 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); | 340 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); |
331 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); | 341 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); |
332 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision); | 342 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision); |
333 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision)
; | 343 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision)
; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 case kFillBW_GrProcessorEdgeType: { | 408 case kFillBW_GrProcessorEdgeType: { |
399 fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;", | 409 fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;", |
400 edgeAlpha.c_str(), v.fsIn(), v.fsIn(), v.fsIn
(), v.fsIn(), v.fsIn()); | 410 edgeAlpha.c_str(), v.fsIn(), v.fsIn(), v.fsIn
(), v.fsIn(), v.fsIn()); |
401 fsBuilder->codeAppendf("%s = float(%s < 0.0);", edgeAlpha.c_str(), e
dgeAlpha.c_str()); | 411 fsBuilder->codeAppendf("%s = float(%s < 0.0);", edgeAlpha.c_str(), e
dgeAlpha.c_str()); |
402 break; | 412 break; |
403 } | 413 } |
404 default: | 414 default: |
405 SkFAIL("Shouldn't get here"); | 415 SkFAIL("Shouldn't get here"); |
406 } | 416 } |
407 | 417 |
408 fsBuilder->codeAppendf("%s = %s;", args.fOutput, | 418 |
409 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1(edgeAlpha.c_s
tr())).c_str()); | 419 fsBuilder->codeAppendf("%s = vec4(%s);", args.fOutputCoverage, edgeAlpha.c_s
tr()); |
410 } | 420 } |
411 | 421 |
412 void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, | 422 void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, |
413 GrProcessorKeyBuilder* b) { | 423 GrProcessorKeyBuilder* b) { |
414 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 424 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
415 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 425 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
416 b->add32(key); | 426 b->add32(key); |
417 } | 427 } |
418 | 428 |
419 ////////////////////////////////////////////////////////////////////////////// | 429 ////////////////////////////////////////////////////////////////////////////// |
420 | 430 |
421 GrCubicEffect::~GrCubicEffect() {} | 431 GrCubicEffect::~GrCubicEffect() {} |
422 | 432 |
423 const GrBackendGeometryProcessorFactory& GrCubicEffect::getFactory() const { | 433 const GrBackendGeometryProcessorFactory& GrCubicEffect::getFactory() const { |
424 return GrTBackendGeometryProcessorFactory<GrCubicEffect>::getInstance(); | 434 return GrTBackendGeometryProcessorFactory<GrCubicEffect>::getInstance(); |
425 } | 435 } |
426 | 436 |
427 GrCubicEffect::GrCubicEffect(GrPrimitiveEdgeType edgeType) | 437 GrCubicEffect::GrCubicEffect(GrPrimitiveEdgeType edgeType) |
428 : fEdgeType(edgeType) | 438 : fEdgeType(edgeType) { |
429 , fInCubicCoeffs(this->addVertexAttrib(GrShaderVar("inCubicCoeffs", | 439 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
430 kVec4f_GrSLType, | 440 fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", |
431 GrShaderVar::kAttribute_T
ypeModifier))) { | 441 kVec4f_GrVertexAttribTyp
e)); |
432 } | 442 } |
433 | 443 |
434 bool GrCubicEffect::onIsEqual(const GrGeometryProcessor& other) const { | 444 bool GrCubicEffect::onIsEqual(const GrGeometryProcessor& other) const { |
435 const GrCubicEffect& ce = other.cast<GrCubicEffect>(); | 445 const GrCubicEffect& ce = other.cast<GrCubicEffect>(); |
436 return (ce.fEdgeType == fEdgeType); | 446 return (ce.fEdgeType == fEdgeType); |
437 } | 447 } |
438 | 448 |
439 ////////////////////////////////////////////////////////////////////////////// | 449 ////////////////////////////////////////////////////////////////////////////// |
440 | 450 |
441 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); | 451 GR_DEFINE_GEOMETRY_PROCESSOR_TEST(GrCubicEffect); |
442 | 452 |
443 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, | 453 GrGeometryProcessor* GrCubicEffect::TestCreate(SkRandom* random, |
444 GrContext*, | 454 GrContext*, |
445 const GrDrawTargetCaps& caps, | 455 const GrDrawTargetCaps& caps, |
446 GrTexture*[]) { | 456 GrTexture*[]) { |
447 GrGeometryProcessor* gp; | 457 GrGeometryProcessor* gp; |
448 do { | 458 do { |
449 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 459 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
450 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 460 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
451 gp = GrCubicEffect::Create(edgeType, caps); | 461 gp = GrCubicEffect::Create(edgeType, caps); |
452 } while (NULL == gp); | 462 } while (NULL == gp); |
453 return gp; | 463 return gp; |
454 } | 464 } |
455 | 465 |
OLD | NEW |