1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "GrBatchFlushState.h"
9 
10 #include "GrBatchAtlas.h"
11 #include "GrPipeline.h"
12 
GrBatchFlushState(GrGpu * gpu,GrResourceProvider * resourceProvider)13 GrBatchFlushState::GrBatchFlushState(GrGpu* gpu, GrResourceProvider* resourceProvider)
14     : fGpu(gpu)
15     , fResourceProvider(resourceProvider)
16     , fCommandBuffer(nullptr)
17     , fVertexPool(gpu)
18     , fIndexPool(gpu)
19     , fLastIssuedToken(GrBatchDrawToken::AlreadyFlushedToken())
20     , fLastFlushedToken(0) {}
21 
makeVertexSpace(size_t vertexSize,int vertexCount,const GrBuffer ** buffer,int * startVertex)22 void* GrBatchFlushState::makeVertexSpace(size_t vertexSize, int vertexCount,
23                                          const GrBuffer** buffer, int* startVertex) {
24     return fVertexPool.makeSpace(vertexSize, vertexCount, buffer, startVertex);
25 }
26 
makeIndexSpace(int indexCount,const GrBuffer ** buffer,int * startIndex)27 uint16_t* GrBatchFlushState::makeIndexSpace(int indexCount,
28                                             const GrBuffer** buffer, int* startIndex) {
29     return reinterpret_cast<uint16_t*>(fIndexPool.makeSpace(indexCount, buffer, startIndex));
30 }
31