| 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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 init.fOverrideColor = GrColor_ILLEGAL; | 862 init.fOverrideColor = GrColor_ILLEGAL; |
| 863 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 863 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
| 864 init.fUsesLocalCoords = this->usesLocalCoords(); | 864 init.fUsesLocalCoords = this->usesLocalCoords(); |
| 865 lineGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | 865 lineGP->initBatchTracker(batchTarget->currentBatchTracker(), init); |
| 866 | 866 |
| 867 const GrVertexBuffer* vertexBuffer; | 867 const GrVertexBuffer* vertexBuffer; |
| 868 int firstVertex; | 868 int firstVertex; |
| 869 | 869 |
| 870 size_t vertexStride = lineGP->getVertexStride(); | 870 size_t vertexStride = lineGP->getVertexStride(); |
| 871 int vertexCount = kLineSegNumVertices * lineCount; | 871 int vertexCount = kLineSegNumVertices * lineCount; |
| 872 void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount, | 872 LineVertex* verts = reinterpret_cast<LineVertex*>( |
| 873 &vertexBuffer, &firstVertex)
; | 873 batchTarget->makeVertSpace(vertexStride, vertexCount, &vertexBuffer,
&firstVertex)); |
| 874 | 874 |
| 875 if (!vertices || !linesIndexBuffer) { | 875 if (!verts|| !linesIndexBuffer) { |
| 876 SkDebugf("Could not allocate vertices\n"); | 876 SkDebugf("Could not allocate vertices\n"); |
| 877 return; | 877 return; |
| 878 } | 878 } |
| 879 | 879 |
| 880 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex)); | 880 SkASSERT(lineGP->getVertexStride() == sizeof(LineVertex)); |
| 881 | 881 |
| 882 LineVertex* verts = reinterpret_cast<LineVertex*>(vertices); | |
| 883 for (int i = 0; i < lineCount; ++i) { | 882 for (int i = 0; i < lineCount; ++i) { |
| 884 add_line(&lines[2*i], toSrc, this->coverage(), &verts); | 883 add_line(&lines[2*i], toSrc, this->coverage(), &verts); |
| 885 } | 884 } |
| 886 | 885 |
| 887 { | 886 { |
| 888 int linesLeft = lineCount; | 887 GrVertices vertices; |
| 889 GrVertices info; | 888 vertices.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, lin
esIndexBuffer, |
| 890 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, linesIn
dexBuffer, | 889 firstVertex, kLineSegNumVertices, kIdxsPerLin
eSeg, lineCount, |
| 891 firstVertex, kLineSegNumVertices, kIdxsPerLineSeg
, &linesLeft, | 890 kLineSegsNumInIdxBuffer); |
| 892 kLineSegsNumInIdxBuffer); | 891 batchTarget->draw(vertices); |
| 893 do { | |
| 894 batchTarget->draw(info); | |
| 895 } while (info.nextInstances(&linesLeft, kLineSegsNumInIdxBuffer)); | |
| 896 } | 892 } |
| 897 } | 893 } |
| 898 | 894 |
| 899 if (quadCount || conicCount) { | 895 if (quadCount || conicCount) { |
| 900 const GrVertexBuffer* vertexBuffer; | 896 const GrVertexBuffer* vertexBuffer; |
| 901 int firstVertex; | 897 int firstVertex; |
| 902 | 898 |
| 903 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( | 899 SkAutoTUnref<const GrIndexBuffer> quadsIndexBuffer( |
| 904 ref_quads_index_buffer(batchTarget->resourceProvider())); | 900 ref_quads_index_buffer(batchTarget->resourceProvider())); |
| 905 | 901 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 932 | 928 |
| 933 // TODO remove this when batch is everywhere | 929 // TODO remove this when batch is everywhere |
| 934 GrPipelineInfo init; | 930 GrPipelineInfo init; |
| 935 init.fColorIgnored = fBatch.fColorIgnored; | 931 init.fColorIgnored = fBatch.fColorIgnored; |
| 936 init.fOverrideColor = GrColor_ILLEGAL; | 932 init.fOverrideColor = GrColor_ILLEGAL; |
| 937 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 933 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
| 938 init.fUsesLocalCoords = this->usesLocalCoords(); | 934 init.fUsesLocalCoords = this->usesLocalCoords(); |
| 939 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | 935 quadGP->initBatchTracker(batchTarget->currentBatchTracker(), init); |
| 940 | 936 |
| 941 { | 937 { |
| 942 int quadsLeft = quadCount; | 938 GrVertices verts; |
| 943 GrVertices info; | 939 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, |
| 944 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua
dsIndexBuffer, | 940 firstVertex, kQuadNumVertices, kIdxsPerQuad,
quadCount, |
| 945 firstVertex, kQuadNumVertices, kIdxsPerQuad,
&quadsLeft, | 941 kQuadsNumInIdxBuffer); |
| 946 kQuadsNumInIdxBuffer); | 942 batchTarget->draw(verts); |
| 947 do { | 943 firstVertex += quadCount * kQuadNumVertices; |
| 948 batchTarget->draw(info); | |
| 949 } while (info.nextInstances(&quadsLeft, kQuadsNumInIdxBuffer)); | |
| 950 firstVertex += quadCount * kQuadNumVertices; | |
| 951 } | 944 } |
| 952 } | 945 } |
| 953 | 946 |
| 954 if (conicCount > 0) { | 947 if (conicCount > 0) { |
| 955 batchTarget->initDraw(conicGP, pipeline); | 948 batchTarget->initDraw(conicGP, pipeline); |
| 956 | 949 |
| 957 // TODO remove this when batch is everywhere | 950 // TODO remove this when batch is everywhere |
| 958 GrPipelineInfo init; | 951 GrPipelineInfo init; |
| 959 init.fColorIgnored = fBatch.fColorIgnored; | 952 init.fColorIgnored = fBatch.fColorIgnored; |
| 960 init.fOverrideColor = GrColor_ILLEGAL; | 953 init.fOverrideColor = GrColor_ILLEGAL; |
| 961 init.fCoverageIgnored = fBatch.fCoverageIgnored; | 954 init.fCoverageIgnored = fBatch.fCoverageIgnored; |
| 962 init.fUsesLocalCoords = this->usesLocalCoords(); | 955 init.fUsesLocalCoords = this->usesLocalCoords(); |
| 963 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init); | 956 conicGP->initBatchTracker(batchTarget->currentBatchTracker(), init); |
| 964 | 957 |
| 965 { | 958 { |
| 966 int conicsLeft = conicCount; | 959 GrVertices verts; |
| 967 GrVertices info; | 960 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, |
| 968 info.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qua
dsIndexBuffer, | 961 firstVertex, kQuadNumVertices, kIdxsPerQuad,
conicCount, |
| 969 firstVertex, kQuadNumVertices, kIdxsPerQuad, &
conicsLeft, | 962 kQuadsNumInIdxBuffer); |
| 970 kQuadsNumInIdxBuffer); | 963 batchTarget->draw(verts); |
| 971 do { | |
| 972 batchTarget->draw(info); | |
| 973 } while (info.nextInstances(&conicsLeft, kQuadsNumInIdxBuffer)); | |
| 974 } | 964 } |
| 975 } | 965 } |
| 976 } | 966 } |
| 977 } | 967 } |
| 978 | 968 |
| 979 static GrBatch* create_hairline_batch(GrColor color, | 969 static GrBatch* create_hairline_batch(GrColor color, |
| 980 const SkMatrix& viewMatrix, | 970 const SkMatrix& viewMatrix, |
| 981 const SkPath& path, | 971 const SkPath& path, |
| 982 const GrStrokeInfo& stroke, | 972 const GrStrokeInfo& stroke, |
| 983 const SkIRect& devClipBounds) { | 973 const SkIRect& devClipBounds) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 GrColor color = GrRandomColor(random); | 1013 GrColor color = GrRandomColor(random); |
| 1024 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 1014 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
| 1025 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | 1015 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); |
| 1026 SkPath path = GrTest::TestPath(random); | 1016 SkPath path = GrTest::TestPath(random); |
| 1027 SkIRect devClipBounds; | 1017 SkIRect devClipBounds; |
| 1028 devClipBounds.setEmpty(); | 1018 devClipBounds.setEmpty(); |
| 1029 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 1019 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; |
| 1030 } | 1020 } |
| 1031 | 1021 |
| 1032 #endif | 1022 #endif |
| OLD | NEW |