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

Side by Side Diff: src/gpu/batches/GrPLSPathRenderer.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/batches/GrNonAAStrokeRectBatch.cpp ('k') | src/gpu/batches/GrTInstanceBatch.h » ('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 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrPLSPathRenderer.h" 8 #include "GrPLSPathRenderer.h"
9 9
10 #include "SkChunkAlloc.h" 10 #include "SkChunkAlloc.h"
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 const SkPath* pathPtr = &args.fPath; 857 const SkPath* pathPtr = &args.fPath;
858 SkTLazy<SkPath> tmpPath; 858 SkTLazy<SkPath> tmpPath;
859 if (viewMatrix->hasPerspective()) { 859 if (viewMatrix->hasPerspective()) {
860 SkPath* tmpPathPtr = tmpPath.init(*pathPtr); 860 SkPath* tmpPathPtr = tmpPath.init(*pathPtr);
861 tmpPathPtr->setIsVolatile(true); 861 tmpPathPtr->setIsVolatile(true);
862 tmpPathPtr->transform(*viewMatrix); 862 tmpPathPtr->transform(*viewMatrix);
863 viewMatrix = &SkMatrix::I(); 863 viewMatrix = &SkMatrix::I();
864 pathPtr = tmpPathPtr; 864 pathPtr = tmpPathPtr;
865 } 865 }
866 866
867 GrVertices grVertices; 867 GrMesh mesh;
868 868
869 PLSVertices triVertices; 869 PLSVertices triVertices;
870 PLSVertices quadVertices; 870 PLSVertices quadVertices;
871 if (!get_geometry(*pathPtr, *viewMatrix, triVertices, quadVertices, rp, bounds)) { 871 if (!get_geometry(*pathPtr, *viewMatrix, triVertices, quadVertices, rp, bounds)) {
872 continue; 872 continue;
873 } 873 }
874 874
875 if (triVertices.count()) { 875 if (triVertices.count()) {
876 const GrVertexBuffer* triVertexBuffer; 876 const GrVertexBuffer* triVertexBuffer;
877 int firstTriVertex; 877 int firstTriVertex;
878 size_t triStride = triangleProcessor->getVertexStride(); 878 size_t triStride = triangleProcessor->getVertexStride();
879 PLSVertex* triVerts = reinterpret_cast<PLSVertex*>(target->makeV ertexSpace( 879 PLSVertex* triVerts = reinterpret_cast<PLSVertex*>(target->makeV ertexSpace(
880 triStride, triVertices.count(), &triVertexBuffer, &first TriVertex)); 880 triStride, triVertices.count(), &triVertexBuffer, &first TriVertex));
881 if (!triVerts) { 881 if (!triVerts) {
882 SkDebugf("Could not allocate vertices\n"); 882 SkDebugf("Could not allocate vertices\n");
883 return; 883 return;
884 } 884 }
885 for (int i = 0; i < triVertices.count(); ++i) { 885 for (int i = 0; i < triVertices.count(); ++i) {
886 triVerts[i] = triVertices[i]; 886 triVerts[i] = triVertices[i];
887 } 887 }
888 grVertices.init(kTriangles_GrPrimitiveType, triVertexBuffer, fir stTriVertex, 888 mesh.init(kTriangles_GrPrimitiveType, triVertexBuffer, firstTriV ertex,
889 triVertices.count()); 889 triVertices.count());
890 target->initDraw(triangleProcessor, this->pipeline()); 890 target->initDraw(triangleProcessor);
891 target->draw(grVertices); 891 target->draw(mesh);
892 } 892 }
893 893
894 if (quadVertices.count()) { 894 if (quadVertices.count()) {
895 const GrVertexBuffer* quadVertexBuffer; 895 const GrVertexBuffer* quadVertexBuffer;
896 int firstQuadVertex; 896 int firstQuadVertex;
897 size_t quadStride = quadProcessor->getVertexStride(); 897 size_t quadStride = quadProcessor->getVertexStride();
898 PLSVertex* quadVerts = reinterpret_cast<PLSVertex*>(target->make VertexSpace( 898 PLSVertex* quadVerts = reinterpret_cast<PLSVertex*>(target->make VertexSpace(
899 quadStride, quadVertices.count(), &quadVertexBuffer, &fi rstQuadVertex)); 899 quadStride, quadVertices.count(), &quadVertexBuffer, &fi rstQuadVertex));
900 if (!quadVerts) { 900 if (!quadVerts) {
901 SkDebugf("Could not allocate vertices\n"); 901 SkDebugf("Could not allocate vertices\n");
902 return; 902 return;
903 } 903 }
904 for (int i = 0; i < quadVertices.count(); ++i) { 904 for (int i = 0; i < quadVertices.count(); ++i) {
905 quadVerts[i] = quadVertices[i]; 905 quadVerts[i] = quadVertices[i];
906 } 906 }
907 grVertices.init(kTriangles_GrPrimitiveType, quadVertexBuffer, fi rstQuadVertex, 907 mesh.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQua dVertex,
908 quadVertices.count()); 908 quadVertices.count());
909 target->initDraw(quadProcessor, this->pipeline()); 909 target->initDraw(quadProcessor);
910 target->draw(grVertices); 910 target->draw(mesh);
911 } 911 }
912 912
913 SkAutoTUnref<GrGeometryProcessor> finishProcessor( 913 SkAutoTUnref<GrGeometryProcessor> finishProcessor(
914 PLSFinishEffect::Create(this->color(), 914 PLSFinishEffect::Create(this->color(),
915 pathPtr->getFillType() == 915 pathPtr->getFillType() ==
916 SkPath::FillType ::kEvenOdd_FillType, 916 SkPath::FillType ::kEvenOdd_FillType,
917 invert, 917 invert,
918 this->usesLocalCoords())); 918 this->usesLocalCoords()));
919 const GrVertexBuffer* rectVertexBuffer; 919 const GrVertexBuffer* rectVertexBuffer;
920 size_t finishStride = finishProcessor->getVertexStride(); 920 size_t finishStride = finishProcessor->getVertexStride();
921 int firstRectVertex; 921 int firstRectVertex;
922 static const int kRectVertexCount = 6; 922 static const int kRectVertexCount = 6;
923 SkPoint* rectVerts = reinterpret_cast<SkPoint*>(target->makeVertexSp ace( 923 SkPoint* rectVerts = reinterpret_cast<SkPoint*>(target->makeVertexSp ace(
924 finishStride, kRectVertexCount, &rectVertexBuffer, &firstRec tVertex)); 924 finishStride, kRectVertexCount, &rectVertexBuffer, &firstRec tVertex));
925 if (!rectVerts) { 925 if (!rectVerts) {
926 SkDebugf("Could not allocate vertices\n"); 926 SkDebugf("Could not allocate vertices\n");
927 return; 927 return;
928 } 928 }
929 rectVerts[0] = { bounds.fLeft, bounds.fTop }; 929 rectVerts[0] = { bounds.fLeft, bounds.fTop };
930 rectVerts[1] = { bounds.fLeft, bounds.fBottom }; 930 rectVerts[1] = { bounds.fLeft, bounds.fBottom };
931 rectVerts[2] = { bounds.fRight, bounds.fBottom }; 931 rectVerts[2] = { bounds.fRight, bounds.fBottom };
932 rectVerts[3] = { bounds.fLeft, bounds.fTop }; 932 rectVerts[3] = { bounds.fLeft, bounds.fTop };
933 rectVerts[4] = { bounds.fRight, bounds.fTop }; 933 rectVerts[4] = { bounds.fRight, bounds.fTop };
934 rectVerts[5] = { bounds.fRight, bounds.fBottom }; 934 rectVerts[5] = { bounds.fRight, bounds.fBottom };
935 935
936 grVertices.init(kTriangles_GrPrimitiveType, rectVertexBuffer, firstR ectVertex, 936 mesh.init(kTriangles_GrPrimitiveType, rectVertexBuffer, firstRectVer tex,
937 kRectVertexCount); 937 kRectVertexCount);
938 target->initDraw(finishProcessor, this->pipeline()); 938 target->initDraw(finishProcessor);
939 target->draw(grVertices); 939 target->draw(mesh);
940 } 940 }
941 } 941 }
942 942
943 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 943 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
944 944
945 private: 945 private:
946 PLSPathBatch(const Geometry& geometry) : INHERITED(ClassID()) { 946 PLSPathBatch(const Geometry& geometry) : INHERITED(ClassID()) {
947 fGeoData.push_back(geometry); 947 fGeoData.push_back(geometry);
948 948
949 // compute bounds 949 // compute bounds
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) { 1002 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) {
1003 PLSPathBatch::Geometry geometry; 1003 PLSPathBatch::Geometry geometry;
1004 geometry.fColor = GrRandomColor(random); 1004 geometry.fColor = GrRandomColor(random);
1005 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 1005 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
1006 geometry.fPath = GrTest::TestPathConvex(random); 1006 geometry.fPath = GrTest::TestPathConvex(random);
1007 1007
1008 return PLSPathBatch::Create(geometry); 1008 return PLSPathBatch::Create(geometry);
1009 } 1009 }
1010 1010
1011 #endif 1011 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrNonAAStrokeRectBatch.cpp ('k') | src/gpu/batches/GrTInstanceBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698