Change vertex buffer allocator functions to take size rather than layout, take two.
Resubmission of r7498.
https://codereview.appspot.com/7228078
git-svn-id: http://skia.googlecode.com/svn/trunk@7501 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrBufferAllocPool.cpp b/src/gpu/GrBufferAllocPool.cpp
index 831c430..ec8a9c9 100644
--- a/src/gpu/GrBufferAllocPool.cpp
+++ b/src/gpu/GrBufferAllocPool.cpp
@@ -373,7 +373,7 @@
preallocBufferCnt) {
}
-void* GrVertexBufferAllocPool::makeSpace(GrVertexLayout layout,
+void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize,
int vertexCount,
const GrVertexBuffer** buffer,
int* startVertex) {
@@ -382,43 +382,41 @@
GrAssert(NULL != buffer);
GrAssert(NULL != startVertex);
- size_t vSize = GrDrawState::VertexSize(layout);
size_t offset = 0; // assign to suppress warning
const GrGeometryBuffer* geomBuffer = NULL; // assign to suppress warning
- void* ptr = INHERITED::makeSpace(vSize * vertexCount,
- vSize,
+ void* ptr = INHERITED::makeSpace(vertexSize * vertexCount,
+ vertexSize,
&geomBuffer,
&offset);
*buffer = (const GrVertexBuffer*) geomBuffer;
- GrAssert(0 == offset % vSize);
- *startVertex = offset / vSize;
+ GrAssert(0 == offset % vertexSize);
+ *startVertex = offset / vertexSize;
return ptr;
}
-bool GrVertexBufferAllocPool::appendVertices(GrVertexLayout layout,
+bool GrVertexBufferAllocPool::appendVertices(size_t vertexSize,
int vertexCount,
const void* vertices,
const GrVertexBuffer** buffer,
int* startVertex) {
- void* space = makeSpace(layout, vertexCount, buffer, startVertex);
+ void* space = makeSpace(vertexSize, vertexCount, buffer, startVertex);
if (NULL != space) {
memcpy(space,
vertices,
- GrDrawState::VertexSize(layout) * vertexCount);
+ vertexSize * vertexCount);
return true;
} else {
return false;
}
}
-int GrVertexBufferAllocPool::preallocatedBufferVertices(GrVertexLayout layout) const {
- return INHERITED::preallocatedBufferSize() /
- GrDrawState::VertexSize(layout);
+int GrVertexBufferAllocPool::preallocatedBufferVertices(size_t vertexSize) const {
+ return INHERITED::preallocatedBufferSize() / vertexSize;
}
-int GrVertexBufferAllocPool::currentBufferVertices(GrVertexLayout layout) const {
- return currentBufferItems(GrDrawState::VertexSize(layout));
+int GrVertexBufferAllocPool::currentBufferVertices(size_t vertexSize) const {
+ return currentBufferItems(vertexSize);
}
////////////////////////////////////////////////////////////////////////////////