| 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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 coverageType = Coverage::kAttribute_Type; | 726 coverageType = Coverage::kAttribute_Type; |
| 727 } | 727 } |
| 728 Coverage coverage(coverageType); | 728 Coverage coverage(coverageType); |
| 729 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : | 729 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : |
| 730 LocalCoords::kUnused_Type); | 730 LocalCoords::kUnused_Type); |
| 731 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); | 731 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); |
| 732 } | 732 } |
| 733 | 733 |
| 734 class AAConvexPathBatch : public GrVertexBatch { | 734 class AAConvexPathBatch : public GrVertexBatch { |
| 735 public: | 735 public: |
| 736 DEFINE_BATCH_CLASS_ID |
| 736 struct Geometry { | 737 struct Geometry { |
| 737 GrColor fColor; | 738 GrColor fColor; |
| 738 SkMatrix fViewMatrix; | 739 SkMatrix fViewMatrix; |
| 739 SkPath fPath; | 740 SkPath fPath; |
| 740 }; | 741 }; |
| 741 | 742 |
| 742 static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPa
thBatch(geometry); } | 743 static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPa
thBatch(geometry); } |
| 743 | 744 |
| 744 const char* name() const override { return "AAConvexBatch"; } | 745 const char* name() const override { return "AAConvexBatch"; } |
| 745 | 746 |
| 746 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 747 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
| 747 // When this is called on a batch, there is only one geometry bundle | 748 // When this is called on a batch, there is only one geometry bundle |
| 748 out->setKnownFourComponents(fGeoData[0].fColor); | 749 out->setKnownFourComponents(fGeoData[0].fColor); |
| 749 } | 750 } |
| 750 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 751 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
| 751 out->setUnknownSingleComponent(); | 752 out->setUnknownSingleComponent(); |
| 752 } | 753 } |
| 753 | 754 |
| 754 private: | 755 private: |
| 755 | |
| 756 void initBatchTracker(const GrPipelineOptimizations& opt) override { | 756 void initBatchTracker(const GrPipelineOptimizations& opt) override { |
| 757 // Handle any color overrides | 757 // Handle any color overrides |
| 758 if (!opt.readsColor()) { | 758 if (!opt.readsColor()) { |
| 759 fGeoData[0].fColor = GrColor_ILLEGAL; | 759 fGeoData[0].fColor = GrColor_ILLEGAL; |
| 760 } | 760 } |
| 761 opt.getOverrideColorIfSet(&fGeoData[0].fColor); | 761 opt.getOverrideColorIfSet(&fGeoData[0].fColor); |
| 762 | 762 |
| 763 // setup batch properties | 763 // setup batch properties |
| 764 fBatch.fColorIgnored = !opt.readsColor(); | 764 fBatch.fColorIgnored = !opt.readsColor(); |
| 765 fBatch.fColor = fGeoData[0].fColor; | 765 fBatch.fColor = fGeoData[0].fColor; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 firstVertex, firstIndex, draw.fVertexCnt, d
raw.fIndexCnt); | 914 firstVertex, firstIndex, draw.fVertexCnt, d
raw.fIndexCnt); |
| 915 target->draw(vertices); | 915 target->draw(vertices); |
| 916 firstVertex += draw.fVertexCnt; | 916 firstVertex += draw.fVertexCnt; |
| 917 firstIndex += draw.fIndexCnt; | 917 firstIndex += draw.fIndexCnt; |
| 918 } | 918 } |
| 919 } | 919 } |
| 920 } | 920 } |
| 921 | 921 |
| 922 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 922 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
| 923 | 923 |
| 924 AAConvexPathBatch(const Geometry& geometry) { | 924 AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) { |
| 925 this->initClassID<AAConvexPathBatch>(); | |
| 926 fGeoData.push_back(geometry); | 925 fGeoData.push_back(geometry); |
| 927 | 926 |
| 928 // compute bounds | 927 // compute bounds |
| 929 fBounds = geometry.fPath.getBounds(); | 928 fBounds = geometry.fPath.getBounds(); |
| 930 geometry.fViewMatrix.mapRect(&fBounds); | 929 geometry.fViewMatrix.mapRect(&fBounds); |
| 931 } | 930 } |
| 932 | 931 |
| 933 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 932 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
| 934 AAConvexPathBatch* that = t->cast<AAConvexPathBatch>(); | 933 AAConvexPathBatch* that = t->cast<AAConvexPathBatch>(); |
| 935 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), | 934 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 GrColor fColor; | 971 GrColor fColor; |
| 973 bool fUsesLocalCoords; | 972 bool fUsesLocalCoords; |
| 974 bool fColorIgnored; | 973 bool fColorIgnored; |
| 975 bool fCoverageIgnored; | 974 bool fCoverageIgnored; |
| 976 bool fLinesOnly; | 975 bool fLinesOnly; |
| 977 bool fCanTweakAlphaForCoverage; | 976 bool fCanTweakAlphaForCoverage; |
| 978 }; | 977 }; |
| 979 | 978 |
| 980 BatchTracker fBatch; | 979 BatchTracker fBatch; |
| 981 SkSTArray<1, Geometry, true> fGeoData; | 980 SkSTArray<1, Geometry, true> fGeoData; |
| 981 |
| 982 typedef GrVertexBatch INHERITED; |
| 982 }; | 983 }; |
| 983 | 984 |
| 984 bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { | 985 bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { |
| 985 if (args.fPath->isEmpty()) { | 986 if (args.fPath->isEmpty()) { |
| 986 return true; | 987 return true; |
| 987 } | 988 } |
| 988 | 989 |
| 989 AAConvexPathBatch::Geometry geometry; | 990 AAConvexPathBatch::Geometry geometry; |
| 990 geometry.fColor = args.fColor; | 991 geometry.fColor = args.fColor; |
| 991 geometry.fViewMatrix = *args.fViewMatrix; | 992 geometry.fViewMatrix = *args.fViewMatrix; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1005 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1006 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
| 1006 AAConvexPathBatch::Geometry geometry; | 1007 AAConvexPathBatch::Geometry geometry; |
| 1007 geometry.fColor = GrRandomColor(random); | 1008 geometry.fColor = GrRandomColor(random); |
| 1008 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1009 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
| 1009 geometry.fPath = GrTest::TestPathConvex(random); | 1010 geometry.fPath = GrTest::TestPathConvex(random); |
| 1010 | 1011 |
| 1011 return AAConvexPathBatch::Create(geometry); | 1012 return AAConvexPathBatch::Create(geometry); |
| 1012 } | 1013 } |
| 1013 | 1014 |
| 1014 #endif | 1015 #endif |
| OLD | NEW |