| 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 GrAttribute* inPosition() const { return fInPosition; } | 529 const GrAttribute* inPosition() const { return fInPosition; } |
| 530 const GrAttribute* inQuadEdge() const { return fInQuadEdge; } | 530 const GrAttribute* 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 emitCode(const EmitArgs& args) SK_OVERRIDE { | 538 void onEmitCode(EmitArgs& args) 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 |
| 544 vsBuilder->emitAttributes(qe); |
| 545 |
| 543 GrGLVertToFrag v(kVec4f_GrSLType); | 546 GrGLVertToFrag v(kVec4f_GrSLType); |
| 544 args.fPB->addVarying("QuadEdge", &v); | 547 args.fPB->addVarying("QuadEdge", &v); |
| 545 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); | 548 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); |
| 546 | 549 |
| 547 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 550 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
| 548 | 551 |
| 549 // Setup pass through color | 552 // Setup pass through color |
| 550 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, NULL, | 553 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputC
olor, NULL, |
| 551 &fColorUniform); | 554 &fColorUniform); |
| 552 | 555 |
| 553 // setup coord outputs | |
| 554 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), qe.i
nPosition()->fName); | |
| 555 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), qe.inPo
sition()->fName); | |
| 556 | |
| 557 // setup uniform viewMatrix | 556 // setup uniform viewMatrix |
| 558 this->addUniformViewMatrix(pb); | 557 this->addUniformViewMatrix(pb); |
| 559 | 558 |
| 560 // setup position varying | 559 // Setup position |
| 561 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPositi
on(), | 560 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", this->position(),
this->uViewM(), |
| 562 this->uViewM(), qe.inPosition()->fName); | 561 qe.inPosition()->fName); |
| 562 |
| 563 // emit transforms |
| 564 this->emitTransforms(args.fPB, this->position(), qe.inPosition()->f
Name, |
| 565 qe.localMatrix(), args.fTransformsIn, args.fTra
nsformsOut); |
| 563 | 566 |
| 564 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde
r(); | 567 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde
r(); |
| 565 | 568 |
| 566 SkAssertResult(fsBuilder->enableFeature( | 569 SkAssertResult(fsBuilder->enableFeature( |
| 567 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 570 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 568 fsBuilder->codeAppendf("float edgeAlpha;"); | 571 fsBuilder->codeAppendf("float edgeAlpha;"); |
| 569 | 572 |
| 570 // keep the derivative instructions outside the conditional | 573 // keep the derivative instructions outside the conditional |
| 571 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 574 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
| 572 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 575 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 618 |
| 616 typedef GrGLGeometryProcessor INHERITED; | 619 typedef GrGLGeometryProcessor INHERITED; |
| 617 }; | 620 }; |
| 618 | 621 |
| 619 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 622 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 620 const GrGLCaps& caps, | 623 const GrGLCaps& caps, |
| 621 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 624 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
| 622 GLProcessor::GenKey(*this, bt, caps, b); | 625 GLProcessor::GenKey(*this, bt, caps, b); |
| 623 } | 626 } |
| 624 | 627 |
| 625 GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_O
VERRIDE { | 628 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 629 const GrGLCaps&) const SK_O
VERRIDE { |
| 626 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 630 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 627 } | 631 } |
| 628 | 632 |
| 629 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { | 633 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { |
| 630 BatchTracker* local = bt->cast<BatchTracker>(); | 634 BatchTracker* local = bt->cast<BatchTracker>(); |
| 631 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 635 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 632 local->fUsesLocalCoords = init.fUsesLocalCoords; | 636 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 633 } | 637 } |
| 634 | 638 |
| 635 bool onCanMakeEqual(const GrBatchTracker& m, | 639 bool onCanMakeEqual(const GrBatchTracker& m, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 vOffset, // start vertex | 786 vOffset, // start vertex |
| 783 0, // start index | 787 0, // start index |
| 784 draw.fVertexCnt, | 788 draw.fVertexCnt, |
| 785 draw.fIndexCnt, | 789 draw.fIndexCnt, |
| 786 &devBounds); | 790 &devBounds); |
| 787 vOffset += draw.fVertexCnt; | 791 vOffset += draw.fVertexCnt; |
| 788 } | 792 } |
| 789 | 793 |
| 790 return true; | 794 return true; |
| 791 } | 795 } |
| OLD | NEW |