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

Side by Side Diff: src/gpu/GrAAHairLinePathRenderer.cpp

Issue 1122673002: Start on simplifying generateGeometry() overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@ibcache
Patch Set: whitespace, remove debug return Created 5 years, 7 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/GrAADistanceFieldPathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.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 * 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 "GrBatch.h" 10 #include "GrBatch.h"
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 881 }
882 882
883 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex)); 883 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex));
884 884
885 LineVertex* verts = reinterpret_cast<LineVertex*>(vertices); 885 LineVertex* verts = reinterpret_cast<LineVertex*>(vertices);
886 for (int i = 0; i < lineCount; ++i) { 886 for (int i = 0; i < lineCount; ++i) {
887 add_line(&lines[2*i], toSrc, this->coverage(), &verts); 887 add_line(&lines[2*i], toSrc, this->coverage(), &verts);
888 } 888 }
889 889
890 { 890 {
891 int linesLeft = lineCount;
891 GrDrawTarget::DrawInfo info; 892 GrDrawTarget::DrawInfo info;
892 info.setVertexBuffer(vertexBuffer); 893 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIn dexBuffer,
893 info.setIndexBuffer(linesIndexBuffer); 894 firstVertex, kLineSegNumVertices, kIdxsPerLineSeg , &linesLeft,
894 info.setPrimitiveType(kTriangles_GrPrimitiveType); 895 kLineSegsNumInIdxBuffer);
895 info.setStartIndex(0); 896 do {
896
897 int lines = 0;
898 while (lines < lineCount) {
899 int n = SkTMin(lineCount - lines, kLineSegsNumInIdxBuffer);
900
901 info.setStartVertex(kLineSegNumVertices*lines + firstVertex);
902 info.setVertexCount(kLineSegNumVertices*n);
903 info.setIndexCount(kIdxsPerLineSeg*n);
904 batchTarget->draw(info); 897 batchTarget->draw(info);
905 898 } while (info.nextInstances(&linesLeft, kLineSegsNumInIdxBuffer));
906 lines += n;
907 }
908 } 899 }
909 } 900 }
910 901
911 if (quadCount || conicCount) { 902 if (quadCount || conicCount) {
912 const GrVertexBuffer* vertexBuffer; 903 const GrVertexBuffer* vertexBuffer;
913 int firstVertex; 904 int firstVertex;
914 905
915 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( 906 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer(
916 ref_quads_index_buffer(batchTarget->resourceProvider())); 907 ref_quads_index_buffer(batchTarget->resourceProvider()));
917 908
(...skipping 28 matching lines...) Expand all
946 937
947 // TODO remove this when batch is everywhere 938 // TODO remove this when batch is everywhere
948 GrPipelineInfo init; 939 GrPipelineInfo init;
949 init.fColorIgnored = fBatch.fColorIgnored; 940 init.fColorIgnored = fBatch.fColorIgnored;
950 init.fOverrideColor = GrColor_ILLEGAL; 941 init.fOverrideColor = GrColor_ILLEGAL;
951 init.fCoverageIgnored = fBatch.fCoverageIgnored; 942 init.fCoverageIgnored = fBatch.fCoverageIgnored;
952 init.fUsesLocalCoords = this->usesLocalCoords(); 943 init.fUsesLocalCoords = this->usesLocalCoords();
953 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init); 944 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
954 945
955 { 946 {
956 GrDrawTarget::DrawInfo info; 947 int quadsLeft = quadCount;
957 info.setVertexBuffer(vertexBuffer); 948 GrDrawTarget::DrawInfo info;
958 info.setIndexBuffer(quadsIndexBuffer); 949 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua dsIndexBuffer,
959 info.setPrimitiveType(kTriangles_GrPrimitiveType); 950 firstVertex, kQuadNumVertices, kIdxsPerQuad, &quadsLeft,
960 info.setStartIndex(0); 951 kQuadsNumInIdxBuffer);
961 952 do {
962 int quads = 0;
963 while (quads < quadCount) {
964 int n = SkTMin(quadCount - quads, kQuadsNumInIdxBuffer);
965
966 info.setStartVertex(kQuadNumVertices*quads + firstVertex);
967 info.setVertexCount(kQuadNumVertices*n);
968 info.setIndexCount(kIdxsPerQuad*n);
969 batchTarget->draw(info); 953 batchTarget->draw(info);
970 954 } while (info.nextInstances(&quadsLeft, kQuadsNumInIdxBuffer));
971 quads += n; 955 firstVertex += quadCount * kQuadNumVertices;
972 }
973 } 956 }
974 } 957 }
975 958
976 if (conicCount > 0) { 959 if (conicCount > 0) {
977 batchTarget->initDraw(conicGP, pipeline); 960 batchTarget->initDraw(conicGP, pipeline);
978 961
979 // TODO remove this when batch is everywhere 962 // TODO remove this when batch is everywhere
980 GrPipelineInfo init; 963 GrPipelineInfo init;
981 init.fColorIgnored = fBatch.fColorIgnored; 964 init.fColorIgnored = fBatch.fColorIgnored;
982 init.fOverrideColor = GrColor_ILLEGAL; 965 init.fOverrideColor = GrColor_ILLEGAL;
983 init.fCoverageIgnored = fBatch.fCoverageIgnored; 966 init.fCoverageIgnored = fBatch.fCoverageIgnored;
984 init.fUsesLocalCoords = this->usesLocalCoords(); 967 init.fUsesLocalCoords = this->usesLocalCoords();
985 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init); 968 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
986 969
987 { 970 {
971 int conicsLeft = conicCount;
988 GrDrawTarget::DrawInfo info; 972 GrDrawTarget::DrawInfo info;
989 info.setVertexBuffer(vertexBuffer); 973 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua dsIndexBuffer,
990 info.setIndexBuffer(quadsIndexBuffer); 974 firstVertex, kQuadNumVertices, kIdxsPerQuad, & conicsLeft,
991 info.setPrimitiveType(kTriangles_GrPrimitiveType); 975 kQuadsNumInIdxBuffer);
992 info.setStartIndex(0); 976 do {
993
994 int conics = 0;
995 while (conics < conicCount) {
996 int n = SkTMin(conicCount - conics, kQuadsNumInIdxBuffer);
997
998 info.setStartVertex(kQuadNumVertices*(quadCount + conics) + firstVertex);
999 info.setVertexCount(kQuadNumVertices*n);
1000 info.setIndexCount(kIdxsPerQuad*n);
1001 batchTarget->draw(info); 977 batchTarget->draw(info);
1002 978 } while (info.nextInstances(&conicsLeft, kQuadsNumInIdxBuffer));
1003 conics += n;
1004 }
1005 } 979 }
1006 } 980 }
1007 } 981 }
1008 } 982 }
1009 983
1010 static GrBatch* create_hairline_batch(GrColor color, 984 static GrBatch* create_hairline_batch(GrColor color,
1011 const SkMatrix& viewMatrix, 985 const SkMatrix& viewMatrix,
1012 const SkPath& path, 986 const SkPath& path,
1013 const GrStrokeInfo& stroke, 987 const GrStrokeInfo& stroke,
1014 const SkIRect& devClipBounds) { 988 const SkIRect& devClipBounds) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 GrColor color = GrRandomColor(random); 1028 GrColor color = GrRandomColor(random);
1055 SkMatrix viewMatrix = GrTest::TestMatrix(random); 1029 SkMatrix viewMatrix = GrTest::TestMatrix(random);
1056 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); 1030 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle);
1057 SkPath path = GrTest::TestPath(random); 1031 SkPath path = GrTest::TestPath(random);
1058 SkIRect devClipBounds; 1032 SkIRect devClipBounds;
1059 devClipBounds.setEmpty(); 1033 devClipBounds.setEmpty();
1060 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds) ; 1034 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds) ;
1061 } 1035 }
1062 1036
1063 #endif 1037 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.cpp ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698