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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 const GrGLSLCaps&) const ov
erride { | 634 const GrGLSLCaps&) const ov
erride { |
635 return SkNEW_ARGS(GLProcessor, (*this, bt)); | 635 return SkNEW_ARGS(GLProcessor, (*this, bt)); |
636 } | 636 } |
637 | 637 |
638 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { | 638 void initBatchTracker(GrBatchTracker* bt, const GrPipelineInfo& init) const
override { |
639 BatchTracker* local = bt->cast<BatchTracker>(); | 639 BatchTracker* local = bt->cast<BatchTracker>(); |
640 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); | 640 local->fInputColorType = GetColorInputType(&local->fColor, this->color()
, init, false); |
641 local->fUsesLocalCoords = init.fUsesLocalCoords; | 641 local->fUsesLocalCoords = init.fUsesLocalCoords; |
642 } | 642 } |
643 | 643 |
644 bool onCanMakeEqual(const GrBatchTracker& m, | |
645 const GrGeometryProcessor& that, | |
646 const GrBatchTracker& t) const override { | |
647 const BatchTracker& mine = m.cast<BatchTracker>(); | |
648 const BatchTracker& theirs = t.cast<BatchTracker>(); | |
649 return CanCombineLocalMatrices(*this, mine.fUsesLocalCoords, | |
650 that, theirs.fUsesLocalCoords) && | |
651 CanCombineOutput(mine.fInputColorType, mine.fColor, | |
652 theirs.fInputColorType, theirs.fColor); | |
653 } | |
654 | |
655 private: | 644 private: |
656 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix) | 645 QuadEdgeEffect(GrColor color, const SkMatrix& localMatrix) |
657 : INHERITED(color, SkMatrix::I(), localMatrix) { | 646 : INHERITED(color, SkMatrix::I(), localMatrix) { |
658 this->initClassID<QuadEdgeEffect>(); | 647 this->initClassID<QuadEdgeEffect>(); |
659 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); | 648 fInPosition = &this->addVertexAttrib(Attribute("inPosition", kVec2f_GrVe
rtexAttribType)); |
660 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe
rtexAttribType)); | 649 fInQuadEdge = &this->addVertexAttrib(Attribute("inQuadEdge", kVec4f_GrVe
rtexAttribType)); |
661 } | 650 } |
662 | 651 |
663 bool onIsEqual(const GrGeometryProcessor& other) const override { | |
664 return true; | |
665 } | |
666 | |
667 void onGetInvariantOutputCoverage(GrInitInvariantOutput* out) const override
{ | |
668 out->setUnknownSingleComponent(); | |
669 } | |
670 | |
671 struct BatchTracker { | 652 struct BatchTracker { |
672 GrGPInput fInputColorType; | 653 GrGPInput fInputColorType; |
673 GrColor fColor; | 654 GrColor fColor; |
674 bool fUsesLocalCoords; | 655 bool fUsesLocalCoords; |
675 }; | 656 }; |
676 | 657 |
677 const Attribute* fInPosition; | 658 const Attribute* fInPosition; |
678 const Attribute* fInQuadEdge; | 659 const Attribute* fInQuadEdge; |
679 | 660 |
680 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; | 661 GR_DECLARE_GEOMETRY_PROCESSOR_TEST; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 } | 721 } |
741 } | 722 } |
742 | 723 |
743 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, | 724 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, |
744 const SkMatrix& localMatrix) { | 725 const SkMatrix& localMatrix) { |
745 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; | 726 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; |
746 if (!tweakAlphaForCoverage) { | 727 if (!tweakAlphaForCoverage) { |
747 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; | 728 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; |
748 } | 729 } |
749 | 730 |
750 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, SkMatrix::I(),
localMatrix, | 731 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, SkMatrix::I(),
localMatrix); |
751 false, 0xff); | |
752 } | 732 } |
753 | 733 |
754 class AAConvexPathBatch : public GrBatch { | 734 class AAConvexPathBatch : public GrBatch { |
755 public: | 735 public: |
756 struct Geometry { | 736 struct Geometry { |
757 GrColor fColor; | 737 GrColor fColor; |
758 SkMatrix fViewMatrix; | 738 SkMatrix fViewMatrix; |
759 SkPath fPath; | 739 SkPath fPath; |
760 }; | 740 }; |
761 | 741 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 BATCH_TEST_DEFINE(AAConvexPath) { | 1025 BATCH_TEST_DEFINE(AAConvexPath) { |
1046 AAConvexPathBatch::Geometry geometry; | 1026 AAConvexPathBatch::Geometry geometry; |
1047 geometry.fColor = GrRandomColor(random); | 1027 geometry.fColor = GrRandomColor(random); |
1048 geometry.fViewMatrix = GrTest::TestMatrix(random); | 1028 geometry.fViewMatrix = GrTest::TestMatrix(random); |
1049 geometry.fPath = GrTest::TestPathConvex(random); | 1029 geometry.fPath = GrTest::TestPathConvex(random); |
1050 | 1030 |
1051 return AAConvexPathBatch::Create(geometry); | 1031 return AAConvexPathBatch::Create(geometry); |
1052 } | 1032 } |
1053 | 1033 |
1054 #endif | 1034 #endif |
OLD | NEW |