| 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/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
| 11 #include "gl/GrGLSL.h" | 11 #include "gl/GrGLSL.h" |
| 12 #include "gl/GrGLGeometryProcessor.h" | 12 #include "gl/GrGLGeometryProcessor.h" |
| 13 #include "gl/builders/GrGLProgramBuilder.h" | 13 #include "gl/builders/GrGLProgramBuilder.h" |
| 14 | 14 |
| 15 struct ConicBatchTracker { | 15 struct ConicBatchTracker { |
| 16 GrGPInput fInputColorType; | 16 GrGPInput fInputColorType; |
| 17 GrColor fColor; | 17 GrColor fColor; |
| 18 uint8_t fCoverageScale; | 18 uint8_t fCoverageScale; |
| 19 bool fUsesLocalCoords; | 19 bool fUsesLocalCoords; |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 class GrGLConicEffect : public GrGLGeometryProcessor { | 22 class GrGLConicEffect : public GrGLGeometryProcessor { |
| 23 public: | 23 public: |
| 24 GrGLConicEffect(const GrGeometryProcessor&, | 24 GrGLConicEffect(const GrGeometryProcessor&, |
| 25 const GrBatchTracker&); | 25 const GrBatchTracker&); |
| 26 | 26 |
| 27 void emitCode(const EmitArgs&) SK_OVERRIDE; | 27 void onEmitCode(EmitArgs&) SK_OVERRIDE; |
| 28 | 28 |
| 29 static inline void GenKey(const GrGeometryProcessor&, | 29 static inline void GenKey(const GrGeometryProcessor&, |
| 30 const GrBatchTracker&, | 30 const GrBatchTracker&, |
| 31 const GrGLCaps&, | 31 const GrGLCaps&, |
| 32 GrProcessorKeyBuilder*); | 32 GrProcessorKeyBuilder*); |
| 33 | 33 |
| 34 virtual void setData(const GrGLProgramDataManager& pdman, | 34 virtual void setData(const GrGLProgramDataManager& pdman, |
| 35 const GrPrimitiveProcessor& primProc, | 35 const GrPrimitiveProcessor& primProc, |
| 36 const GrBatchTracker& bt) SK_OVERRIDE { | 36 const GrBatchTracker& bt) SK_OVERRIDE { |
| 37 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); | 37 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 59 typedef GrGLGeometryProcessor INHERITED; | 59 typedef GrGLGeometryProcessor INHERITED; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor, | 62 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor, |
| 63 const GrBatchTracker& bt) | 63 const GrBatchTracker& bt) |
| 64 : fColor(GrColor_ILLEGAL), fCoverageScale(0xff) { | 64 : fColor(GrColor_ILLEGAL), fCoverageScale(0xff) { |
| 65 const GrConicEffect& ce = processor.cast<GrConicEffect>(); | 65 const GrConicEffect& ce = processor.cast<GrConicEffect>(); |
| 66 fEdgeType = ce.getEdgeType(); | 66 fEdgeType = ce.getEdgeType(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void GrGLConicEffect::emitCode(const EmitArgs& args) { | 69 void GrGLConicEffect::onEmitCode(EmitArgs& args) { |
| 70 GrGLGPBuilder* pb = args.fPB; | 70 GrGLGPBuilder* pb = args.fPB; |
| 71 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 71 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 72 const GrConicEffect& gp = args.fGP.cast<GrConicEffect>(); | 72 const GrConicEffect& gp = args.fGP.cast<GrConicEffect>(); |
| 73 const ConicBatchTracker& local = args.fBT.cast<ConicBatchTracker>(); | 73 const ConicBatchTracker& local = args.fBT.cast<ConicBatchTracker>(); |
| 74 | 74 |
| 75 // emit attributes |
| 76 vsBuilder->emitAttributes(gp); |
| 77 |
| 75 GrGLVertToFrag v(kVec4f_GrSLType); | 78 GrGLVertToFrag v(kVec4f_GrSLType); |
| 76 args.fPB->addVarying("ConicCoeffs", &v); | 79 args.fPB->addVarying("ConicCoeffs", &v); |
| 77 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName); | 80 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName); |
| 78 | 81 |
| 79 // Setup pass through color | 82 // Setup pass through color |
| 80 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 83 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
| 81 &fColorUniform); | 84 &fColorUniform); |
| 82 | 85 |
| 83 // setup coord outputs | |
| 84 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); | |
| 85 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); | |
| 86 | |
| 87 // setup uniform viewMatrix | 86 // setup uniform viewMatrix |
| 88 this->addUniformViewMatrix(pb); | 87 this->addUniformViewMatrix(pb); |
| 89 | 88 |
| 90 // setup position varying | 89 // Setup position |
| 91 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), | 90 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uVi
ewM(), |
| 92 gp.inPosition()->fName); | 91 gp.inPosition()->fName); |
| 93 | 92 |
| 93 // emit transforms with position |
| 94 this->emitTransforms(pb, this->position(), gp.inPosition()->fName, gp.localM
atrix(), |
| 95 args.fTransformsIn, args.fTransformsOut); |
| 96 |
| 94 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 97 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 95 fsBuilder->codeAppend("float edgeAlpha;"); | 98 fsBuilder->codeAppend("float edgeAlpha;"); |
| 96 | 99 |
| 97 switch (fEdgeType) { | 100 switch (fEdgeType) { |
| 98 case kHairlineAA_GrProcessorEdgeType: { | 101 case kHairlineAA_GrProcessorEdgeType: { |
| 99 SkAssertResult(fsBuilder->enableFeature( | 102 SkAssertResult(fsBuilder->enableFeature( |
| 100 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 103 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 101 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); | 104 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); |
| 102 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn()); | 105 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn()); |
| 103 fsBuilder->codeAppendf("float dfdx =" | 106 fsBuilder->codeAppendf("float dfdx =" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 ////////////////////////////////////////////////////////////////////////////// | 180 ////////////////////////////////////////////////////////////////////////////// |
| 178 | 181 |
| 179 GrConicEffect::~GrConicEffect() {} | 182 GrConicEffect::~GrConicEffect() {} |
| 180 | 183 |
| 181 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 184 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 182 const GrGLCaps& caps, | 185 const GrGLCaps& caps, |
| 183 GrProcessorKeyBuilder* b) const { | 186 GrProcessorKeyBuilder* b) const { |
| 184 GrGLConicEffect::GenKey(*this, bt, caps, b); | 187 GrGLConicEffect::GenKey(*this, bt, caps, b); |
| 185 } | 188 } |
| 186 | 189 |
| 187 GrGLGeometryProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt)
const { | 190 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt
, |
| 191 const GrGLCaps&) const { |
| 188 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); | 192 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); |
| 189 } | 193 } |
| 190 | 194 |
| 191 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, | 195 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, |
| 192 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) | 196 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) |
| 193 : INHERITED(color, viewMatrix, localMatrix) | 197 : INHERITED(color, viewMatrix, localMatrix) |
| 194 , fCoverageScale(coverage) | 198 , fCoverageScale(coverage) |
| 195 , fEdgeType(edgeType) { | 199 , fEdgeType(edgeType) { |
| 196 this->initClassID<GrConicEffect>(); | 200 this->initClassID<GrConicEffect>(); |
| 197 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 201 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 GrColor fColor; | 255 GrColor fColor; |
| 252 uint8_t fCoverageScale; | 256 uint8_t fCoverageScale; |
| 253 bool fUsesLocalCoords; | 257 bool fUsesLocalCoords; |
| 254 }; | 258 }; |
| 255 | 259 |
| 256 class GrGLQuadEffect : public GrGLGeometryProcessor { | 260 class GrGLQuadEffect : public GrGLGeometryProcessor { |
| 257 public: | 261 public: |
| 258 GrGLQuadEffect(const GrGeometryProcessor&, | 262 GrGLQuadEffect(const GrGeometryProcessor&, |
| 259 const GrBatchTracker&); | 263 const GrBatchTracker&); |
| 260 | 264 |
| 261 void emitCode(const EmitArgs&) SK_OVERRIDE; | 265 void onEmitCode(EmitArgs&) SK_OVERRIDE; |
| 262 | 266 |
| 263 static inline void GenKey(const GrGeometryProcessor&, | 267 static inline void GenKey(const GrGeometryProcessor&, |
| 264 const GrBatchTracker&, | 268 const GrBatchTracker&, |
| 265 const GrGLCaps&, | 269 const GrGLCaps&, |
| 266 GrProcessorKeyBuilder*); | 270 GrProcessorKeyBuilder*); |
| 267 | 271 |
| 268 virtual void setData(const GrGLProgramDataManager& pdman, | 272 virtual void setData(const GrGLProgramDataManager& pdman, |
| 269 const GrPrimitiveProcessor& primProc, | 273 const GrPrimitiveProcessor& primProc, |
| 270 const GrBatchTracker& bt) SK_OVERRIDE { | 274 const GrBatchTracker& bt) SK_OVERRIDE { |
| 271 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); | 275 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 293 typedef GrGLGeometryProcessor INHERITED; | 297 typedef GrGLGeometryProcessor INHERITED; |
| 294 }; | 298 }; |
| 295 | 299 |
| 296 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor, | 300 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor, |
| 297 const GrBatchTracker& bt) | 301 const GrBatchTracker& bt) |
| 298 : fColor(GrColor_ILLEGAL), fCoverageScale(0xff) { | 302 : fColor(GrColor_ILLEGAL), fCoverageScale(0xff) { |
| 299 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); | 303 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); |
| 300 fEdgeType = ce.getEdgeType(); | 304 fEdgeType = ce.getEdgeType(); |
| 301 } | 305 } |
| 302 | 306 |
| 303 void GrGLQuadEffect::emitCode(const EmitArgs& args) { | 307 void GrGLQuadEffect::onEmitCode(EmitArgs& args) { |
| 304 GrGLGPBuilder* pb = args.fPB; | 308 GrGLGPBuilder* pb = args.fPB; |
| 305 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 309 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 306 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); | 310 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); |
| 307 const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>(); | 311 const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>(); |
| 308 | 312 |
| 313 // emit attributes |
| 314 vsBuilder->emitAttributes(gp); |
| 315 |
| 309 GrGLVertToFrag v(kVec4f_GrSLType); | 316 GrGLVertToFrag v(kVec4f_GrSLType); |
| 310 args.fPB->addVarying("HairQuadEdge", &v); | 317 args.fPB->addVarying("HairQuadEdge", &v); |
| 311 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); | 318 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); |
| 312 | 319 |
| 313 // Setup pass through color | 320 // Setup pass through color |
| 314 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 321 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
| 315 &fColorUniform); | 322 &fColorUniform); |
| 316 | 323 |
| 317 // setup coord outputs | |
| 318 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); | |
| 319 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); | |
| 320 | |
| 321 // setup uniform viewMatrix | 324 // setup uniform viewMatrix |
| 322 this->addUniformViewMatrix(pb); | 325 this->addUniformViewMatrix(pb); |
| 323 | 326 |
| 324 // setup position varying | 327 // Setup position |
| 325 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), | 328 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uVi
ewM(), |
| 326 gp.inPosition()->fName); | 329 gp.inPosition()->fName); |
| 327 | 330 |
| 331 // emit transforms with position |
| 332 this->emitTransforms(pb, this->position(), gp.inPosition()->fName, gp.localM
atrix(), |
| 333 args.fTransformsIn, args.fTransformsOut); |
| 334 |
| 328 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 335 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 329 fsBuilder->codeAppendf("float edgeAlpha;"); | 336 fsBuilder->codeAppendf("float edgeAlpha;"); |
| 330 | 337 |
| 331 switch (fEdgeType) { | 338 switch (fEdgeType) { |
| 332 case kHairlineAA_GrProcessorEdgeType: { | 339 case kHairlineAA_GrProcessorEdgeType: { |
| 333 SkAssertResult(fsBuilder->enableFeature( | 340 SkAssertResult(fsBuilder->enableFeature( |
| 334 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 341 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 335 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 342 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
| 336 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 343 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
| 337 fsBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.
y," | 344 fsBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.
y," |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 ////////////////////////////////////////////////////////////////////////////// | 404 ////////////////////////////////////////////////////////////////////////////// |
| 398 | 405 |
| 399 GrQuadEffect::~GrQuadEffect() {} | 406 GrQuadEffect::~GrQuadEffect() {} |
| 400 | 407 |
| 401 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, | 408 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 402 const GrGLCaps& caps, | 409 const GrGLCaps& caps, |
| 403 GrProcessorKeyBuilder* b) const { | 410 GrProcessorKeyBuilder* b) const { |
| 404 GrGLQuadEffect::GenKey(*this, bt, caps, b); | 411 GrGLQuadEffect::GenKey(*this, bt, caps, b); |
| 405 } | 412 } |
| 406 | 413 |
| 407 GrGLGeometryProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt)
const { | 414 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt, |
| 415 const GrGLCaps&) const { |
| 408 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); | 416 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); |
| 409 } | 417 } |
| 410 | 418 |
| 411 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, | 419 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, |
| 412 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) | 420 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) |
| 413 : INHERITED(color, viewMatrix, localMatrix) | 421 : INHERITED(color, viewMatrix, localMatrix) |
| 414 , fCoverageScale(coverage) | 422 , fCoverageScale(coverage) |
| 415 , fEdgeType(edgeType) { | 423 , fEdgeType(edgeType) { |
| 416 this->initClassID<GrQuadEffect>(); | 424 this->initClassID<GrQuadEffect>(); |
| 417 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 425 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 GrGPInput fInputColorType; | 479 GrGPInput fInputColorType; |
| 472 GrColor fColor; | 480 GrColor fColor; |
| 473 bool fUsesLocalCoords; | 481 bool fUsesLocalCoords; |
| 474 }; | 482 }; |
| 475 | 483 |
| 476 class GrGLCubicEffect : public GrGLGeometryProcessor { | 484 class GrGLCubicEffect : public GrGLGeometryProcessor { |
| 477 public: | 485 public: |
| 478 GrGLCubicEffect(const GrGeometryProcessor&, | 486 GrGLCubicEffect(const GrGeometryProcessor&, |
| 479 const GrBatchTracker&); | 487 const GrBatchTracker&); |
| 480 | 488 |
| 481 void emitCode(const EmitArgs&) SK_OVERRIDE; | 489 void onEmitCode(EmitArgs&) SK_OVERRIDE; |
| 482 | 490 |
| 483 static inline void GenKey(const GrGeometryProcessor&, | 491 static inline void GenKey(const GrGeometryProcessor&, |
| 484 const GrBatchTracker&, | 492 const GrBatchTracker&, |
| 485 const GrGLCaps&, | 493 const GrGLCaps&, |
| 486 GrProcessorKeyBuilder*); | 494 GrProcessorKeyBuilder*); |
| 487 | 495 |
| 488 virtual void setData(const GrGLProgramDataManager& pdman, | 496 virtual void setData(const GrGLProgramDataManager& pdman, |
| 489 const GrPrimitiveProcessor& primProc, | 497 const GrPrimitiveProcessor& primProc, |
| 490 const GrBatchTracker& bt) SK_OVERRIDE { | 498 const GrBatchTracker& bt) SK_OVERRIDE { |
| 491 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); | 499 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 507 typedef GrGLGeometryProcessor INHERITED; | 515 typedef GrGLGeometryProcessor INHERITED; |
| 508 }; | 516 }; |
| 509 | 517 |
| 510 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor, | 518 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor, |
| 511 const GrBatchTracker&) | 519 const GrBatchTracker&) |
| 512 : fColor(GrColor_ILLEGAL) { | 520 : fColor(GrColor_ILLEGAL) { |
| 513 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 521 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
| 514 fEdgeType = ce.getEdgeType(); | 522 fEdgeType = ce.getEdgeType(); |
| 515 } | 523 } |
| 516 | 524 |
| 517 void GrGLCubicEffect::emitCode(const EmitArgs& args) { | 525 void GrGLCubicEffect::onEmitCode(EmitArgs& args) { |
| 518 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 526 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 519 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); | 527 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); |
| 520 const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>(); | 528 const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>(); |
| 521 | 529 |
| 530 // emit attributes |
| 531 vsBuilder->emitAttributes(gp); |
| 532 |
| 522 GrGLVertToFrag v(kVec4f_GrSLType); | 533 GrGLVertToFrag v(kVec4f_GrSLType); |
| 523 args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision); | 534 args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision); |
| 524 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); | 535 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); |
| 525 | 536 |
| 526 // Setup pass through color | 537 // Setup pass through color |
| 527 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 538 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
| 528 &fColorUniform); | 539 &fColorUniform); |
| 529 | 540 |
| 530 // setup coord outputs | |
| 531 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); | |
| 532 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); | |
| 533 | |
| 534 // setup uniform viewMatrix | 541 // setup uniform viewMatrix |
| 535 this->addUniformViewMatrix(args.fPB); | 542 this->addUniformViewMatrix(args.fPB); |
| 536 | 543 |
| 537 // setup position varying | 544 // Setup position |
| 538 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), | 545 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(), this->uVi
ewM(), |
| 539 gp.inPosition()->fName); | 546 gp.inPosition()->fName); |
| 540 | 547 |
| 548 // emit transforms with position |
| 549 this->emitTransforms(args.fPB, this->position(), gp.inPosition()->fName, gp.
localMatrix(), |
| 550 args.fTransformsIn, args.fTransformsOut); |
| 551 |
| 541 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 552 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 542 | 553 |
| 543 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); | 554 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); |
| 544 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 555 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
| 545 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 556 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
| 546 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 557 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
| 547 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 558 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
| 548 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); | 559 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); |
| 549 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 560 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
| 550 GrGLShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 561 GrGLShaderVar func("func", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 ////////////////////////////////////////////////////////////////////////////// | 651 ////////////////////////////////////////////////////////////////////////////// |
| 641 | 652 |
| 642 GrCubicEffect::~GrCubicEffect() {} | 653 GrCubicEffect::~GrCubicEffect() {} |
| 643 | 654 |
| 644 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 655 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 645 const GrGLCaps& caps, | 656 const GrGLCaps& caps, |
| 646 GrProcessorKeyBuilder* b) const { | 657 GrProcessorKeyBuilder* b) const { |
| 647 GrGLCubicEffect::GenKey(*this, bt, caps, b); | 658 GrGLCubicEffect::GenKey(*this, bt, caps, b); |
| 648 } | 659 } |
| 649 | 660 |
| 650 GrGLGeometryProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt)
const { | 661 GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt
, |
| 662 const GrGLCaps&) const { |
| 651 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); | 663 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); |
| 652 } | 664 } |
| 653 | 665 |
| 654 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, | 666 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, |
| 655 GrPrimitiveEdgeType edgeType) | 667 GrPrimitiveEdgeType edgeType) |
| 656 : INHERITED(color, viewMatrix), fEdgeType(edgeType) { | 668 : INHERITED(color, viewMatrix), fEdgeType(edgeType) { |
| 657 this->initClassID<GrCubicEffect>(); | 669 this->initClassID<GrCubicEffect>(); |
| 658 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 670 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
| 659 fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", | 671 fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", |
| 660 kVec4f_GrVertexAttribTyp
e)); | 672 kVec4f_GrVertexAttribTyp
e)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 GrGeometryProcessor* gp; | 705 GrGeometryProcessor* gp; |
| 694 do { | 706 do { |
| 695 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 707 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
| 696 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 708 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
| 697 gp = GrCubicEffect::Create(GrRandomColor(random), | 709 gp = GrCubicEffect::Create(GrRandomColor(random), |
| 698 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); | 710 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); |
| 699 } while (NULL == gp); | 711 } while (NULL == gp); |
| 700 return gp; | 712 return gp; |
| 701 } | 713 } |
| 702 | 714 |
| OLD | NEW |