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

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

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comments updated Created 4 years, 8 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
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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 mesh.init(kTriangles_GrPrimitiveType, triVertexBuffer, firstTriV ertex, 888 mesh.init(kTriangles_GrPrimitiveType, triVertexBuffer, firstTriV ertex,
889 triVertices.count()); 889 triVertices.count());
890 target->initDraw(triangleProcessor); 890 target->draw(triangleProcessor, mesh);
891 target->draw(mesh);
892 } 891 }
893 892
894 if (quadVertices.count()) { 893 if (quadVertices.count()) {
895 const GrBuffer* quadVertexBuffer; 894 const GrBuffer* quadVertexBuffer;
896 int firstQuadVertex; 895 int firstQuadVertex;
897 size_t quadStride = quadProcessor->getVertexStride(); 896 size_t quadStride = quadProcessor->getVertexStride();
898 PLSVertex* quadVerts = reinterpret_cast<PLSVertex*>(target->make VertexSpace( 897 PLSVertex* quadVerts = reinterpret_cast<PLSVertex*>(target->make VertexSpace(
899 quadStride, quadVertices.count(), &quadVertexBuffer, &fi rstQuadVertex)); 898 quadStride, quadVertices.count(), &quadVertexBuffer, &fi rstQuadVertex));
900 if (!quadVerts) { 899 if (!quadVerts) {
901 SkDebugf("Could not allocate vertices\n"); 900 SkDebugf("Could not allocate vertices\n");
902 return; 901 return;
903 } 902 }
904 for (int i = 0; i < quadVertices.count(); ++i) { 903 for (int i = 0; i < quadVertices.count(); ++i) {
905 quadVerts[i] = quadVertices[i]; 904 quadVerts[i] = quadVertices[i];
906 } 905 }
907 mesh.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQua dVertex, 906 mesh.init(kTriangles_GrPrimitiveType, quadVertexBuffer, firstQua dVertex,
908 quadVertices.count()); 907 quadVertices.count());
909 target->initDraw(quadProcessor); 908 target->draw(quadProcessor, mesh);
910 target->draw(mesh);
911 } 909 }
912 910
913 SkAutoTUnref<GrGeometryProcessor> finishProcessor( 911 SkAutoTUnref<GrGeometryProcessor> finishProcessor(
914 PLSFinishEffect::Create(this->color(), 912 PLSFinishEffect::Create(this->color(),
915 pathPtr->getFillType() == 913 pathPtr->getFillType() ==
916 SkPath::FillType ::kEvenOdd_FillType, 914 SkPath::FillType ::kEvenOdd_FillType,
917 invert, 915 invert,
918 this->usesLocalCoords())); 916 this->usesLocalCoords()));
919 const GrBuffer* rectVertexBuffer; 917 const GrBuffer* rectVertexBuffer;
920 size_t finishStride = finishProcessor->getVertexStride(); 918 size_t finishStride = finishProcessor->getVertexStride();
921 int firstRectVertex; 919 int firstRectVertex;
922 static const int kRectVertexCount = 6; 920 static const int kRectVertexCount = 6;
923 SkPoint* rectVerts = reinterpret_cast<SkPoint*>(target->makeVertexSp ace( 921 SkPoint* rectVerts = reinterpret_cast<SkPoint*>(target->makeVertexSp ace(
924 finishStride, kRectVertexCount, &rectVertexBuffer, &firstRec tVertex)); 922 finishStride, kRectVertexCount, &rectVertexBuffer, &firstRec tVertex));
925 if (!rectVerts) { 923 if (!rectVerts) {
926 SkDebugf("Could not allocate vertices\n"); 924 SkDebugf("Could not allocate vertices\n");
927 return; 925 return;
928 } 926 }
929 rectVerts[0] = { bounds.fLeft, bounds.fTop }; 927 rectVerts[0] = { bounds.fLeft, bounds.fTop };
930 rectVerts[1] = { bounds.fLeft, bounds.fBottom }; 928 rectVerts[1] = { bounds.fLeft, bounds.fBottom };
931 rectVerts[2] = { bounds.fRight, bounds.fBottom }; 929 rectVerts[2] = { bounds.fRight, bounds.fBottom };
932 rectVerts[3] = { bounds.fLeft, bounds.fTop }; 930 rectVerts[3] = { bounds.fLeft, bounds.fTop };
933 rectVerts[4] = { bounds.fRight, bounds.fTop }; 931 rectVerts[4] = { bounds.fRight, bounds.fTop };
934 rectVerts[5] = { bounds.fRight, bounds.fBottom }; 932 rectVerts[5] = { bounds.fRight, bounds.fBottom };
935 933
936 mesh.init(kTriangles_GrPrimitiveType, rectVertexBuffer, firstRectVer tex, 934 mesh.init(kTriangles_GrPrimitiveType, rectVertexBuffer, firstRectVer tex,
937 kRectVertexCount); 935 kRectVertexCount);
938 target->initDraw(finishProcessor); 936 target->draw(finishProcessor, mesh);
939 target->draw(mesh);
940 } 937 }
941 } 938 }
942 939
943 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } 940 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; }
944 941
945 private: 942 private:
946 PLSPathBatch(const Geometry& geometry) : INHERITED(ClassID()) { 943 PLSPathBatch(const Geometry& geometry) : INHERITED(ClassID()) {
947 fGeoData.push_back(geometry); 944 fGeoData.push_back(geometry);
948 945
949 // compute bounds 946 // compute bounds
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) { 999 DRAW_BATCH_TEST_DEFINE(PLSPathBatch) {
1003 PLSPathBatch::Geometry geometry; 1000 PLSPathBatch::Geometry geometry;
1004 geometry.fColor = GrRandomColor(random); 1001 geometry.fColor = GrRandomColor(random);
1005 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random); 1002 geometry.fViewMatrix = GrTest::TestMatrixInvertible(random);
1006 geometry.fPath = GrTest::TestPathConvex(random); 1003 geometry.fPath = GrTest::TestPathConvex(random);
1007 1004
1008 return PLSPathBatch::Create(geometry); 1005 return PLSPathBatch::Create(geometry);
1009 } 1006 }
1010 1007
1011 #endif 1008 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698