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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 coverageType = Coverage::kSolid_Type; | 732 coverageType = Coverage::kSolid_Type; |
733 } else { | 733 } else { |
734 coverageType = Coverage::kAttribute_Type; | 734 coverageType = Coverage::kAttribute_Type; |
735 } | 735 } |
736 Coverage coverage(coverageType); | 736 Coverage coverage(coverageType); |
737 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : | 737 LocalCoords localCoords(usesLocalCoords ? LocalCoords::kUsePosition_Type : |
738 LocalCoords::kUnused_Type); | 738 LocalCoords::kUnused_Type); |
739 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); | 739 return CreateForDeviceSpace(color, coverage, localCoords, viewMatrix); |
740 } | 740 } |
741 | 741 |
742 class AAConvexPathBatch : public GrBatch { | 742 class AAConvexPathBatch : public GrVertexBatch { |
743 public: | 743 public: |
744 struct Geometry { | 744 struct Geometry { |
745 GrColor fColor; | 745 GrColor fColor; |
746 SkMatrix fViewMatrix; | 746 SkMatrix fViewMatrix; |
747 SkPath fPath; | 747 SkPath fPath; |
748 }; | 748 }; |
749 | 749 |
750 static GrBatch* Create(const Geometry& geometry) { | 750 static GrDrawBatch* Create(const Geometry& geometry) { |
751 return SkNEW_ARGS(AAConvexPathBatch, (geometry)); | 751 return SkNEW_ARGS(AAConvexPathBatch, (geometry)); |
752 } | 752 } |
753 | 753 |
754 const char* name() const override { return "AAConvexBatch"; } | 754 const char* name() const override { return "AAConvexBatch"; } |
755 | 755 |
756 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { | 756 void getInvariantOutputColor(GrInitInvariantOutput* out) const override { |
757 // When this is called on a batch, there is only one geometry bundle | 757 // When this is called on a batch, there is only one geometry bundle |
758 out->setKnownFourComponents(fGeoData[0].fColor); | 758 out->setKnownFourComponents(fGeoData[0].fColor); |
759 } | 759 } |
760 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { | 760 void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 AAConvexPathBatch(const Geometry& geometry) { | 934 AAConvexPathBatch(const Geometry& geometry) { |
935 this->initClassID<AAConvexPathBatch>(); | 935 this->initClassID<AAConvexPathBatch>(); |
936 fGeoData.push_back(geometry); | 936 fGeoData.push_back(geometry); |
937 | 937 |
938 // compute bounds | 938 // compute bounds |
939 fBounds = geometry.fPath.getBounds(); | 939 fBounds = geometry.fPath.getBounds(); |
940 geometry.fViewMatrix.mapRect(&fBounds); | 940 geometry.fViewMatrix.mapRect(&fBounds); |
941 } | 941 } |
942 | 942 |
943 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { | 943 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { |
944 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *t->pipel
ine(), t->bounds(), | 944 AAConvexPathBatch* that = t->cast<AAConvexPathBatch>(); |
945 caps)) { | 945 if (!GrPipeline::CanCombine(*this->pipeline(), this->bounds(), *that->pi
peline(), |
| 946 that->bounds(), caps)) { |
946 return false; | 947 return false; |
947 } | 948 } |
948 | 949 |
949 AAConvexPathBatch* that = t->cast<AAConvexPathBatch>(); | |
950 | |
951 if (this->color() != that->color()) { | 950 if (this->color() != that->color()) { |
952 return false; | 951 return false; |
953 } | 952 } |
954 | 953 |
955 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); | 954 SkASSERT(this->usesLocalCoords() == that->usesLocalCoords()); |
956 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { | 955 if (this->usesLocalCoords() && !this->viewMatrix().cheapEqualTo(that->vi
ewMatrix())) { |
957 return false; | 956 return false; |
958 } | 957 } |
959 | 958 |
960 if (this->linesOnly() != that->linesOnly()) { | 959 if (this->linesOnly() != that->linesOnly()) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { | 994 bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) { |
996 if (args.fPath->isEmpty()) { | 995 if (args.fPath->isEmpty()) { |
997 return true; | 996 return true; |
998 } | 997 } |
999 | 998 |
1000 AAConvexPathBatch::Geometry geometry; | 999 AAConvexPathBatch::Geometry geometry; |
1001 geometry.fColor = args.fColor; | 1000 geometry.fColor = args.fColor; |
1002 geometry.fViewMatrix = *args.fViewMatrix; | 1001 geometry.fViewMatrix = *args.fViewMatrix; |
1003 geometry.fPath = *args.fPath; | 1002 geometry.fPath = *args.fPath; |
1004 | 1003 |
1005 SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry)); | 1004 SkAutoTUnref<GrDrawBatch> batch(AAConvexPathBatch::Create(geometry)); |
1006 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); | 1005 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); |
1007 | 1006 |
1008 return true; | 1007 return true; |
1009 | 1008 |
1010 } | 1009 } |
1011 | 1010 |
1012 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 1011 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
1013 | 1012 |
1014 #ifdef GR_TEST_UTILS | 1013 #ifdef GR_TEST_UTILS |
1015 | 1014 |
1016 BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1015 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
1017 AAConvexPathBatch::Geometry geometry; | 1016 AAConvexPathBatch::Geometry geometry; |
1018 geometry.fColor = GrRandomColor(random); | 1017 geometry.fColor = GrRandomColor(random); |
1019 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1018 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
1020 geometry.fPath = GrTest::TestPathConvex(random); | 1019 geometry.fPath = GrTest::TestPathConvex(random); |
1021 | 1020 |
1022 return AAConvexPathBatch::Create(geometry); | 1021 return AAConvexPathBatch::Create(geometry); |
1023 } | 1022 } |
1024 | 1023 |
1025 #endif | 1024 #endif |
OLD | NEW |