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

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

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nit Created 4 years, 9 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/GrVertices.h ('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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
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 21 matching lines...) Expand all
828 int firstIndex; 828 int firstIndex;
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 GrMesh mesh;
839 info.initIndexed(kTriangles_GrPrimitiveType, 839 mesh.initIndexed(kTriangles_GrPrimitiveType,
840 vertexBuffer, indexBuffer, 840 vertexBuffer, indexBuffer,
841 firstVertex, firstIndex, 841 firstVertex, firstIndex,
842 tess.numPts(), tess.numIndices()); 842 tess.numPts(), tess.numIndices());
843 target->draw(info); 843 target->draw(mesh);
844 } 844 }
845 } 845 }
846 846
847 void onPrepareDraws(Target* target) const override { 847 void onPrepareDraws(Target* target) const override {
848 #ifndef SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS 848 #ifndef SK_IGNORE_LINEONLY_AA_CONVEX_PATH_OPTS
849 if (this->linesOnly()) { 849 if (this->linesOnly()) {
850 this->prepareLinesOnlyDraws(target); 850 this->prepareLinesOnlyDraws(target);
851 return; 851 return;
852 } 852 }
853 #endif 853 #endif
854 854
855 int instanceCount = fGeoData.count(); 855 int instanceCount = fGeoData.count();
856 856
857 SkMatrix invert; 857 SkMatrix invert;
858 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) { 858 if (this->usesLocalCoords() && !this->viewMatrix().invert(&invert)) {
859 SkDebugf("Could not invert viewmatrix\n"); 859 SkDebugf("Could not invert viewmatrix\n");
860 return; 860 return;
861 } 861 }
862 862
863 // Setup GrGeometryProcessor 863 // Setup GrGeometryProcessor
864 SkAutoTUnref<GrGeometryProcessor> quadProcessor( 864 SkAutoTUnref<GrGeometryProcessor> quadProcessor(
865 QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoo rds())); 865 QuadEdgeEffect::Create(this->color(), invert, this->usesLocalCoo rds()));
866 866
867 target->initDraw(quadProcessor, this->pipeline()); 867 target->initDraw(quadProcessor);
868 868
869 // TODO generate all segments for all paths and use one vertex buffer 869 // TODO generate all segments for all paths and use one vertex buffer
870 for (int i = 0; i < instanceCount; i++) { 870 for (int i = 0; i < instanceCount; i++) {
871 const Geometry& args = fGeoData[i]; 871 const Geometry& args = fGeoData[i];
872 872
873 // We use the fact that SkPath::transform path does subdivision base d on 873 // 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 874 // perspective. Otherwise, we apply the view matrix when copying to the
875 // segment representation. 875 // segment representation.
876 const SkMatrix* viewMatrix = &args.fViewMatrix; 876 const SkMatrix* viewMatrix = &args.fViewMatrix;
877 877
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 917
918 uint16_t *idxs = target->makeIndexSpace(indexCount, &indexBuffer, &f irstIndex); 918 uint16_t *idxs = target->makeIndexSpace(indexCount, &indexBuffer, &f irstIndex);
919 if (!idxs) { 919 if (!idxs) {
920 SkDebugf("Could not allocate indices\n"); 920 SkDebugf("Could not allocate indices\n");
921 return; 921 return;
922 } 922 }
923 923
924 SkSTArray<kPreallocDrawCnt, Draw, true> draws; 924 SkSTArray<kPreallocDrawCnt, Draw, true> draws;
925 create_vertices(segments, fanPt, &draws, verts, idxs); 925 create_vertices(segments, fanPt, &draws, verts, idxs);
926 926
927 GrVertices vertices; 927 GrMesh mesh;
928 928
929 for (int j = 0; j < draws.count(); ++j) { 929 for (int j = 0; j < draws.count(); ++j) {
930 const Draw& draw = draws[j]; 930 const Draw& draw = draws[j];
931 vertices.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, i ndexBuffer, 931 mesh.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, index Buffer,
932 firstVertex, firstIndex, draw.fVertexCnt, d raw.fIndexCnt); 932 firstVertex, firstIndex, draw.fVertexCnt, draw. fIndexCnt);
933 target->draw(vertices); 933 target->draw(mesh);
934 firstVertex += draw.fVertexCnt; 934 firstVertex += draw.fVertexCnt;
935 firstIndex += draw.fIndexCnt; 935 firstIndex += draw.fIndexCnt;
936 } 936 }
937 } 937 }
938 } 938 }
939 939
940 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 940 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
941 941
942 AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) { 942 AAConvexPathBatch(const Geometry& geometry) : INHERITED(ClassID()) {
943 fGeoData.push_back(geometry); 943 fGeoData.push_back(geometry);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) { 1025 DRAW_BATCH_TEST_DEFINE(AAConvexPathBatch) {
1026 AAConvexPathBatch::Geometry geometry; 1026 AAConvexPathBatch::Geometry geometry;
1027 geometry.fColor = GrRandomColor(random); 1027 geometry.fColor = GrRandomColor(random);
1028 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 1028 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
1029 geometry.fPath = GrTest::TestPathConvex(random); 1029 geometry.fPath = GrTest::TestPathConvex(random);
1030 1030
1031 return AAConvexPathBatch::Create(geometry); 1031 return AAConvexPathBatch::Create(geometry);
1032 } 1032 }
1033 1033
1034 #endif 1034 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrVertices.h ('k') | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698