| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
| 10 | 10 |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 528 |
| 529 const Attribute* inPosition() const { return fInPosition; } | 529 const Attribute* inPosition() const { return fInPosition; } |
| 530 const Attribute* inQuadEdge() const { return fInQuadEdge; } | 530 const Attribute* inQuadEdge() const { return fInQuadEdge; } |
| 531 | 531 |
| 532 class GLProcessor : public GrGLGeometryProcessor { | 532 class GLProcessor : public GrGLGeometryProcessor { |
| 533 public: | 533 public: |
| 534 GLProcessor(const GrGeometryProcessor&, | 534 GLProcessor(const GrGeometryProcessor&, |
| 535 const GrBatchTracker&) | 535 const GrBatchTracker&) |
| 536 : fColor(GrColor_ILLEGAL) {} | 536 : fColor(GrColor_ILLEGAL) {} |
| 537 | 537 |
| 538 void onEmitCode(EmitArgs& args) SK_OVERRIDE { | 538 void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) SK_OVERRIDE { |
| 539 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); | 539 const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>(); |
| 540 GrGLGPBuilder* pb = args.fPB; | 540 GrGLGPBuilder* pb = args.fPB; |
| 541 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); | 541 GrGLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder(); |
| 542 | 542 |
| 543 // emit attributes | 543 // emit attributes |
| 544 vsBuilder->emitAttributes(qe); | 544 vsBuilder->emitAttributes(qe); |
| 545 | 545 |
| 546 GrGLVertToFrag v(kVec4f_GrSLType); | 546 GrGLVertToFrag v(kVec4f_GrSLType); |
| 547 args.fPB->addVarying("QuadEdge", &v); | 547 args.fPB->addVarying("QuadEdge", &v); |
| 548 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); | 548 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); |
| 549 | 549 |
| 550 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 550 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
| 551 | 551 |
| 552 // Setup pass through color | 552 // Setup pass through color |
| 553 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, NULL, | 553 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, NULL, |
| 554 &fColorUniform); | 554 &fColorUniform); |
| 555 | 555 |
| 556 // setup uniform viewMatrix | 556 // setup uniform viewMatrix |
| 557 this->addUniformViewMatrix(pb); | 557 this->addUniformViewMatrix(pb); |
| 558 | 558 |
| 559 // Setup position | 559 // Setup position |
| 560 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(),
this->uViewM(), | 560 SetupPosition(vsBuilder, gpArgs, qe.inPosition()->fName, |
| 561 qe.inPosition()->fName); | 561 qe.viewMatrix(), this->uViewM()); |
| 562 | 562 |
| 563 // emit transforms | 563 // emit transforms |
| 564 this->emitTransforms(args.fPB, this->position(), qe.inPosition()->f
Name, | 564 this->emitTransforms(args.fPB, gpArgs->fPositionVar, qe.inPosition()
->fName, |
| 565 qe.localMatrix(), args.fTransformsIn, args.fTra
nsformsOut); | 565 qe.localMatrix(), args.fTransformsIn, args.fTra
nsformsOut); |
| 566 | 566 |
| 567 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde
r(); | 567 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde
r(); |
| 568 | 568 |
| 569 SkAssertResult(fsBuilder->enableFeature( | 569 SkAssertResult(fsBuilder->enableFeature( |
| 570 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 570 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 571 fsBuilder->codeAppendf("float edgeAlpha;"); | 571 fsBuilder->codeAppendf("float edgeAlpha;"); |
| 572 | 572 |
| 573 // keep the derivative instructions outside the conditional | 573 // keep the derivative instructions outside the conditional |
| 574 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 574 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 587 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0
);}"); | 587 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0
);}"); |
| 588 | 588 |
| 589 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); | 589 fsBuilder->codeAppendf("%s = vec4(edgeAlpha);", args.fOutputCoverage
); |
| 590 } | 590 } |
| 591 | 591 |
| 592 static inline void GenKey(const GrGeometryProcessor& gp, | 592 static inline void GenKey(const GrGeometryProcessor& gp, |
| 593 const GrBatchTracker& bt, | 593 const GrBatchTracker& bt, |
| 594 const GrGLCaps&, | 594 const GrGLCaps&, |
| 595 GrProcessorKeyBuilder* b) { | 595 GrProcessorKeyBuilder* b) { |
| 596 const BatchTracker& local = bt.cast<BatchTracker>(); | 596 const BatchTracker& local = bt.cast<BatchTracker>(); |
| 597 b->add32((local.fInputColorType << 16) | | 597 uint32_t key = local.fInputColorType << 16; |
| 598 (local.fUsesLocalCoords && gp.localMatrix().hasPerspective(
) ? 0x1 : 0x0)); | 598 key |= local.fUsesLocalCoords && gp.localMatrix().hasPerspective() ?
0x1 : 0x0; |
| 599 key |= ComputePosKey(gp.viewMatrix()) << 1; |
| 600 b->add32(key); |
| 599 } | 601 } |
| 600 | 602 |
| 601 virtual void setData(const GrGLProgramDataManager& pdman, | 603 virtual void setData(const GrGLProgramDataManager& pdman, |
| 602 const GrPrimitiveProcessor& gp, | 604 const GrPrimitiveProcessor& gp, |
| 603 const GrBatchTracker& bt) SK_OVERRIDE { | 605 const GrBatchTracker& bt) SK_OVERRIDE { |
| 604 this->setUniformViewMatrix(pdman, gp.viewMatrix()); | 606 this->setUniformViewMatrix(pdman, gp.viewMatrix()); |
| 605 | 607 |
| 606 const BatchTracker& local = bt.cast<BatchTracker>(); | 608 const BatchTracker& local = bt.cast<BatchTracker>(); |
| 607 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { | 609 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != f
Color) { |
| 608 GrGLfloat c[4]; | 610 GrGLfloat c[4]; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 vOffset, // start vertex | 788 vOffset, // start vertex |
| 787 0, // start index | 789 0, // start index |
| 788 draw.fVertexCnt, | 790 draw.fVertexCnt, |
| 789 draw.fIndexCnt, | 791 draw.fIndexCnt, |
| 790 &devBounds); | 792 &devBounds); |
| 791 vOffset += draw.fVertexCnt; | 793 vOffset += draw.fVertexCnt; |
| 792 } | 794 } |
| 793 | 795 |
| 794 return true; | 796 return true; |
| 795 } | 797 } |
| OLD | NEW |