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 "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, kTriangles_GrPrimitiveType); |
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 GrVertices vertices; |
886 vertices.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, lin
esIndexBuffer, | 886 vertices.initInstanced(vertexBuffer, linesIndexBuffer, firstVertex,
kLineSegNumVertices, |
887 firstVertex, kLineSegNumVertices, kIdxsPerLin
eSeg, lineCount, | 887 kIdxsPerLineSeg, lineCount, kLineSegsNumInIdx
Buffer); |
888 kLineSegsNumInIdxBuffer); | |
889 target->draw(vertices); | 888 target->draw(vertices); |
890 } | 889 } |
891 } | 890 } |
892 | 891 |
893 if (quadCount || conicCount) { | 892 if (quadCount || conicCount) { |
894 const GrVertexBuffer* vertexBuffer; | 893 const GrVertexBuffer* vertexBuffer; |
895 int firstVertex; | 894 int firstVertex; |
896 | 895 |
897 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( | 896 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( |
898 ref_quads_index_buffer(target->resourceProvider())); | 897 ref_quads_index_buffer(target->resourceProvider())); |
(...skipping 16 matching lines...) Expand all Loading... |
915 SkASSERT(qSubdivs[i] >= 0); | 914 SkASSERT(qSubdivs[i] >= 0); |
916 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); | 915 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); |
917 } | 916 } |
918 | 917 |
919 // Start Conics | 918 // Start Conics |
920 for (int i = 0; i < conicCount; ++i) { | 919 for (int i = 0; i < conicCount; ++i) { |
921 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &bezVerts); | 920 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &bezVerts); |
922 } | 921 } |
923 | 922 |
924 if (quadCount > 0) { | 923 if (quadCount > 0) { |
925 target->initDraw(quadGP, this->pipeline()); | 924 target->initDraw(quadGP, kTriangles_GrPrimitiveType); |
926 | 925 |
927 { | 926 { |
928 GrVertices tempVerts; | 927 GrVertices tempVerts; |
929 tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer
, quadsIndexBuffer, | 928 tempVerts.initInstanced(vertexBuffer, quadsIndexBuffer, firstVer
tex, |
930 firstVertex, kQuadNumVertices, kIdxsPerQ
uad, quadCount, | 929 kQuadNumVertices, kIdxsPerQuad, quadCoun
t, |
931 kQuadsNumInIdxBuffer); | 930 kQuadsNumInIdxBuffer); |
932 target->draw(tempVerts); | 931 target->draw(tempVerts); |
933 firstVertex += quadCount * kQuadNumVertices; | 932 firstVertex += quadCount * kQuadNumVertices; |
934 } | 933 } |
935 } | 934 } |
936 | 935 |
937 if (conicCount > 0) { | 936 if (conicCount > 0) { |
938 target->initDraw(conicGP, this->pipeline()); | 937 target->initDraw(conicGP, kTriangles_GrPrimitiveType); |
939 | 938 |
940 { | 939 { |
941 GrVertices tempVerts; | 940 GrVertices tempVerts; |
942 tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer
, quadsIndexBuffer, | 941 tempVerts.initInstanced(vertexBuffer, quadsIndexBuffer, firstVer
tex, |
943 firstVertex, kQuadNumVertices, kIdxsPerQ
uad, conicCount, | 942 kQuadNumVertices, kIdxsPerQuad, conicCou
nt, |
944 kQuadsNumInIdxBuffer); | 943 kQuadsNumInIdxBuffer); |
945 target->draw(tempVerts); | 944 target->draw(tempVerts); |
946 } | 945 } |
947 } | 946 } |
948 } | 947 } |
949 } | 948 } |
950 | 949 |
951 static GrDrawBatch* create_hairline_batch(GrColor color, | 950 static GrDrawBatch* create_hairline_batch(GrColor color, |
952 const SkMatrix& viewMatrix, | 951 const SkMatrix& viewMatrix, |
953 const SkPath& path, | 952 const SkPath& path, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 GrColor color = GrRandomColor(random); | 989 GrColor color = GrRandomColor(random); |
991 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 990 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
992 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | 991 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); |
993 SkPath path = GrTest::TestPath(random); | 992 SkPath path = GrTest::TestPath(random); |
994 SkIRect devClipBounds; | 993 SkIRect devClipBounds; |
995 devClipBounds.setEmpty(); | 994 devClipBounds.setEmpty(); |
996 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 995 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; |
997 } | 996 } |
998 | 997 |
999 #endif | 998 #endif |
OLD | NEW |