Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: src/gpu/batches/GrAAConvexPathRenderer.cpp

Issue 1345393003: Revert of add a ClassID function to GrBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
737 struct Geometry { 736 struct Geometry {
738 GrColor fColor; 737 GrColor fColor;
739 SkMatrix fViewMatrix; 738 SkMatrix fViewMatrix;
740 SkPath fPath; 739 SkPath fPath;
741 }; 740 };
742 741
743 static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPa thBatch(geometry); } 742 static GrDrawBatch* Create(const Geometry& geometry) { return new AAConvexPa thBatch(geometry); }
744 743
745 const char* name() const override { return "AAConvexBatch"; } 744 const char* name() const override { return "AAConvexBatch"; }
746 745
747 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { 746 void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
748 // When this is called on a batch, there is only one geometry bundle 747 // When this is called on a batch, there is only one geometry bundle
749 out->setKnownFourComponents(fGeoData[0].fColor); 748 out->setKnownFourComponents(fGeoData[0].fColor);
750 } 749 }
751 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { 750 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
752 out->setUnknownSingleComponent(); 751 out->setUnknownSingleComponent();
753 } 752 }
754 753
755 private: 754 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
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) : INHERITED(ClassID()) { 924 AAConvexPathBatch(const Geometry& geometry) {
925 this->initClassID<AAConvexPathBatch>();
925 fGeoData.push_back(geometry); 926 fGeoData.push_back(geometry);
926 927
927 // compute bounds 928 // compute bounds
928 fBounds = geometry.fPath.getBounds(); 929 fBounds = geometry.fPath.getBounds();
929 geometry.fViewMatrix.mapRect(&fBounds); 930 geometry.fViewMatrix.mapRect(&fBounds);
930 } 931 }
931 932
932 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { 933 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override {
933 AAConvexPathBatch* that = t->cast<AAConvexPathBatch>(); 934 AAConvexPathBatch* that = t->cast<AAConvexPathBatch>();
934 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(), 935 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi peline(),
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 GrColor fColor; 972 GrColor fColor;
972 bool fUsesLocalCoords; 973 bool fUsesLocalCoords;
973 bool fColorIgnored; 974 bool fColorIgnored;
974 bool fCoverageIgnored; 975 bool fCoverageIgnored;
975 bool fLinesOnly; 976 bool fLinesOnly;
976 bool fCanTweakAlphaForCoverage; 977 bool fCanTweakAlphaForCoverage;
977 }; 978 };
978 979
979 BatchTracker fBatch; 980 BatchTracker fBatch;
980 SkSTArray<1, Geometry, true> fGeoData; 981 SkSTArray<1, Geometry, true> fGeoData;
981
982 typedef GrVertexBatch INHERITED;
983 }; 982 };
984 983
985 bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { 984 bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
986 if (args.fPath->isEmpty()) { 985 if (args.fPath->isEmpty()) {
987 return true; 986 return true;
988 } 987 }
989 988
990 AAConvexPathBatch::Geometry geometry; 989 AAConvexPathBatch::Geometry geometry;
991 geometry.fColor = args.fColor; 990 geometry.fColor = args.fColor;
992 geometry.fViewMatrix = *args.fViewMatrix; 991 geometry.fViewMatrix = *args.fViewMatrix;
(...skipping 13 matching lines...) Expand all
1006 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { 1005 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) {
1007 AAConvexPathBatch::Geometry geometry; 1006 AAConvexPathBatch::Geometry geometry;
1008 geometry.fColor = GrRandomColor(random); 1007 geometry.fColor = GrRandomColor(random);
1009 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 1008 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
1010 geometry.fPath = GrTest::TestPathConvex(random); 1009 geometry.fPath = GrTest::TestPathConvex(random);
1011 1010
1012 return AAConvexPathBatch::Create(geometry); 1011 return AAConvexPathBatch::Create(geometry);
1013 } 1012 }
1014 1013
1015 #endif 1014 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698