OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 | 10 |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 | 787 |
788 if (!get_segments(args.fPath, *viewMatrix, &segments, &fanPt, &verte
xCount, | 788 if (!get_segments(args.fPath, *viewMatrix, &segments, &fanPt, &verte
xCount, |
789 &indexCount)) { | 789 &indexCount)) { |
790 continue; | 790 continue; |
791 } | 791 } |
792 | 792 |
793 const GrVertexBuffer* vertexBuffer; | 793 const GrVertexBuffer* vertexBuffer; |
794 int firstVertex; | 794 int firstVertex; |
795 | 795 |
796 size_t vertexStride = quadProcessor->getVertexStride(); | 796 size_t vertexStride = quadProcessor->getVertexStride(); |
797 void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCoun
t, | 797 QuadVertex* verts = reinterpret_cast<QuadVertex*>(batchTarget->makeV
ertSpace( |
798 &vertexBuffer, &firstVer
tex); | 798 vertexStride, vertexCount, &vertexBuffer, &firstVertex)); |
799 if (!vertices) { | 799 |
| 800 if (!verts) { |
800 SkDebugf("Could not allocate vertices\n"); | 801 SkDebugf("Could not allocate vertices\n"); |
801 return; | 802 return; |
802 } | 803 } |
803 | 804 |
804 const GrIndexBuffer* indexBuffer; | 805 const GrIndexBuffer* indexBuffer; |
805 int firstIndex; | 806 int firstIndex; |
806 | 807 |
807 uint16_t *idxs = batchTarget->makeIndexSpace(indexCount, &indexBuffe
r, &firstIndex); | 808 uint16_t *idxs = batchTarget->makeIndexSpace(indexCount, &indexBuffe
r, &firstIndex); |
808 if (!idxs) { | 809 if (!idxs) { |
809 SkDebugf("Could not allocate indices\n"); | 810 SkDebugf("Could not allocate indices\n"); |
810 return; | 811 return; |
811 } | 812 } |
812 | 813 |
813 QuadVertex* verts = reinterpret_cast<QuadVertex*>(vertices); | |
814 | |
815 SkSTArray<kPreallocDrawCnt, Draw, true> draws; | 814 SkSTArray<kPreallocDrawCnt, Draw, true> draws; |
816 create_vertices(segments, fanPt, &draws, verts, idxs); | 815 create_vertices(segments, fanPt, &draws, verts, idxs); |
817 | 816 |
818 GrVertices info; | 817 GrVertices vertices; |
819 | 818 |
820 for (int i = 0; i < draws.count(); ++i) { | 819 for (int i = 0; i < draws.count(); ++i) { |
821 const Draw& draw = draws[i]; | 820 const Draw& draw = draws[i]; |
822 info.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, index
Buffer, firstVertex, | 821 vertices.initIndexed(kTriangles_GrPrimitiveType, vertexBuffer, i
ndexBuffer, |
823 firstIndex, draw.fVertexCnt, draw.fIndexCnt); | 822 firstVertex, firstIndex, draw.fVertexCnt, d
raw.fIndexCnt); |
824 batchTarget->draw(info); | 823 batchTarget->draw(vertices); |
825 firstVertex += draw.fVertexCnt; | 824 firstVertex += draw.fVertexCnt; |
826 firstIndex += draw.fIndexCnt; | 825 firstIndex += draw.fIndexCnt; |
827 } | 826 } |
828 } | 827 } |
829 } | 828 } |
830 | 829 |
831 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 830 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
832 | 831 |
833 private: | 832 private: |
834 AAConvexPathBatch(const Geometry& geometry) { | 833 AAConvexPathBatch(const Geometry& geometry) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 geometry.fColor = color; | 886 geometry.fColor = color; |
888 geometry.fViewMatrix = vm; | 887 geometry.fViewMatrix = vm; |
889 geometry.fPath = path; | 888 geometry.fPath = path; |
890 | 889 |
891 SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry)); | 890 SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry)); |
892 target->drawBatch(pipelineBuilder, batch); | 891 target->drawBatch(pipelineBuilder, batch); |
893 | 892 |
894 return true; | 893 return true; |
895 | 894 |
896 } | 895 } |
OLD | NEW |