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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 private: | 40 private: |
41 GrGpu* fGpu; | 41 GrGpu* fGpu; |
42 }; | 42 }; |
43 | 43 |
44 /** Tracks the state across all the GrBatches in a GrDrawTarget flush. */ | 44 /** Tracks the state across all the GrBatches in a GrDrawTarget flush. */ |
45 class GrBatchFlushState { | 45 class GrBatchFlushState { |
46 public: | 46 public: |
47 GrBatchFlushState(GrGpu*, GrResourceProvider*, GrBatchToken lastFlushedToken
); | 47 GrBatchFlushState(GrGpu*, GrResourceProvider*, GrBatchToken lastFlushedToken
); |
48 | 48 |
49 ~GrBatchFlushState() { SkASSERT(fLastFlushedToken == fCurrentToken); } | 49 ~GrBatchFlushState() { this->reset(); } |
50 | 50 |
51 void advanceToken() { ++fCurrentToken; } | 51 void advanceToken() { ++fCurrentToken; } |
52 | 52 |
53 void advanceLastFlushedToken() { ++fLastFlushedToken; } | 53 void advanceLastFlushedToken() { ++fLastFlushedToken; } |
54 | 54 |
55 /** Inserts an upload to be executred after all batches in the flush prepare
d their draws | 55 /** Inserts an upload to be executred after all batches in the flush prepare
d their draws |
56 but before the draws are executed to the backend 3D API. */ | 56 but before the draws are executed to the backend 3D API. */ |
57 void addASAPUpload(GrBatchUploader* upload) { | 57 void addASAPUpload(GrBatchUploader* upload) { |
58 fAsapUploads.push_back().reset(SkRef(upload)); | 58 fAsapUploads.push_back().reset(SkRef(upload)); |
59 } | 59 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 void putBackIndices(size_t indices) { fIndexPool.putBack(indices * sizeof(ui
nt16_t)); } | 94 void putBackIndices(size_t indices) { fIndexPool.putBack(indices * sizeof(ui
nt16_t)); } |
95 | 95 |
96 void putBackVertexSpace(size_t sizeInBytes) { fVertexPool.putBack(sizeInByte
s); } | 96 void putBackVertexSpace(size_t sizeInBytes) { fVertexPool.putBack(sizeInByte
s); } |
97 | 97 |
98 GrBatchUploader::TextureUploader* uploader() { return &fUploader; } | 98 GrBatchUploader::TextureUploader* uploader() { return &fUploader; } |
99 | 99 |
100 GrGpu* gpu() { return fGpu; } | 100 GrGpu* gpu() { return fGpu; } |
101 | 101 |
| 102 void reset() { |
| 103 fVertexPool.reset(); |
| 104 fIndexPool.reset(); |
| 105 } |
| 106 |
102 private: | 107 private: |
103 GrGpu* fGpu; | 108 GrGpu* fGpu; |
104 GrBatchUploader::TextureUploader fUploader; | 109 GrBatchUploader::TextureUploader fUploader; |
105 | 110 |
106 GrResourceProvider* fResourceProvider; | 111 GrResourceProvider* fResourceProvider; |
107 | 112 |
108 GrVertexBufferAllocPool fVertexPool; | 113 GrVertexBufferAllocPool fVertexPool; |
109 GrIndexBufferAllocPool fIndexPool; | 114 GrIndexBufferAllocPool fIndexPool; |
110 | 115 |
111 SkTArray<SkAutoTUnref<GrBatchUploader>, true> fAsapUploads; | 116 SkTArray<SkAutoTUnref<GrBatchUploader>, true> fAsapUploads; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void putBackVertices(int vertices, size_t vertexStride) { | 185 void putBackVertices(int vertices, size_t vertexStride) { |
181 this->state()->putBackVertexSpace(vertices * vertexStride); | 186 this->state()->putBackVertexSpace(vertices * vertexStride); |
182 } | 187 } |
183 | 188 |
184 private: | 189 private: |
185 GrVertexBatch* vertexBatch() { return static_cast<GrVertexBatch*>(this->batc
h()); } | 190 GrVertexBatch* vertexBatch() { return static_cast<GrVertexBatch*>(this->batc
h()); } |
186 typedef GrDrawBatch::Target INHERITED; | 191 typedef GrDrawBatch::Target INHERITED; |
187 }; | 192 }; |
188 | 193 |
189 #endif | 194 #endif |
OLD | NEW |