| 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 517 |
| 518 class QuadEdgeEffect : public GrGeometryProcessor { | 518 class QuadEdgeEffect : public GrGeometryProcessor { |
| 519 public: | 519 public: |
| 520 | 520 |
| 521 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatri
x) { | 521 static GrGeometryProcessor* Create(GrColor color, const SkMatrix& localMatri
x) { |
| 522 return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix)); | 522 return SkNEW_ARGS(QuadEdgeEffect, (color, localMatrix)); |
| 523 } | 523 } |
| 524 | 524 |
| 525 virtual ~QuadEdgeEffect() {} | 525 virtual ~QuadEdgeEffect() {} |
| 526 | 526 |
| 527 virtual const char* name() const SK_OVERRIDE { return "QuadEdge"; } | 527 const char* name() const SK_OVERRIDE { return "QuadEdge"; } |
| 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 void emitCode(const 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 GrGLVertToFrag v(kVec4f_GrSLType); | 543 GrGLVertToFrag v(kVec4f_GrSLType); |
| 544 args.fPB->addVarying("QuadEdge", &v); | 544 args.fPB->addVarying("QuadEdge", &v); |
| 545 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); | 545 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), qe.inQuadEdge()->fName
); |
| 546 | 546 |
| 547 const BatchTracker& local = args.fBT.cast<BatchTracker>(); | 547 const BatchTracker& local = args.fBT.cast<BatchTracker>(); |
| 548 | 548 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 typedef GrGLGeometryProcessor INHERITED; | 616 typedef GrGLGeometryProcessor INHERITED; |
| 617 }; | 617 }; |
| 618 | 618 |
| 619 virtual void getGLProcessorKey(const GrBatchTracker& bt, | 619 virtual void getGLProcessorKey(const GrBatchTracker& bt, |
| 620 const GrGLCaps& caps, | 620 const GrGLCaps& caps, |
| 621 GrProcessorKeyBuilder* b) const SK_OVERRIDE { | 621 GrProcessorKeyBuilder* b) const SK_OVERRIDE { |
| 622 GLProcessor::GenKey(*this, bt, caps, b); | 622 GLProcessor::GenKey(*this, bt, caps, b); |
| 623 } | 623 } |
| 624 | 624 |
| 625 virtual GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) co
nst SK_OVERRIDE { | 625 GrGLGeometryProcessor* createGLInstance(const GrBatchTracker& bt) const SK_O
VERRIDE { |
| 626 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 626 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
| 627 } | 627 } |
| 628 | 628 |
| 629 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { | 629 void initBatchTracker(GrBatchTracker* bt, const InitBT& init) const SK_OVERR
IDE { |
| 630 BatchTracker* local = bt->cast<BatchTracker>(); | 630 BatchTracker* local = bt->cast<BatchTracker>(); |
| 631 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 631 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
| 632 local->fUsesLocalCoords = init.fUsesLocalCoords; | 632 local->fUsesLocalCoords = init.fUsesLocalCoords; |
| 633 } | 633 } |
| 634 | 634 |
| 635 bool onCanMakeEqual(const GrBatchTracker& m, | 635 bool onCanMakeEqual(const GrBatchTracker& m, |
| 636 const GrGeometryProcessor& that, | 636 const GrGeometryProcessor& that, |
| 637 const GrBatchTracker& t) const SK_OVERRIDE { | 637 const GrBatchTracker& t) const SK_OVERRIDE { |
| 638 const BatchTracker& mine = m.cast<BatchTracker>(); | 638 const BatchTracker& mine = m.cast<BatchTracker>(); |
| 639 const BatchTracker& theirs = t.cast<BatchTracker>(); | 639 const BatchTracker& theirs = t.cast<BatchTracker>(); |
| 640 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, | 640 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, |
| 641 that, theirs.fUsesLocalCoords) && | 641 that, theirs.fUsesLocalCoords) && |
| 642 CanCombineOutput(mine.fInputColorType, mine.fColor, | 642 CanCombineOutput(mine.fInputColorType, mine.fColor, |
| 643 theirs.fInputColorType, theirs.fColor); | 643 theirs.fInputColorType, theirs.fColor); |
| 644 } | 644 } |
| 645 | 645 |
| 646 private: | 646 private: |
| 647 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix) | 647 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix) |
| 648 : INHERITED(color, SkMatrix::I(), localMatrix) { | 648 : INHERITED(color, SkMatrix::I(), localMatrix) { |
| 649 this->initClassID<QuadEdgeEffect>(); | 649 this->initClassID<QuadEdgeEffect>(); |
| 650 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); | 650 fInPosition = &this->addVertexAttrib(GrAttribute("inPosition", kVec2f_Gr
VertexAttribType)); |
| 651 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr
VertexAttribType)); | 651 fInQuadEdge = &this->addVertexAttrib(GrAttribute("inQuadEdge", kVec4f_Gr
VertexAttribType)); |
| 652 } | 652 } |
| 653 | 653 |
| 654 virtual bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { | 654 bool onIsEqual(const GrGeometryProcessor& other) const SK_OVERRIDE { |
| 655 return true; | 655 return true; |
| 656 } | 656 } |
| 657 | 657 |
| 658 virtual void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const
SK_OVERRIDE { | 658 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const SK_OVERR
IDE { |
| 659 out->setUnknownSingleComponent(); | 659 out->setUnknownSingleComponent(); |
| 660 } | 660 } |
| 661 | 661 |
| 662 struct BatchTracker { | 662 struct BatchTracker { |
| 663 GrGPInput fInputColorType; | 663 GrGPInput fInputColorType; |
| 664 GrColor fColor; | 664 GrColor fColor; |
| 665 bool fUsesLocalCoords; | 665 bool fUsesLocalCoords; |
| 666 }; | 666 }; |
| 667 | 667 |
| 668 const GrAttribute* fInPosition; | 668 const GrAttribute* fInPosition; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 vOffset, // start vertex | 782 vOffset, // start vertex |
| 783 0, // start index | 783 0, // start index |
| 784 draw.fVertexCnt, | 784 draw.fVertexCnt, |
| 785 draw.fIndexCnt, | 785 draw.fIndexCnt, |
| 786 &devBounds); | 786 &devBounds); |
| 787 vOffset += draw.fVertexCnt; | 787 vOffset += draw.fVertexCnt; |
| 788 } | 788 } |
| 789 | 789 |
| 790 return true; | 790 return true; |
| 791 } | 791 } |
| OLD | NEW |