| 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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * coni
cCount; | 901 int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * coni
cCount; |
| 902 void *vertices = target->makeVertexSpace(vertexStride, vertexCount, | 902 void *vertices = target->makeVertexSpace(vertexStride, vertexCount, |
| 903 &vertexBuffer, &firstVertex); | 903 &vertexBuffer, &firstVertex); |
| 904 | 904 |
| 905 if (!vertices || !quadsIndexBuffer) { | 905 if (!vertices || !quadsIndexBuffer) { |
| 906 SkDebugf("Could not allocate vertices\n"); | 906 SkDebugf("Could not allocate vertices\n"); |
| 907 return; | 907 return; |
| 908 } | 908 } |
| 909 | 909 |
| 910 // Setup vertices | 910 // Setup vertices |
| 911 BezierVertex* verts = reinterpret_cast<BezierVertex*>(vertices); | 911 BezierVertex* bezVerts = reinterpret_cast<BezierVertex*>(vertices); |
| 912 | 912 |
| 913 int unsubdivQuadCnt = quads.count() / 3; | 913 int unsubdivQuadCnt = quads.count() / 3; |
| 914 for (int i = 0; i < unsubdivQuadCnt; ++i) { | 914 for (int i = 0; i < unsubdivQuadCnt; ++i) { |
| 915 SkASSERT(qSubdivs[i] >= 0); | 915 SkASSERT(qSubdivs[i] >= 0); |
| 916 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &verts); | 916 add_quads(&quads[3*i], qSubdivs[i], toDevice, toSrc, &bezVerts); |
| 917 } | 917 } |
| 918 | 918 |
| 919 // Start Conics | 919 // Start Conics |
| 920 for (int i = 0; i < conicCount; ++i) { | 920 for (int i = 0; i < conicCount; ++i) { |
| 921 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &verts); | 921 add_conics(&conics[3*i], cWeights[i], toDevice, toSrc, &bezVerts); |
| 922 } | 922 } |
| 923 | 923 |
| 924 if (quadCount > 0) { | 924 if (quadCount > 0) { |
| 925 target->initDraw(quadGP, this->pipeline()); | 925 target->initDraw(quadGP, this->pipeline()); |
| 926 | 926 |
| 927 { | 927 { |
| 928 GrVertices verts; | 928 GrVertices tempVerts; |
| 929 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, | 929 tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer
, quadsIndexBuffer, |
| 930 firstVertex, kQuadNumVertices, kIdxsPerQuad,
quadCount, | 930 firstVertex, kQuadNumVertices, kIdxsPerQ
uad, quadCount, |
| 931 kQuadsNumInIdxBuffer); | 931 kQuadsNumInIdxBuffer); |
| 932 target->draw(verts); | 932 target->draw(tempVerts); |
| 933 firstVertex += quadCount * kQuadNumVertices; | 933 firstVertex += quadCount * kQuadNumVertices; |
| 934 } | 934 } |
| 935 } | 935 } |
| 936 | 936 |
| 937 if (conicCount > 0) { | 937 if (conicCount > 0) { |
| 938 target->initDraw(conicGP, this->pipeline()); | 938 target->initDraw(conicGP, this->pipeline()); |
| 939 | 939 |
| 940 { | 940 { |
| 941 GrVertices verts; | 941 GrVertices tempVerts; |
| 942 verts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer, qu
adsIndexBuffer, | 942 tempVerts.initInstanced(kTriangles_GrPrimitiveType, vertexBuffer
, quadsIndexBuffer, |
| 943 firstVertex, kQuadNumVertices, kIdxsPerQuad,
conicCount, | 943 firstVertex, kQuadNumVertices, kIdxsPerQ
uad, conicCount, |
| 944 kQuadsNumInIdxBuffer); | 944 kQuadsNumInIdxBuffer); |
| 945 target->draw(verts); | 945 target->draw(tempVerts); |
| 946 } | 946 } |
| 947 } | 947 } |
| 948 } | 948 } |
| 949 } | 949 } |
| 950 | 950 |
| 951 static GrDrawBatch* create_hairline_batch(GrColor color, | 951 static GrDrawBatch* create_hairline_batch(GrColor color, |
| 952 const SkMatrix& viewMatrix, | 952 const SkMatrix& viewMatrix, |
| 953 const SkPath& path, | 953 const SkPath& path, |
| 954 const GrStrokeInfo& stroke, | 954 const GrStrokeInfo& stroke, |
| 955 const SkIRect& devClipBounds) { | 955 const SkIRect& devClipBounds) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 GrColor color = GrRandomColor(random); | 989 GrColor color = GrRandomColor(random); |
| 990 SkMatrix viewMatrix = GrTest::TestMatrix(random); | 990 SkMatrix viewMatrix = GrTest::TestMatrix(random); |
| 991 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); | 991 GrStrokeInfo stroke(SkStrokeRec::kHairline_InitStyle); |
| 992 SkPath path = GrTest::TestPath(random); | 992 SkPath path = GrTest::TestPath(random); |
| 993 SkIRect devClipBounds; | 993 SkIRect devClipBounds; |
| 994 devClipBounds.setEmpty(); | 994 devClipBounds.setEmpty(); |
| 995 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; | 995 return create_hairline_batch(color, viewMatrix, path, stroke, devClipBounds)
; |
| 996 } | 996 } |
| 997 | 997 |
| 998 #endif | 998 #endif |
| OLD | NEW |