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

Side by Side Diff: src/gpu/batches/GrAAHairLinePathRenderer.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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrAAHairLinePathRenderer.h" 8 #include "GrAAHairLinePathRenderer.h"
9 9
10 #include "GrBatchFlushState.h" 10 #include "GrBatchFlushState.h"
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 &lines, &quads, &conics, &qSubdivs, &cWeights); 853 &lines, &quads, &conics, &qSubdivs, &cWeights);
854 } 854 }
855 855
856 int lineCount = lines.count() / 2; 856 int lineCount = lines.count() / 2;
857 int conicCount = conics.count() / 3; 857 int conicCount = conics.count() / 3;
858 858
859 // do lines first 859 // do lines first
860 if (lineCount) { 860 if (lineCount) {
861 SkAutoTUnref<const GrIndexBuffer> linesIndexBuffer( 861 SkAutoTUnref<const GrIndexBuffer> linesIndexBuffer(
862 ref_lines_index_buffer(target->resourceProvider())); 862 ref_lines_index_buffer(target->resourceProvider()));
863 target->initDraw(lineGP, this->pipeline()); 863 target->initDraw(lineGP);
864 864
865 const GrVertexBuffer* vertexBuffer; 865 const GrVertexBuffer* vertexBuffer;
866 int firstVertex; 866 int firstVertex;
867 867
868 size_t vertexStride = lineGP->getVertexStride(); 868 size_t vertexStride = lineGP->getVertexStride();
869 int vertexCount = kLineSegNumVertices * lineCount; 869 int vertexCount = kLineSegNumVertices * lineCount;
870 LineVertex* verts = reinterpret_cast<LineVertex*>( 870 LineVertex* verts = reinterpret_cast<LineVertex*>(
871 target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &f irstVertex)); 871 target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &f irstVertex));
872 872
873 if (!verts|| !linesIndexBuffer) { 873 if (!verts|| !linesIndexBuffer) {
874 SkDebugf("Could not allocate vertices\n"); 874 SkDebugf("Could not allocate vertices\n");
875 return; 875 return;
876 } 876 }
877 877
878 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex)); 878 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex));
879 879
880 for (int i = 0; i < lineCount; ++i) { 880 for (int i = 0; i < lineCount; ++i) {
881 add_line(&lines[2*i], toSrc, this->coverage(), &verts); 881 add_line(&lines[2*i], toSrc, this->coverage(), &verts);
882 } 882 }
883 883
884 { 884 {
885 GrVertices vertices; 885 GrMesh mesh;
886 vertices.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, lin esIndexBuffer, 886 mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIn dexBuffer,
887 firstVertex, kLineSegNumVertices, kIdxsPerLin eSeg, lineCount, 887 firstVertex, kLineSegNumVertices, kIdxsPerLineSeg , lineCount,
888 kLineSegsNumInIdxBuffer); 888 kLineSegsNumInIdxBuffer);
889 target->draw(vertices); 889 target->draw(mesh);
890 } 890 }
891 } 891 }
892 892
893 if (quadCount || conicCount) { 893 if (quadCount || conicCount) {
894 const GrVertexBuffer* vertexBuffer; 894 const GrVertexBuffer* vertexBuffer;
895 int firstVertex; 895 int firstVertex;
896 896
897 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( 897 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer(
898 ref_quads_index_buffer(target->resourceProvider())); 898 ref_quads_index_buffer(target->resourceProvider()));
899 899
(...skipping 15 matching lines...) Expand all
915 SkASSERT(qSubdivs[i] >= 0); 915 SkASSERT(qSubdivs[i] >= 0);
916 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); 916 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts);
917 } 917 }
918 918
919 // Start Conics 919 // Start Conics
920 for (int i = 0; i < conicCount; ++i) { 920 for (int i = 0; i < conicCount; ++i) {
921 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &bezVerts); 921 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &bezVerts);
922 } 922 }
923 923
924 if (quadCount > 0) { 924 if (quadCount > 0) {
925 target->initDraw(quadGP, this->pipeline()); 925 target->initDraw(quadGP);
926 926
927 { 927 {
928 GrVertices tempVerts; 928 GrMesh mesh;
929 tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer , quadsIndexBuffer, 929 mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua dsIndexBuffer,
930 firstVertex, kQuadNumVertices, kIdxsPerQ uad, quadCount, 930 firstVertex, kQuadNumVertices, kIdxsPerQuad, quadCount,
931 kQuadsNumInIdxBuffer); 931 kQuadsNumInIdxBuffer);
932 target->draw(tempVerts); 932 target->draw(mesh);
933 firstVertex += quadCount * kQuadNumVertices; 933 firstVertex += quadCount * kQuadNumVertices;
934 } 934 }
935 } 935 }
936 936
937 if (conicCount > 0) { 937 if (conicCount > 0) {
938 target->initDraw(conicGP, this->pipeline()); 938 target->initDraw(conicGP);
939 939
940 { 940 {
941 GrVertices tempVerts; 941 GrMesh mesh;
942 tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer , quadsIndexBuffer, 942 mesh.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua dsIndexBuffer,
943 firstVertex, kQuadNumVertices, kIdxsPerQ uad, conicCount, 943 firstVertex, kQuadNumVertices, kIdxsPerQuad, conicCount,
944 kQuadsNumInIdxBuffer); 944 kQuadsNumInIdxBuffer);
945 target->draw(tempVerts); 945 target->draw(mesh);
946 } 946 }
947 } 947 }
948 } 948 }
949 } 949 }
950 950
951 static GrDrawBatch* create_hairline_batch(GrColor color, 951 static GrDrawBatch* create_hairline_batch(GrColor color,
952 const SkMatrix& viewMatrix, 952 const SkMatrix& viewMatrix,
953 const SkPath& path, 953 const SkPath& path,
954 const GrStrokeInfo& stroke, 954 const GrStrokeInfo& stroke,
955 const SkIRect& devClipBounds) { 955 const SkIRect& devClipBounds) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 GrColor color = GrRandomColor(random); 990 GrColor color = GrRandomColor(random);
991 SkMatrix viewMatrix = GrTest::TestMatrix(random); 991 SkMatrix viewMatrix = GrTest::TestMatrix(random);
992 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); 992 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle);
993 SkPath path = GrTest::TestPath(random); 993 SkPath path = GrTest::TestPath(random);
994 SkIRect devClipBounds; 994 SkIRect devClipBounds;
995 devClipBounds.setEmpty(); 995 devClipBounds.setEmpty();
996 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds) ; 996 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds) ;
997 } 997 }
998 998
999 #endif 999 #endif
OLDNEW
« no previous file with comments | « src/gpu/batches/GrAADistanceFieldPathRenderer.cpp ('k') | src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698