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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 tess.coverage(i); | 715 tess.coverage(i); |
716 } | 716 } |
717 } | 717 } |
718 | 718 |
719 for (int i = 0; i < tess.numIndices(); ++i) { | 719 for (int i = 0; i < tess.numIndices(); ++i) { |
720 idxs[i] = tess.index(i); | 720 idxs[i] = tess.index(i); |
721 } | 721 } |
722 } | 722 } |
723 | 723 |
724 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, | 724 static const GrGeometryProcessor* create_fill_gp(bool tweakAlphaForCoverage, |
725 const SkMatrix& localMatrix, | 725 const SkMatrix& viewMatrix, |
726 bool usesLocalCoords, | 726 bool usesLocalCoords, |
727 bool coverageIgnored) { | 727 bool coverageIgnored) { |
728 uint32_t flags = GrDefaultGeoProcFactory::kColor_GPType; | 728 using namespace GrDefaultGeoProcFactory; |
729 if (!tweakAlphaForCoverage) { | 729 |
730 flags |= GrDefaultGeoProcFactory::kCoverage_GPType; | 730 Color color(Color::kAttribute_Type); |
731 Coverage::Type coverageType; | |
732 if (coverageIgnored) { | |
733 coverageType = Coverage::kNone_Type; | |
734 } else if (tweakAlphaForCoverage) { | |
735 coverageType = Coverage::kSolid_Type; | |
736 } else { | |
737 coverageType = Coverage::kAttribute_Type; | |
731 } | 738 } |
739 Coverage coverage(coverageType); | |
732 | 740 |
733 return GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE, usesLocalCoords , coverageIgnored, | 741 if (usesLocalCoords) { |
734 SkMatrix::I(), localMatrix); | 742 LocalCoords localCoords(LocalCoords::kUsePosition_Type); |
bsalomon
2015/07/28 20:14:48
Let's see if we can always use CreateForDeviceSpac
| |
743 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); | |
744 } else { | |
robertphillips
2015/07/29 13:09:44
extra space ?
| |
745 LocalCoords localCoords(LocalCoords::kUnused_Type); | |
746 return Create(color, coverage, localCoords); | |
747 } | |
735 } | 748 } |
736 | 749 |
737 class AAConvexPathBatch : public GrBatch { | 750 class AAConvexPathBatch : public GrBatch { |
738 public: | 751 public: |
739 struct Geometry { | 752 struct Geometry { |
740 GrColor fColor; | 753 GrColor fColor; |
741 SkMatrix fViewMatrix; | 754 SkMatrix fViewMatrix; |
742 SkPath fPath; | 755 SkPath fPath; |
743 }; | 756 }; |
744 | 757 |
(...skipping 23 matching lines...) Expand all Loading... | |
768 fBatch.fColor = fGeoData[0].fColor; | 781 fBatch.fColor = fGeoData[0].fColor; |
769 fBatch.fUsesLocalCoords = init.readsLocalCoords(); | 782 fBatch.fUsesLocalCoords = init.readsLocalCoords(); |
770 fBatch.fCoverageIgnored = !init.readsCoverage(); | 783 fBatch.fCoverageIgnored = !init.readsCoverage(); |
771 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks(); | 784 fBatch.fLinesOnly = SkPath::kLine_SegmentMask == fGeoData[0].fPath.getSe gmentMasks(); |
772 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); | 785 fBatch.fCanTweakAlphaForCoverage = init.canTweakAlphaForCoverage(); |
773 } | 786 } |
774 | 787 |
775 void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) { | 788 void generateGeometryLinesOnly(GrBatchTarget* batchTarget, const GrPipeline* pipeline) { |
776 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); | 789 bool canTweakAlphaForCoverage = this->canTweakAlphaForCoverage(); |
777 | 790 |
778 SkMatrix invert; | 791 // Setup GrGeometryProcessor |
779 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { | 792 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF orCoverage, |
780 SkDebugf("Could not invert viewmatrix\n"); | 793 this->viewMatr ix(), |
794 this->usesLoca lCoords(), | |
795 this->coverage Ignored())); | |
796 if (!gp) { | |
797 SkDebugf("Could not create GrGeometryProcessor\n"); | |
781 return; | 798 return; |
782 } | 799 } |
783 | 800 |
784 // Setup GrGeometryProcessor | |
785 SkAutoTUnref<const GrGeometryProcessor> gp( | |
786 create_fill_gp(canTweakAlphaForC overage, invert, | |
787 this->usesLocalCo ords(), | |
788 this->coverageIgn ored())); | |
789 | |
790 batchTarget->initDraw(gp, pipeline); | 801 batchTarget->initDraw(gp, pipeline); |
791 | 802 |
792 size_t vertexStride = gp->getVertexStride(); | 803 size_t vertexStride = gp->getVertexStride(); |
793 | 804 |
794 SkASSERT(canTweakAlphaForCoverage ? | 805 SkASSERT(canTweakAlphaForCoverage ? |
795 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : | 806 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt tr) : |
796 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); | 807 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo verageAttr)); |
797 | 808 |
798 GrAAConvexTessellator tess; | 809 GrAAConvexTessellator tess; |
799 | 810 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1018 BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1029 BATCH_TEST_DEFINE(AAConvexPathBatch) { |
1019 AAConvexPathBatch::Geometry geometry; | 1030 AAConvexPathBatch::Geometry geometry; |
1020 geometry.fColor = GrRandomColor(random); | 1031 geometry.fColor = GrRandomColor(random); |
1021 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1032 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
1022 geometry.fPath = GrTest::TestPathConvex(random); | 1033 geometry.fPath = GrTest::TestPathConvex(random); |
1023 | 1034 |
1024 return AAConvexPathBatch::Create(geometry); | 1035 return AAConvexPathBatch::Create(geometry); |
1025 } | 1036 } |
1026 | 1037 |
1027 #endif | 1038 #endif |
OLD | NEW |