OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 "GrContext.h" | 9 #include "GrContext.h" |
10 | 10 |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 return; | 903 return; |
904 } | 904 } |
905 GrDrawState* drawState = target->drawState(); | 905 GrDrawState* drawState = target->drawState(); |
906 | 906 |
907 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target); | 907 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target); |
908 | 908 |
909 int colorOffset = -1, texOffset = -1; | 909 int colorOffset = -1, texOffset = -1; |
910 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset
); | 910 set_vertex_attributes(drawState, texCoords, colors, &colorOffset, &texOffset
); |
911 | 911 |
912 size_t VertexStride = drawState->getVertexStride(); | 912 size_t VertexStride = drawState->getVertexStride(); |
913 if (sizeof(SkPoint) != VertexStride) { | 913 if (!geo.set(target, vertexCount, indexCount)) { |
914 if (!geo.set(target, vertexCount, 0)) { | 914 SkDebugf("Failed to get space for vertices!\n"); |
915 SkDebugf("Failed to get space for vertices!\n"); | 915 return; |
916 return; | 916 } |
| 917 void* curVertex = geo.vertices(); |
| 918 |
| 919 for (int i = 0; i < vertexCount; ++i) { |
| 920 *((SkPoint*)curVertex) = positions[i]; |
| 921 |
| 922 if (texOffset >= 0) { |
| 923 *(SkPoint*)((intptr_t)curVertex + texOffset) = texCoords[i]; |
917 } | 924 } |
918 void* curVertex = geo.vertices(); | 925 if (colorOffset >= 0) { |
919 | 926 *(GrColor*)((intptr_t)curVertex + colorOffset) = colors[i]; |
920 for (int i = 0; i < vertexCount; ++i) { | |
921 *((SkPoint*)curVertex) = positions[i]; | |
922 | |
923 if (texOffset >= 0) { | |
924 *(SkPoint*)((intptr_t)curVertex + texOffset) = texCoords[i]; | |
925 } | |
926 if (colorOffset >= 0) { | |
927 *(GrColor*)((intptr_t)curVertex + colorOffset) = colors[i]; | |
928 } | |
929 curVertex = (void*)((intptr_t)curVertex + VertexStride); | |
930 } | 927 } |
931 } else { | 928 curVertex = (void*)((intptr_t)curVertex + VertexStride); |
932 target->setVertexSourceToArray(positions, vertexCount); | |
933 } | 929 } |
934 | 930 |
935 // we don't currently apply offscreen AA to this path. Need improved | 931 // we don't currently apply offscreen AA to this path. Need improved |
936 // management of GrDrawTarget's geometry to avoid copying points per-tile. | 932 // management of GrDrawTarget's geometry to avoid copying points per-tile. |
937 | |
938 if (indices) { | 933 if (indices) { |
939 target->setIndexSourceToArray(indices, indexCount); | 934 uint16_t* curIndex = (uint16_t*)geo.indices(); |
| 935 for (int i = 0; i < indexCount; ++i) { |
| 936 curIndex[i] = indices[i]; |
| 937 } |
940 target->drawIndexed(primitiveType, 0, 0, vertexCount, indexCount); | 938 target->drawIndexed(primitiveType, 0, 0, vertexCount, indexCount); |
941 target->resetIndexSource(); | |
942 } else { | 939 } else { |
943 target->drawNonIndexed(primitiveType, 0, vertexCount); | 940 target->drawNonIndexed(primitiveType, 0, vertexCount); |
944 } | 941 } |
945 } | 942 } |
946 | 943 |
947 /////////////////////////////////////////////////////////////////////////////// | 944 /////////////////////////////////////////////////////////////////////////////// |
948 | 945 |
949 void GrContext::drawRRect(const GrPaint& paint, | 946 void GrContext::drawRRect(const GrPaint& paint, |
950 const SkRRect& rrect, | 947 const SkRRect& rrect, |
951 const GrStrokeInfo& strokeInfo) { | 948 const GrStrokeInfo& strokeInfo) { |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 fResourceCache->printStats(); | 1776 fResourceCache->printStats(); |
1780 } | 1777 } |
1781 #endif | 1778 #endif |
1782 | 1779 |
1783 #if GR_GPU_STATS | 1780 #if GR_GPU_STATS |
1784 const GrContext::GPUStats* GrContext::gpuStats() const { | 1781 const GrContext::GPUStats* GrContext::gpuStats() const { |
1785 return fGpu->gpuStats(); | 1782 return fGpu->gpuStats(); |
1786 } | 1783 } |
1787 #endif | 1784 #endif |
1788 | 1785 |
OLD | NEW |