Chromium Code Reviews| Index: src/gpu/GrBatchTarget.h |
| diff --git a/src/gpu/GrBatchTarget.h b/src/gpu/GrBatchTarget.h |
| index 91726e5b9f7df20e942e64b688cc12052e0956b3..7019a67ab3ac91324e253af06c3b479ca3364849 100644 |
| --- a/src/gpu/GrBatchTarget.h |
| +++ b/src/gpu/GrBatchTarget.h |
| @@ -19,16 +19,10 @@ |
| * GrBatch instances use this object to allocate space for their geometry and to issue the draws |
| * that render their batch. |
| */ |
| - |
| -class GrIndexBufferAllocPool; |
| -class GrVertexBufferAllocPool; |
| - |
| class GrBatchTarget : public SkNoncopyable { |
| public: |
| typedef GrBatchAtlas::BatchToken BatchToken; |
| - GrBatchTarget(GrGpu* gpu, |
| - GrVertexBufferAllocPool* vpool, |
| - GrIndexBufferAllocPool* ipool); |
| + GrBatchTarget(GrGpu* gpu); |
| void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeline) { |
| GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipeline)); |
| @@ -94,6 +88,7 @@ public: |
| void resetNumberOfDraws() { fNumberOfDraws = 0; } |
| int numberOfDraws() const { return fNumberOfDraws; } |
| void preFlush() { |
| + this->unmap(); |
| int updateCount = fAsapUploads.count(); |
| for (int i = 0; i < updateCount; i++) { |
| fAsapUploads[i]->upload(TextureUploader(fGpu)); |
| @@ -117,11 +112,13 @@ public: |
| const GrDrawTargetCaps& caps() const { return *fGpu->caps(); } |
| - GrVertexBufferAllocPool* vertexPool() { return fVertexPool; } |
| - GrIndexBufferAllocPool* indexPool() { return fIndexPool; } |
| - |
| GrResourceProvider* resourceProvider() const { return fGpu->getContext()->resourceProvider(); } |
| + void* makeVertSpace(size_t vertexSize, int vertexCount, |
| + const GrVertexBuffer** buffer, int* startVertex); |
| + uint16_t* makeIndexSpace(int indexCount, |
| + const GrIndexBuffer** buffer, int* startIndex); |
| + |
| // A helper for draws which overallocate and then return data to the pool |
| void putBackIndices(size_t indices) { fIndexPool->putBack(indices * sizeof(uint16_t)); } |
| @@ -129,10 +126,20 @@ public: |
| fVertexPool->putBack(vertices * vertexStride); |
| } |
| + void unmap() { |
|
bsalomon
2015/05/07 14:28:40
Maybe a bit more descriptive name here? unmapBuffe
robertphillips
2015/05/07 14:34:21
Done-ish. unmap has been renamed and made private.
|
| + fVertexPool->unmap(); |
| + fIndexPool->unmap(); |
| + } |
| + |
| + void reset() { |
| + fVertexPool->reset(); |
| + fIndexPool->reset(); |
| + } |
| + |
| private: |
| GrGpu* fGpu; |
| - GrVertexBufferAllocPool* fVertexPool; |
| - GrIndexBufferAllocPool* fIndexPool; |
| + SkAutoTDelete<GrVertexBufferAllocPool> fVertexPool; |
| + SkAutoTDelete<GrIndexBufferAllocPool> fIndexPool; |
| typedef void* TBufferAlign; // This wouldn't be enough align if a command used long double. |