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