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 GrBatchBuffer_DEFINED | 8 #ifndef GrBatchBuffer_DEFINED |
9 #define GrBatchBuffer_DEFINED | 9 #define GrBatchBuffer_DEFINED |
10 | 10 |
| 11 #include "GrBufferAllocPool.h" |
11 #include "GrPendingProgramElement.h" | 12 #include "GrPendingProgramElement.h" |
12 #include "GrPipeline.h" | 13 #include "GrPipeline.h" |
13 #include "GrGpu.h" | 14 #include "GrGpu.h" |
14 #include "GrTRecorder.h" | 15 #include "GrTRecorder.h" |
15 | 16 |
16 /* | 17 /* |
17 * GrBatch instances use this object to allocate space for their geometry and to
issue the draws | 18 * GrBatch instances use this object to allocate space for their geometry and to
issue the draws |
18 * that render their batch. | 19 * that render their batch. |
19 */ | 20 */ |
20 | 21 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 return &fFlushBuffer.back().fBatchTracker; | 76 return &fFlushBuffer.back().fBatchTracker; |
76 } | 77 } |
77 | 78 |
78 const GrDrawTargetCaps& caps() const { return *fGpu->caps(); } | 79 const GrDrawTargetCaps& caps() const { return *fGpu->caps(); } |
79 | 80 |
80 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; } | 81 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; } |
81 GrIndexBufferAllocPool* indexPool() { return fIndexPool; } | 82 GrIndexBufferAllocPool* indexPool() { return fIndexPool; } |
82 | 83 |
83 const GrIndexBuffer* quadIndexBuffer() const { return fGpu->getQuadIndexBuff
er(); } | 84 const GrIndexBuffer* quadIndexBuffer() const { return fGpu->getQuadIndexBuff
er(); } |
84 | 85 |
| 86 // A helper for draws which overallocate and then return data to the pool |
| 87 void putBackIndices(size_t indices) { fIndexPool->putBack(indices * sizeof(u
int16_t)); } |
| 88 |
| 89 void putBackVertices(size_t vertices, size_t vertexStride) { |
| 90 fVertexPool->putBack(vertices * vertexStride); |
| 91 } |
| 92 |
85 private: | 93 private: |
86 GrGpu* fGpu; | 94 GrGpu* fGpu; |
87 GrVertexBufferAllocPool* fVertexPool; | 95 GrVertexBufferAllocPool* fVertexPool; |
88 GrIndexBufferAllocPool* fIndexPool; | 96 GrIndexBufferAllocPool* fIndexPool; |
89 | 97 |
90 typedef void* TBufferAlign; // This wouldn't be enough align if a command us
ed long double. | 98 typedef void* TBufferAlign; // This wouldn't be enough align if a command us
ed long double. |
91 | 99 |
92 struct BufferedFlush { | 100 struct BufferedFlush { |
93 BufferedFlush(const GrPrimitiveProcessor* primProc, const GrPipeline* pi
peline) | 101 BufferedFlush(const GrPrimitiveProcessor* primProc, const GrPipeline* pi
peline) |
94 : fPrimitiveProcessor(primProc) | 102 : fPrimitiveProcessor(primProc) |
(...skipping 11 matching lines...) Expand all Loading... |
106 | 114 |
107 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer; | 115 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer; |
108 | 116 |
109 FlushBuffer fFlushBuffer; | 117 FlushBuffer fFlushBuffer; |
110 // TODO this is temporary | 118 // TODO this is temporary |
111 FlushBuffer::Iter fIter; | 119 FlushBuffer::Iter fIter; |
112 int fNumberOfDraws; | 120 int fNumberOfDraws; |
113 }; | 121 }; |
114 | 122 |
115 #endif | 123 #endif |
OLD | NEW |