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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 // Setup GrGeometryProcessor | 786 // Setup GrGeometryProcessor |
787 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF
orCoverage, | 787 SkAutoTUnref<const GrGeometryProcessor> gp(create_fill_gp(canTweakAlphaF
orCoverage, |
788 this->viewMatr
ix(), | 788 this->viewMatr
ix(), |
789 this->usesLoca
lCoords(), | 789 this->usesLoca
lCoords(), |
790 this->coverage
Ignored())); | 790 this->coverage
Ignored())); |
791 if (!gp) { | 791 if (!gp) { |
792 SkDebugf("Could not create GrGeometryProcessor\n"); | 792 SkDebugf("Could not create GrGeometryProcessor\n"); |
793 return; | 793 return; |
794 } | 794 } |
795 | 795 |
796 target->initDraw(gp, this->pipeline()); | 796 target->initDraw(gp, kTriangles_GrPrimitiveType); |
797 | 797 |
798 size_t vertexStride = gp->getVertexStride(); | 798 size_t vertexStride = gp->getVertexStride(); |
799 | 799 |
800 SkASSERT(canTweakAlphaForCoverage ? | 800 SkASSERT(canTweakAlphaForCoverage ? |
801 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : | 801 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorAt
tr) : |
802 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); | 802 vertexStride == sizeof(GrDefaultGeoProcFactory::PositionColorCo
verageAttr)); |
803 | 803 |
804 GrAAConvexTessellator tess; | 804 GrAAConvexTessellator tess; |
805 | 805 |
806 int instanceCount = fGeoData.count(); | 806 int instanceCount = fGeoData.count(); |
(...skipping 22 matching lines...) Expand all Loading... |
829 | 829 |
830 uint16_t* idxs = target->makeIndexSpace(tess.numIndices(), &indexBuf
fer, &firstIndex); | 830 uint16_t* idxs = target->makeIndexSpace(tess.numIndices(), &indexBuf
fer, &firstIndex); |
831 if (!idxs) { | 831 if (!idxs) { |
832 SkDebugf("Could not allocate indices\n"); | 832 SkDebugf("Could not allocate indices\n"); |
833 return; | 833 return; |
834 } | 834 } |
835 | 835 |
836 extract_verts(tess, verts, vertexStride, args.fColor, idxs, canTweak
AlphaForCoverage); | 836 extract_verts(tess, verts, vertexStride, args.fColor, idxs, canTweak
AlphaForCoverage); |
837 | 837 |
838 GrVertices info; | 838 GrVertices info; |
839 info.initIndexed(kTriangles_GrPrimitiveType, | 839 info.initIndexed(vertexBuffer, indexBuffer, |
840 vertexBuffer, indexBuffer, | |
841 firstVertex, firstIndex, | 840 firstVertex, firstIndex, |
842 tess.numPts(), tess.numIndices()); | 841 tess.numPts(), tess.numIndices()); |
843 target->draw(info); | 842 target->draw(info); |
844 } | 843 } |
845 } | 844 } |
846 | 845 |
847 void onPrepareDraws(Target* target) const override { | 846 void onPrepareDraws(Target* target) const override { |
848 #ifndef SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS | 847 #ifndef SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS |
849 if (this->linesOnly()) { | 848 if (this->linesOnly()) { |
850 this->prepareLinesOnlyDraws(target); | 849 this->prepareLinesOnlyDraws(target); |
851 return; | 850 return; |
852 } | 851 } |
853 #endif | 852 #endif |
854 | 853 |
855 int instanceCount = fGeoData.count(); | 854 int instanceCount = fGeoData.count(); |
856 | 855 |
857 SkMatrix invert; | 856 SkMatrix invert; |
858 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { | 857 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { |
859 SkDebugf("Could not invert viewmatrix\n"); | 858 SkDebugf("Could not invert viewmatrix\n"); |
860 return; | 859 return; |
861 } | 860 } |
862 | 861 |
863 // Setup GrGeometryProcessor | 862 // Setup GrGeometryProcessor |
864 SkAutoTUnref<GrGeometryProcessor> quadProcessor( | 863 SkAutoTUnref<GrGeometryProcessor> quadProcessor( |
865 QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoo
rds())); | 864 QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoo
rds())); |
866 | 865 |
867 target->initDraw(quadProcessor, this->pipeline()); | 866 target->initDraw(quadProcessor, kTriangles_GrPrimitiveType); |
868 | 867 |
869 // TODO generate all segments for all paths and use one vertex buffer | 868 // TODO generate all segments for all paths and use one vertex buffer |
870 for (int i = 0; i < instanceCount; i++) { | 869 for (int i = 0; i < instanceCount; i++) { |
871 const Geometry& args = fGeoData[i]; | 870 const Geometry& args = fGeoData[i]; |
872 | 871 |
873 // We use the fact that SkPath::transform path does subdivision base
d on | 872 // We use the fact that SkPath::transform path does subdivision base
d on |
874 // perspective. Otherwise, we apply the view matrix when copying to
the | 873 // perspective. Otherwise, we apply the view matrix when copying to
the |
875 // segment representation. | 874 // segment representation. |
876 const SkMatrix* viewMatrix = &args.fViewMatrix; | 875 const SkMatrix* viewMatrix = &args.fViewMatrix; |
877 | 876 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 return; | 920 return; |
922 } | 921 } |
923 | 922 |
924 SkSTArray<kPreallocDrawCnt, Draw, true> draws; | 923 SkSTArray<kPreallocDrawCnt, Draw, true> draws; |
925 create_vertices(segments, fanPt, &draws, verts, idxs); | 924 create_vertices(segments, fanPt, &draws, verts, idxs); |
926 | 925 |
927 GrVertices vertices; | 926 GrVertices vertices; |
928 | 927 |
929 for (int j = 0; j < draws.count(); ++j) { | 928 for (int j = 0; j < draws.count(); ++j) { |
930 const Draw& draw = draws[j]; | 929 const Draw& draw = draws[j]; |
931 vertices.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, i
ndexBuffer, | 930 vertices.initIndexed(vertexBuffer, indexBuffer, firstVertex, fir
stIndex, |
932 firstVertex, firstIndex, draw.fVertexCnt, d
raw.fIndexCnt); | 931 draw.fVertexCnt, draw.fIndexCnt); |
933 target->draw(vertices); | 932 target->draw(vertices); |
934 firstVertex += draw.fVertexCnt; | 933 firstVertex += draw.fVertexCnt; |
935 firstIndex += draw.fIndexCnt; | 934 firstIndex += draw.fIndexCnt; |
936 } | 935 } |
937 } | 936 } |
938 } | 937 } |
939 | 938 |
940 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 939 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
941 | 940 |
942 AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) { | 941 AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { | 1024 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { |
1026 AAConvexPathBatch::Geometry geometry; | 1025 AAConvexPathBatch::Geometry geometry; |
1027 geometry.fColor = GrRandomColor(random); | 1026 geometry.fColor = GrRandomColor(random); |
1028 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); | 1027 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); |
1029 geometry.fPath = GrTest::TestPathConvex(random); | 1028 geometry.fPath = GrTest::TestPathConvex(random); |
1030 | 1029 |
1031 return AAConvexPathBatch::Create(geometry); | 1030 return AAConvexPathBatch::Create(geometry); |
1032 } | 1031 } |
1033 | 1032 |
1034 #endif | 1033 #endif |
OLD | NEW |