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

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

Issue 1124633003: Revert of Start on simplifying generateGeometry() overrides (Closed) Base URL: https://skia.googlesource.com/skia.git@ibcache
Patch Set: 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;
892 GrDrawTarget::DrawInfo info; 891 GrDrawTarget::DrawInfo info;
893 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIn dexBuffer, 892 info.setVertexBuffer(vertexBuffer);
894 firstVertex, kLineSegNumVertices, kIdxsPerLineSeg , &linesLeft, 893 info.setIndexBuffer(linesIndexBuffer);
895 kLineSegsNumInIdxBuffer); 894 info.setPrimitiveType(kTriangles_GrPrimitiveType);
896 do { 895 info.setStartIndex(0);
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);
897 batchTarget->draw(info); 904 batchTarget->draw(info);
898 } while (info.nextInstances(&linesLeft, kLineSegsNumInIdxBuffer)); 905
906 lines += n;
907 }
899 } 908 }
900 } 909 }
901 910
902 if (quadCount || conicCount) { 911 if (quadCount || conicCount) {
903 const GrVertexBuffer* vertexBuffer; 912 const GrVertexBuffer* vertexBuffer;
904 int firstVertex; 913 int firstVertex;
905 914
906 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( 915 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer(
907 ref_quads_index_buffer(batchTarget->resourceProvider())); 916 ref_quads_index_buffer(batchTarget->resourceProvider()));
908 917
(...skipping 28 matching lines...) Expand all
937 946
938 // TODO remove this when batch is everywhere 947 // TODO remove this when batch is everywhere
939 GrPipelineInfo init; 948 GrPipelineInfo init;
940 init.fColorIgnored = fBatch.fColorIgnored; 949 init.fColorIgnored = fBatch.fColorIgnored;
941 init.fOverrideColor = GrColor_ILLEGAL; 950 init.fOverrideColor = GrColor_ILLEGAL;
942 init.fCoverageIgnored = fBatch.fCoverageIgnored; 951 init.fCoverageIgnored = fBatch.fCoverageIgnored;
943 init.fUsesLocalCoords = this->usesLocalCoords(); 952 init.fUsesLocalCoords = this->usesLocalCoords();
944 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init); 953 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
945 954
946 { 955 {
947 int quadsLeft = quadCount; 956 GrDrawTarget::DrawInfo info;
948 GrDrawTarget::DrawInfo info; 957 info.setVertexBuffer(vertexBuffer);
949 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua dsIndexBuffer, 958 info.setIndexBuffer(quadsIndexBuffer);
950 firstVertex, kQuadNumVertices, kIdxsPerQuad, &quadsLeft, 959 info.setPrimitiveType(kTriangles_GrPrimitiveType);
951 kQuadsNumInIdxBuffer); 960 info.setStartIndex(0);
952 do { 961
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);
953 batchTarget->draw(info); 969 batchTarget->draw(info);
954 } while (info.nextInstances(&quadsLeft, kQuadsNumInIdxBuffer)); 970
955 firstVertex += quadCount * kQuadNumVertices; 971 quads += n;
972 }
956 } 973 }
957 } 974 }
958 975
959 if (conicCount > 0) { 976 if (conicCount > 0) {
960 batchTarget->initDraw(conicGP, pipeline); 977 batchTarget->initDraw(conicGP, pipeline);
961 978
962 // TODO remove this when batch is everywhere 979 // TODO remove this when batch is everywhere
963 GrPipelineInfo init; 980 GrPipelineInfo init;
964 init.fColorIgnored = fBatch.fColorIgnored; 981 init.fColorIgnored = fBatch.fColorIgnored;
965 init.fOverrideColor = GrColor_ILLEGAL; 982 init.fOverrideColor = GrColor_ILLEGAL;
966 init.fCoverageIgnored = fBatch.fCoverageIgnored; 983 init.fCoverageIgnored = fBatch.fCoverageIgnored;
967 init.fUsesLocalCoords = this->usesLocalCoords(); 984 init.fUsesLocalCoords = this->usesLocalCoords();
968 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init); 985 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init);
969 986
970 { 987 {
971 int conicsLeft = conicCount;
972 GrDrawTarget::DrawInfo info; 988 GrDrawTarget::DrawInfo info;
973 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua dsIndexBuffer, 989 info.setVertexBuffer(vertexBuffer);
974 firstVertex, kQuadNumVertices, kIdxsPerQuad, & conicsLeft, 990 info.setIndexBuffer(quadsIndexBuffer);
975 kQuadsNumInIdxBuffer); 991 info.setPrimitiveType(kTriangles_GrPrimitiveType);
976 do { 992 info.setStartIndex(0);
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);
977 batchTarget->draw(info); 1001 batchTarget->draw(info);
978 } while (info.nextInstances(&conicsLeft, kQuadsNumInIdxBuffer)); 1002
1003 conics += n;
1004 }
979 } 1005 }
980 } 1006 }
981 } 1007 }
982 } 1008 }
983 1009
984 static GrBatch* create_hairline_batch(GrColor color, 1010 static GrBatch* create_hairline_batch(GrColor color,
985 const SkMatrix& viewMatrix, 1011 const SkMatrix& viewMatrix,
986 const SkPath& path, 1012 const SkPath& path,
987 const GrStrokeInfo& stroke, 1013 const GrStrokeInfo& stroke,
988 const SkIRect& devClipBounds) { 1014 const SkIRect& devClipBounds) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 GrColor color = GrRandomColor(random); 1054 GrColor color = GrRandomColor(random);
1029 SkMatrix viewMatrix = GrTest::TestMatrix(random); 1055 SkMatrix viewMatrix = GrTest::TestMatrix(random);
1030 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); 1056 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle);
1031 SkPath path = GrTest::TestPath(random); 1057 SkPath path = GrTest::TestPath(random);
1032 SkIRect devClipBounds; 1058 SkIRect devClipBounds;
1033 devClipBounds.setEmpty(); 1059 devClipBounds.setEmpty();
1034 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds) ; 1060 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds) ;
1035 } 1061 }
1036 1062
1037 #endif 1063 #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