Chromium Code Reviews| 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 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 538 virtual void emitCode(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 const char* pos3 = "pos3"; |
| 562 this->uViewM(), qe.inPosition()->fName); | 561 vsBuilder->codeAppendf("vec3 %s;", pos3); |
| 562 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", pos3, this->uViewM( ), | |
| 563 qe.inPosition()->fName); | |
| 564 | |
| 565 // emit transforms | |
| 566 this->emitTransforms(args.fPB, pos3, qe.inPosition()->fName, qe.loca lMatrix(), | |
| 567 args.fTransformsIn, args.fTransformsOut); | |
| 568 | |
| 569 vsBuilder->transformToNormalizedDeviceSpace(pos3); | |
|
bsalomon
2015/01/13 14:51:14
won't this be repeated for every GP? Maybe we shou
| |
| 563 | 570 |
| 564 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde r(); | 571 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilde r(); |
| 565 | 572 |
| 566 SkAssertResult(fsBuilder->enableFeature( | 573 SkAssertResult(fsBuilder->enableFeature( |
| 567 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); | 574 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); |
| 568 fsBuilder->codeAppendf("float edgeAlpha;"); | 575 fsBuilder->codeAppendf("float edgeAlpha;"); |
| 569 | 576 |
| 570 // keep the derivative instructions outside the conditional | 577 // keep the derivative instructions outside the conditional |
| 571 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 578 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
| 572 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); | 579 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 | 622 |
| 616 typedef GrGLGeometryProcessor INHERITED; | 623 typedef GrGLGeometryProcessor INHERITED; |
| 617 }; | 624 }; |
| 618 | 625 |
| 619 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 626 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 620 const GrGLCaps& caps, | 627 const GrGLCaps& caps, |
| 621 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 628 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
| 622 GLProcessor::GenKey(*this, bt, caps, b); | 629 GLProcessor::GenKey(*this, bt, caps, b); |
| 623 } | 630 } |
| 624 | 631 |
| 625 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co nst SK_OVERRIDE { | 632 virtual GrGLPrimitiveProcessor* createGLInstance(const GrBatchTracker& bt, |
| 633 const GrGLCaps&) const SK_O VERRIDE { | |
| 626 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 634 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 627 } | 635 } |
| 628 | 636 |
| 629 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE { | 637 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR IDE { |
| 630 BatchTracker* local = bt->cast<BatchTracker>(); | 638 BatchTracker* local = bt->cast<BatchTracker>(); |
| 631 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false); | 639 local->fInputColorType = GetColorInputType(&local->fColor, this->color() , init, false); |
| 632 local->fUsesLocalCoords = init.fUsesLocalCoords; | 640 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 633 } | 641 } |
| 634 | 642 |
| 635 bool onCanMakeEqual(const GrBatchTracker& m, | 643 bool onCanMakeEqual(const GrBatchTracker& m, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 vOffset, // start vertex | 790 vOffset, // start vertex |
| 783 0, // start index | 791 0, // start index |
| 784 draw.fVertexCnt, | 792 draw.fVertexCnt, |
| 785 draw.fIndexCnt, | 793 draw.fIndexCnt, |
| 786 &devBounds); | 794 &devBounds); |
| 787 vOffset += draw.fVertexCnt; | 795 vOffset += draw.fVertexCnt; |
| 788 } | 796 } |
| 789 | 797 |
| 790 return true; | 798 return true; |
| 791 } | 799 } |
| OLD | NEW |