OLD | NEW |
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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 } | 880 } |
881 | 881 |
882 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex)); | 882 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex)); |
883 | 883 |
884 LineVertex* verts = reinterpret_cast<LineVertex*>(vertices); | 884 LineVertex* verts = reinterpret_cast<LineVertex*>(vertices); |
885 for (int i = 0; i < lineCount; ++i) { | 885 for (int i = 0; i < lineCount; ++i) { |
886 add_line(&lines[2*i], toSrc, this->coverage(), &verts); | 886 add_line(&lines[2*i], toSrc, this->coverage(), &verts); |
887 } | 887 } |
888 | 888 |
889 { | 889 { |
| 890 int linesLeft = lineCount; |
890 GrDrawTarget::DrawInfo info; | 891 GrDrawTarget::DrawInfo info; |
891 info.setVertexBuffer(vertexBuffer); | 892 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIn
dexBuffer, |
892 info.setIndexBuffer(linesIndexBuffer); | 893 firstVertex, kLineSegNumVertices, kIdxsPerLineSeg
, &linesLeft, |
893 info.setPrimitiveType(kTriangles_GrPrimitiveType); | 894 kLineSegsNumInIdxBuffer); |
894 info.setStartIndex(0); | 895 do { |
895 | |
896 int lines = 0; | |
897 while (lines < lineCount) { | |
898 int n = SkTMin(lineCount - lines, kLineSegsNumInIdxBuffer); | |
899 | |
900 info.setStartVertex(kLineSegNumVertices*lines + firstVertex); | |
901 info.setVertexCount(kLineSegNumVertices*n); | |
902 info.setIndexCount(kIdxsPerLineSeg*n); | |
903 batchTarget->draw(info); | 896 batchTarget->draw(info); |
904 | 897 } while (info.nextInstances(&linesLeft, kLineSegsNumInIdxBuffer)); |
905 lines += n; | |
906 } | |
907 } | 898 } |
908 } | 899 } |
909 | 900 |
910 if (quadCount || conicCount) { | 901 if (quadCount || conicCount) { |
911 const GrVertexBuffer* vertexBuffer; | 902 const GrVertexBuffer* vertexBuffer; |
912 int firstVertex; | 903 int firstVertex; |
913 | 904 |
914 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( | 905 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( |
915 ref_quads_index_buffer(batchTarget->resourceProvider())); | 906 ref_quads_index_buffer(batchTarget->resourceProvider())); |
916 | 907 |
(...skipping 28 matching lines...) Expand all Loading... |
945 | 936 |
946 // TODO remove this when batch is everywhere | 937 // TODO remove this when batch is everywhere |
947 GrPipelineInfo init; | 938 GrPipelineInfo init; |
948 init.fColorIgnored = fBatch.fColorIgnored; | 939 init.fColorIgnored = fBatch.fColorIgnored; |
949 init.fOverrideColor = GrColor_ILLEGAL; | 940 init.fOverrideColor = GrColor_ILLEGAL; |
950 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 941 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
951 init.fUsesLocalCoords = this->usesLocalCoords(); | 942 init.fUsesLocalCoords = this->usesLocalCoords(); |
952 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | 943 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init); |
953 | 944 |
954 { | 945 { |
955 GrDrawTarget::DrawInfo info; | 946 int quadsLeft = quadCount; |
956 info.setVertexBuffer(vertexBuffer); | 947 GrDrawTarget::DrawInfo info; |
957 info.setIndexBuffer(quadsIndexBuffer); | 948 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua
dsIndexBuffer, |
958 info.setPrimitiveType(kTriangles_GrPrimitiveType); | 949 firstVertex, kQuadNumVertices, kIdxsPerQuad,
&quadsLeft, |
959 info.setStartIndex(0); | 950 kQuadsNumInIdxBuffer); |
960 | 951 do { |
961 int quads = 0; | |
962 while (quads < quadCount) { | |
963 int n = SkTMin(quadCount - quads, kQuadsNumInIdxBuffer); | |
964 | |
965 info.setStartVertex(kQuadNumVertices*quads + firstVertex); | |
966 info.setVertexCount(kQuadNumVertices*n); | |
967 info.setIndexCount(kIdxsPerQuad*n); | |
968 batchTarget->draw(info); | 952 batchTarget->draw(info); |
969 | 953 } while (info.nextInstances(&quadsLeft, kQuadsNumInIdxBuffer)); |
970 quads += n; | 954 firstVertex += quadCount * kQuadNumVertices; |
971 } | |
972 } | 955 } |
973 } | 956 } |
974 | 957 |
975 if (conicCount > 0) { | 958 if (conicCount > 0) { |
976 batchTarget->initDraw(conicGP, pipeline); | 959 batchTarget->initDraw(conicGP, pipeline); |
977 | 960 |
978 // TODO remove this when batch is everywhere | 961 // TODO remove this when batch is everywhere |
979 GrPipelineInfo init; | 962 GrPipelineInfo init; |
980 init.fColorIgnored = fBatch.fColorIgnored; | 963 init.fColorIgnored = fBatch.fColorIgnored; |
981 init.fOverrideColor = GrColor_ILLEGAL; | 964 init.fOverrideColor = GrColor_ILLEGAL; |
982 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 965 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
983 init.fUsesLocalCoords = this->usesLocalCoords(); | 966 init.fUsesLocalCoords = this->usesLocalCoords(); |
984 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | 967 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init); |
985 | 968 |
986 { | 969 { |
| 970 int conicsLeft = conicCount; |
987 GrDrawTarget::DrawInfo info; | 971 GrDrawTarget::DrawInfo info; |
988 info.setVertexBuffer(vertexBuffer); | 972 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua
dsIndexBuffer, |
989 info.setIndexBuffer(quadsIndexBuffer); | 973 firstVertex, kQuadNumVertices, kIdxsPerQuad, &
conicsLeft, |
990 info.setPrimitiveType(kTriangles_GrPrimitiveType); | 974 kQuadsNumInIdxBuffer); |
991 info.setStartIndex(0); | 975 do { |
992 | |
993 int conics = 0; | |
994 while (conics < conicCount) { | |
995 int n = SkTMin(conicCount - conics, kQuadsNumInIdxBuffer); | |
996 | |
997 info.setStartVertex(kQuadNumVertices*(quadCount + conics) +
firstVertex); | |
998 info.setVertexCount(kQuadNumVertices*n); | |
999 info.setIndexCount(kIdxsPerQuad*n); | |
1000 batchTarget->draw(info); | 976 batchTarget->draw(info); |
1001 | 977 } while (info.nextInstances(&conicsLeft, kQuadsNumInIdxBuffer)); |
1002 conics += n; | |
1003 } | |
1004 } | 978 } |
1005 } | 979 } |
1006 } | 980 } |
1007 } | 981 } |
1008 | 982 |
1009 bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target, | 983 bool GrAAHairLinePathRenderer::onDrawPath(GrDrawTarget* target, |
1010 GrPipelineBuilder* pipelineBuilder, | 984 GrPipelineBuilder* pipelineBuilder, |
1011 GrColor color, | 985 GrColor color, |
1012 const SkMatrix& viewMatrix, | 986 const SkMatrix& viewMatrix, |
1013 const SkPath& path, | 987 const SkPath& path, |
(...skipping 14 matching lines...) Expand all Loading... |
1028 geometry.fCoverage = newCoverage; | 1002 geometry.fCoverage = newCoverage; |
1029 geometry.fViewMatrix = viewMatrix; | 1003 geometry.fViewMatrix = viewMatrix; |
1030 geometry.fPath = path; | 1004 geometry.fPath = path; |
1031 geometry.fDevClipBounds = devClipBounds; | 1005 geometry.fDevClipBounds = devClipBounds; |
1032 | 1006 |
1033 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry)); | 1007 SkAutoTUnref<GrBatch> batch(AAHairlineBatch::Create(geometry)); |
1034 target->drawBatch(pipelineBuilder, batch); | 1008 target->drawBatch(pipelineBuilder, batch); |
1035 | 1009 |
1036 return true; | 1010 return true; |
1037 } | 1011 } |
OLD | NEW |