| 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 #ifndef GrVertices_DEFINED | 8 #ifndef GrVertices_DEFINED |
| 9 #define GrVertices_DEFINED | 9 #define GrVertices_DEFINED |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 GrVertices(const GrVertices& di) { (*this) = di; } | 46 GrVertices(const GrVertices& di) { (*this) = di; } |
| 47 GrVertices& operator =(const GrVertices& di); | 47 GrVertices& operator =(const GrVertices& di); |
| 48 | 48 |
| 49 void init(GrPrimitiveType primType, const GrVertexBuffer* vertexBuffer, int
startVertex, | 49 void init(GrPrimitiveType primType, const GrVertexBuffer* vertexBuffer, int
startVertex, |
| 50 int vertexCount) { | 50 int vertexCount) { |
| 51 SkASSERT(vertexBuffer); | 51 SkASSERT(vertexBuffer); |
| 52 SkASSERT(vertexCount); | 52 SkASSERT(vertexCount); |
| 53 SkASSERT(startVertex >= 0); | 53 SkASSERT(startVertex >= 0); |
| 54 fPrimitiveType = primType; | 54 fPrimitiveType = primType; |
| 55 fVertexBuffer.reset(vertexBuffer); | 55 fVertexBuffer.reset(vertexBuffer); |
| 56 fIndexBuffer.reset(NULL); | 56 fIndexBuffer.reset(nullptr); |
| 57 fStartVertex = startVertex; | 57 fStartVertex = startVertex; |
| 58 fStartIndex = 0; | 58 fStartIndex = 0; |
| 59 fVertexCount = vertexCount; | 59 fVertexCount = vertexCount; |
| 60 fIndexCount = 0; | 60 fIndexCount = 0; |
| 61 fInstanceCount = 0; | 61 fInstanceCount = 0; |
| 62 fVerticesPerInstance = 0; | 62 fVerticesPerInstance = 0; |
| 63 fIndicesPerInstance = 0; | 63 fIndicesPerInstance = 0; |
| 64 fMaxInstancesPerDraw = 0; | 64 fMaxInstancesPerDraw = 0; |
| 65 } | 65 } |
| 66 | 66 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 vertices.fVerticesPerInstance; | 147 vertices.fVerticesPerInstance; |
| 148 fInstanceBatch.fPrimitiveType = vertices.fPrimitiveType; | 148 fInstanceBatch.fPrimitiveType = vertices.fPrimitiveType; |
| 149 fInstanceBatch.fStartIndex = vertices.fStartIndex; | 149 fInstanceBatch.fStartIndex = vertices.fStartIndex; |
| 150 fInstanceBatch.fStartVertex = vertices.fStartVertex; | 150 fInstanceBatch.fStartVertex = vertices.fStartVertex; |
| 151 fInstancesRemaining = vertices.fInstanceCount - vertices.fMaxInstanc
esPerDraw; | 151 fInstancesRemaining = vertices.fInstanceCount - vertices.fMaxInstanc
esPerDraw; |
| 152 return &fInstanceBatch; | 152 return &fInstanceBatch; |
| 153 } | 153 } |
| 154 | 154 |
| 155 const GrNonInstancedVertices* next() { | 155 const GrNonInstancedVertices* next() { |
| 156 if (!fInstancesRemaining) { | 156 if (!fInstancesRemaining) { |
| 157 return NULL; | 157 return nullptr; |
| 158 } | 158 } |
| 159 fInstanceBatch.fStartVertex += fInstanceBatch.fVertexCount; | 159 fInstanceBatch.fStartVertex += fInstanceBatch.fVertexCount; |
| 160 int instances = SkTMin(fInstancesRemaining, fVertices->fMaxInstances
PerDraw); | 160 int instances = SkTMin(fInstancesRemaining, fVertices->fMaxInstances
PerDraw); |
| 161 fInstanceBatch.fIndexCount = instances * fVertices->fIndicesPerInsta
nce; | 161 fInstanceBatch.fIndexCount = instances * fVertices->fIndicesPerInsta
nce; |
| 162 fInstanceBatch.fVertexCount = instances * fVertices->fVerticesPerIns
tance; | 162 fInstanceBatch.fVertexCount = instances * fVertices->fVerticesPerIns
tance; |
| 163 fInstancesRemaining -= instances; | 163 fInstancesRemaining -= instances; |
| 164 return &fInstanceBatch; | 164 return &fInstanceBatch; |
| 165 } | 165 } |
| 166 private: | 166 private: |
| 167 GrNonInstancedVertices fInstanceBatch; | 167 GrNonInstancedVertices fInstanceBatch; |
| 168 const GrVertices* fVertices; | 168 const GrVertices* fVertices; |
| 169 int fInstancesRemaining; | 169 int fInstancesRemaining; |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 int fInstanceCount; | 173 int fInstanceCount; |
| 174 int fVerticesPerInstance; | 174 int fVerticesPerInstance; |
| 175 int fIndicesPerInstance; | 175 int fIndicesPerInstance; |
| 176 int fMaxInstancesPerDraw; | 176 int fMaxInstancesPerDraw; |
| 177 }; | 177 }; |
| 178 | 178 |
| 179 #endif | 179 #endif |
| OLD | NEW |