OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrBatch.h" | 8 #include "GrBatch.h" |
9 #include "GrBatchTarget.h" | 9 #include "GrBatchTarget.h" |
10 #include "GrResourceProvider.h" | 10 #include "GrResourceProvider.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 &firstVertex); | 62 &firstVertex); |
63 if (!vertices) { | 63 if (!vertices) { |
64 SkDebugf("Vertices could not be allocated for instanced rendering."); | 64 SkDebugf("Vertices could not be allocated for instanced rendering."); |
65 return NULL; | 65 return NULL; |
66 } | 66 } |
67 SkASSERT(vertexBuffer); | 67 SkASSERT(vertexBuffer); |
68 fInstancesRemaining = instancesToDraw; | 68 fInstancesRemaining = instancesToDraw; |
69 size_t ibSize = indexBuffer->gpuMemorySize(); | 69 size_t ibSize = indexBuffer->gpuMemorySize(); |
70 fMaxInstancesPerDraw = static_cast<int>(ibSize / (sizeof(uint16_t) * indices
PerInstance)); | 70 fMaxInstancesPerDraw = static_cast<int>(ibSize / (sizeof(uint16_t) * indices
PerInstance)); |
71 | 71 |
72 fDrawInfo.initInstanced(primType, vertexBuffer, indexBuffer, | 72 fVertices.initInstanced(primType, vertexBuffer, indexBuffer, |
73 firstVertex, verticesPerInstance, indicesPerInstance, &fInstancesRemaini
ng, | 73 firstVertex, verticesPerInstance, indicesPerInstance, &fInstancesRemaini
ng, |
74 fMaxInstancesPerDraw); | 74 fMaxInstancesPerDraw); |
75 SkASSERT(fMaxInstancesPerDraw > 0); | 75 SkASSERT(fMaxInstancesPerDraw > 0); |
76 return vertices; | 76 return vertices; |
77 } | 77 } |
78 | 78 |
79 void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride,
int quadsToDraw) { | 79 void* GrBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride,
int quadsToDraw) { |
80 SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer( | 80 SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer( |
81 batchTarget->resourceProvider()->refQuadIndexBuffer()); | 81 batchTarget->resourceProvider()->refQuadIndexBuffer()); |
82 if (!quadIndexBuffer) { | 82 if (!quadIndexBuffer) { |
83 SkDebugf("Could not get quad index buffer."); | 83 SkDebugf("Could not get quad index buffer."); |
84 return NULL; | 84 return NULL; |
85 } | 85 } |
86 return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertex
Stride, | 86 return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertex
Stride, |
87 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ
uad, quadsToDraw); | 87 quadIndexBuffer, kVerticesPerQuad, kIndicesPerQ
uad, quadsToDraw); |
88 } | 88 } |
OLD | NEW |