| 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 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; | 27 virtual void emitCode(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::emitCode(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 const char* pos3 = "pos3"; |
| 92 gp.inPosition()->fName); | 91 vsBuilder->codeAppendf("vec3 %s;", pos3); |
| 92 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", pos3, this->uViewM(), gp.in
Position()->fName); |
| 93 |
| 94 // emit transforms with position |
| 95 this->emitTransforms(pb, pos3, gp.inPosition()->fName, gp.localMatrix(), arg
s.fTransformsIn, |
| 96 args.fTransformsOut); |
| 97 |
| 98 vsBuilder->transformToNormalizedDeviceSpace(pos3); |
| 93 | 99 |
| 94 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 100 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 95 fsBuilder->codeAppend("float edgeAlpha;"); | 101 fsBuilder->codeAppend("float edgeAlpha;"); |
| 96 | 102 |
| 97 switch (fEdgeType) { | 103 switch (fEdgeType) { |
| 98 case kHairlineAA_GrProcessorEdgeType: { | 104 case kHairlineAA_GrProcessorEdgeType: { |
| 99 SkAssertResult(fsBuilder->enableFeature( | 105 SkAssertResult(fsBuilder->enableFeature( |
| 100 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 106 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 101 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); | 107 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); |
| 102 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn()); | 108 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", v.fsIn()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 ////////////////////////////////////////////////////////////////////////////// | 183 ////////////////////////////////////////////////////////////////////////////// |
| 178 | 184 |
| 179 GrConicEffect::~GrConicEffect() {} | 185 GrConicEffect::~GrConicEffect() {} |
| 180 | 186 |
| 181 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 187 void GrConicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 182 const GrGLCaps& caps, | 188 const GrGLCaps& caps, |
| 183 GrProcessorKeyBuilder* b) const { | 189 GrProcessorKeyBuilder* b) const { |
| 184 GrGLConicEffect::GenKey(*this, bt, caps, b); | 190 GrGLConicEffect::GenKey(*this, bt, caps, b); |
| 185 } | 191 } |
| 186 | 192 |
| 187 GrGLGeometryProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt)
const { | 193 GrGLPrimitiveProcessor* GrConicEffect::createGLInstance(const GrBatchTracker& bt
, |
| 194 const GrGLCaps&) const { |
| 188 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); | 195 return SkNEW_ARGS(GrGLConicEffect, (*this, bt)); |
| 189 } | 196 } |
| 190 | 197 |
| 191 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, | 198 GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t
coverage, |
| 192 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) | 199 GrPrimitiveEdgeType edgeType, const SkMatrix& local
Matrix) |
| 193 : INHERITED(color, viewMatrix, localMatrix) | 200 : INHERITED(color, viewMatrix, localMatrix) |
| 194 , fCoverageScale(coverage) | 201 , fCoverageScale(coverage) |
| 195 , fEdgeType(edgeType) { | 202 , fEdgeType(edgeType) { |
| 196 this->initClassID<GrConicEffect>(); | 203 this->initClassID<GrConicEffect>(); |
| 197 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 204 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 GrColor fColor; | 258 GrColor fColor; |
| 252 uint8_t fCoverageScale; | 259 uint8_t fCoverageScale; |
| 253 bool fUsesLocalCoords; | 260 bool fUsesLocalCoords; |
| 254 }; | 261 }; |
| 255 | 262 |
| 256 class GrGLQuadEffect : public GrGLGeometryProcessor { | 263 class GrGLQuadEffect : public GrGLGeometryProcessor { |
| 257 public: | 264 public: |
| 258 GrGLQuadEffect(const GrGeometryProcessor&, | 265 GrGLQuadEffect(const GrGeometryProcessor&, |
| 259 const GrBatchTracker&); | 266 const GrBatchTracker&); |
| 260 | 267 |
| 261 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; | 268 virtual void emitCode(EmitArgs&) SK_OVERRIDE; |
| 262 | 269 |
| 263 static inline void GenKey(const GrGeometryProcessor&, | 270 static inline void GenKey(const GrGeometryProcessor&, |
| 264 const GrBatchTracker&, | 271 const GrBatchTracker&, |
| 265 const GrGLCaps&, | 272 const GrGLCaps&, |
| 266 GrProcessorKeyBuilder*); | 273 GrProcessorKeyBuilder*); |
| 267 | 274 |
| 268 virtual void setData(const GrGLProgramDataManager& pdman, | 275 virtual void setData(const GrGLProgramDataManager& pdman, |
| 269 const GrPrimitiveProcessor& primProc, | 276 const GrPrimitiveProcessor& primProc, |
| 270 const GrBatchTracker& bt) SK_OVERRIDE { | 277 const GrBatchTracker& bt) SK_OVERRIDE { |
| 271 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); | 278 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 293 typedef GrGLGeometryProcessor INHERITED; | 300 typedef GrGLGeometryProcessor INHERITED; |
| 294 }; | 301 }; |
| 295 | 302 |
| 296 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor, | 303 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor, |
| 297 const GrBatchTracker& bt) | 304 const GrBatchTracker& bt) |
| 298 : fColor(GrColor_ILLEGAL), fCoverageScale(0xff) { | 305 : fColor(GrColor_ILLEGAL), fCoverageScale(0xff) { |
| 299 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); | 306 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); |
| 300 fEdgeType = ce.getEdgeType(); | 307 fEdgeType = ce.getEdgeType(); |
| 301 } | 308 } |
| 302 | 309 |
| 303 void GrGLQuadEffect::emitCode(const EmitArgs& args) { | 310 void GrGLQuadEffect::emitCode(EmitArgs& args) { |
| 304 GrGLGPBuilder* pb = args.fPB; | 311 GrGLGPBuilder* pb = args.fPB; |
| 305 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 312 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 306 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); | 313 const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>(); |
| 307 const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>(); | 314 const QuadBatchTracker& local = args.fBT.cast<QuadBatchTracker>(); |
| 308 | 315 |
| 316 // emit attributes |
| 317 vsBuilder->emitAttributes(gp); |
| 318 |
| 309 GrGLVertToFrag v(kVec4f_GrSLType); | 319 GrGLVertToFrag v(kVec4f_GrSLType); |
| 310 args.fPB->addVarying("HairQuadEdge", &v); | 320 args.fPB->addVarying("HairQuadEdge", &v); |
| 311 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); | 321 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); |
| 312 | 322 |
| 313 // Setup pass through color | 323 // Setup pass through color |
| 314 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 324 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
| 315 &fColorUniform); | 325 &fColorUniform); |
| 316 | 326 |
| 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 | 327 // setup uniform viewMatrix |
| 322 this->addUniformViewMatrix(pb); | 328 this->addUniformViewMatrix(pb); |
| 323 | 329 |
| 324 // setup position varying | 330 // Setup position |
| 325 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), | 331 const char* pos3 = "pos3"; |
| 326 gp.inPosition()->fName); | 332 vsBuilder->codeAppendf("vec3 %s;", pos3); |
| 333 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", pos3, this->uViewM(), gp.in
Position()->fName); |
| 334 |
| 335 // emit transforms with position |
| 336 this->emitTransforms(pb, pos3, gp.inPosition()->fName, gp.localMatrix(), arg
s.fTransformsIn, |
| 337 args.fTransformsOut); |
| 338 |
| 339 vsBuilder->transformToNormalizedDeviceSpace(pos3); |
| 327 | 340 |
| 328 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 341 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 329 fsBuilder->codeAppendf("float edgeAlpha;"); | 342 fsBuilder->codeAppendf("float edgeAlpha;"); |
| 330 | 343 |
| 331 switch (fEdgeType) { | 344 switch (fEdgeType) { |
| 332 case kHairlineAA_GrProcessorEdgeType: { | 345 case kHairlineAA_GrProcessorEdgeType: { |
| 333 SkAssertResult(fsBuilder->enableFeature( | 346 SkAssertResult(fsBuilder->enableFeature( |
| 334 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 347 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 335 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 348 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
| 336 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 349 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 ////////////////////////////////////////////////////////////////////////////// | 410 ////////////////////////////////////////////////////////////////////////////// |
| 398 | 411 |
| 399 GrQuadEffect::~GrQuadEffect() {} | 412 GrQuadEffect::~GrQuadEffect() {} |
| 400 | 413 |
| 401 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, | 414 void GrQuadEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 402 const GrGLCaps& caps, | 415 const GrGLCaps& caps, |
| 403 GrProcessorKeyBuilder* b) const { | 416 GrProcessorKeyBuilder* b) const { |
| 404 GrGLQuadEffect::GenKey(*this, bt, caps, b); | 417 GrGLQuadEffect::GenKey(*this, bt, caps, b); |
| 405 } | 418 } |
| 406 | 419 |
| 407 GrGLGeometryProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt)
const { | 420 GrGLPrimitiveProcessor* GrQuadEffect::createGLInstance(const GrBatchTracker& bt, |
| 421 const GrGLCaps&) const { |
| 408 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); | 422 return SkNEW_ARGS(GrGLQuadEffect, (*this, bt)); |
| 409 } | 423 } |
| 410 | 424 |
| 411 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, | 425 GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t co
verage, |
| 412 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) | 426 GrPrimitiveEdgeType edgeType, const SkMatrix& localMa
trix) |
| 413 : INHERITED(color, viewMatrix, localMatrix) | 427 : INHERITED(color, viewMatrix, localMatrix) |
| 414 , fCoverageScale(coverage) | 428 , fCoverageScale(coverage) |
| 415 , fEdgeType(edgeType) { | 429 , fEdgeType(edgeType) { |
| 416 this->initClassID<GrQuadEffect>(); | 430 this->initClassID<GrQuadEffect>(); |
| 417 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 431 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 GrGPInput fInputColorType; | 485 GrGPInput fInputColorType; |
| 472 GrColor fColor; | 486 GrColor fColor; |
| 473 bool fUsesLocalCoords; | 487 bool fUsesLocalCoords; |
| 474 }; | 488 }; |
| 475 | 489 |
| 476 class GrGLCubicEffect : public GrGLGeometryProcessor { | 490 class GrGLCubicEffect : public GrGLGeometryProcessor { |
| 477 public: | 491 public: |
| 478 GrGLCubicEffect(const GrGeometryProcessor&, | 492 GrGLCubicEffect(const GrGeometryProcessor&, |
| 479 const GrBatchTracker&); | 493 const GrBatchTracker&); |
| 480 | 494 |
| 481 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; | 495 virtual void emitCode(EmitArgs&) SK_OVERRIDE; |
| 482 | 496 |
| 483 static inline void GenKey(const GrGeometryProcessor&, | 497 static inline void GenKey(const GrGeometryProcessor&, |
| 484 const GrBatchTracker&, | 498 const GrBatchTracker&, |
| 485 const GrGLCaps&, | 499 const GrGLCaps&, |
| 486 GrProcessorKeyBuilder*); | 500 GrProcessorKeyBuilder*); |
| 487 | 501 |
| 488 virtual void setData(const GrGLProgramDataManager& pdman, | 502 virtual void setData(const GrGLProgramDataManager& pdman, |
| 489 const GrPrimitiveProcessor& primProc, | 503 const GrPrimitiveProcessor& primProc, |
| 490 const GrBatchTracker& bt) SK_OVERRIDE { | 504 const GrBatchTracker& bt) SK_OVERRIDE { |
| 491 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); | 505 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 507 typedef GrGLGeometryProcessor INHERITED; | 521 typedef GrGLGeometryProcessor INHERITED; |
| 508 }; | 522 }; |
| 509 | 523 |
| 510 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor, | 524 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor, |
| 511 const GrBatchTracker&) | 525 const GrBatchTracker&) |
| 512 : fColor(GrColor_ILLEGAL) { | 526 : fColor(GrColor_ILLEGAL) { |
| 513 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 527 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
| 514 fEdgeType = ce.getEdgeType(); | 528 fEdgeType = ce.getEdgeType(); |
| 515 } | 529 } |
| 516 | 530 |
| 517 void GrGLCubicEffect::emitCode(const EmitArgs& args) { | 531 void GrGLCubicEffect::emitCode(EmitArgs& args) { |
| 518 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 532 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 519 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); | 533 const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>(); |
| 520 const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>(); | 534 const CubicBatchTracker& local = args.fBT.cast<CubicBatchTracker>(); |
| 521 | 535 |
| 536 // emit attributes |
| 537 vsBuilder->emitAttributes(gp); |
| 538 |
| 522 GrGLVertToFrag v(kVec4f_GrSLType); | 539 GrGLVertToFrag v(kVec4f_GrSLType); |
| 523 args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision); | 540 args.fPB->addVarying("CubicCoeffs", &v, kHigh_GrSLPrecision); |
| 524 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); | 541 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); |
| 525 | 542 |
| 526 // Setup pass through color | 543 // Setup pass through color |
| 527 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 544 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
| 528 &fColorUniform); | 545 &fColorUniform); |
| 529 | 546 |
| 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 | 547 // setup uniform viewMatrix |
| 535 this->addUniformViewMatrix(args.fPB); | 548 this->addUniformViewMatrix(args.fPB); |
| 536 | 549 |
| 537 // setup position varying | 550 // Setup position |
| 538 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), | 551 const char* pos3 = "pos3"; |
| 539 gp.inPosition()->fName); | 552 vsBuilder->codeAppendf("vec3 %s;", pos3); |
| 553 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", pos3, this->uViewM(), gp.in
Position()->fName); |
| 554 |
| 555 // emit transforms with position |
| 556 this->emitTransforms(args.fPB, pos3, gp.inPosition()->fName, gp.localMatrix(
), |
| 557 args.fTransformsIn, args.fTransformsOut); |
| 558 |
| 559 vsBuilder->transformToNormalizedDeviceSpace(pos3); |
| 540 | 560 |
| 541 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 561 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 542 | 562 |
| 543 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); | 563 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); |
| 544 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 564 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
| 545 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 565 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
| 546 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 566 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
| 547 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 567 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
| 548 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); | 568 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); |
| 549 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 569 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 ////////////////////////////////////////////////////////////////////////////// | 660 ////////////////////////////////////////////////////////////////////////////// |
| 641 | 661 |
| 642 GrCubicEffect::~GrCubicEffect() {} | 662 GrCubicEffect::~GrCubicEffect() {} |
| 643 | 663 |
| 644 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, | 664 void GrCubicEffect::getGLProcessorKey(const GrBatchTracker& bt, |
| 645 const GrGLCaps& caps, | 665 const GrGLCaps& caps, |
| 646 GrProcessorKeyBuilder* b) const { | 666 GrProcessorKeyBuilder* b) const { |
| 647 GrGLCubicEffect::GenKey(*this, bt, caps, b); | 667 GrGLCubicEffect::GenKey(*this, bt, caps, b); |
| 648 } | 668 } |
| 649 | 669 |
| 650 GrGLGeometryProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt)
const { | 670 GrGLPrimitiveProcessor* GrCubicEffect::createGLInstance(const GrBatchTracker& bt
, |
| 671 const GrGLCaps&) const { |
| 651 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); | 672 return SkNEW_ARGS(GrGLCubicEffect, (*this, bt)); |
| 652 } | 673 } |
| 653 | 674 |
| 654 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, | 675 GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, |
| 655 GrPrimitiveEdgeType edgeType) | 676 GrPrimitiveEdgeType edgeType) |
| 656 : INHERITED(color, viewMatrix), fEdgeType(edgeType) { | 677 : INHERITED(color, viewMatrix), fEdgeType(edgeType) { |
| 657 this->initClassID<GrCubicEffect>(); | 678 this->initClassID<GrCubicEffect>(); |
| 658 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); | 679 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_GrVert
exAttribType)); |
| 659 fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", | 680 fInCubicCoeffs = &this->addVertexAttrib(GrAttribute("inCubicCoeffs", |
| 660 kVec4f_GrVertexAttribTyp
e)); | 681 kVec4f_GrVertexAttribTyp
e)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 GrGeometryProcessor* gp; | 714 GrGeometryProcessor* gp; |
| 694 do { | 715 do { |
| 695 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 716 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
| 696 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 717 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
| 697 gp = GrCubicEffect::Create(GrRandomColor(random), | 718 gp = GrCubicEffect::Create(GrRandomColor(random), |
| 698 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); | 719 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); |
| 699 } while (NULL == gp); | 720 } while (NULL == gp); |
| 700 return gp; | 721 return gp; |
| 701 } | 722 } |
| 702 | 723 |
| OLD | NEW |