OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 GrInOrderDrawBuffer_DEFINED | 8 #ifndef GrInOrderDrawBuffer_DEFINED |
9 #define GrInOrderDrawBuffer_DEFINED | 9 #define GrInOrderDrawBuffer_DEFINED |
10 | 10 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // Determines whether the current draw operation requires a new GrPipeline a
nd if so | 291 // Determines whether the current draw operation requires a new GrPipeline a
nd if so |
292 // records it. If the draw can be skipped false is returned and no new GrPip
eline is | 292 // records it. If the draw can be skipped false is returned and no new GrPip
eline is |
293 // recorded. | 293 // recorded. |
294 // TODO delete the primproc variant when we have batches everywhere | 294 // TODO delete the primproc variant when we have batches everywhere |
295 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(const GrPrimitiveProce
ssor*, | 295 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(const GrPrimitiveProce
ssor*, |
296 const PipelineInfo&); | 296 const PipelineInfo&); |
297 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrBatch*, const Pipeli
neInfo&); | 297 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrBatch*, const Pipeli
neInfo&); |
298 | 298 |
299 // We lazily record clip changes in order to skip clips that have no effect. | 299 // We lazily record clip changes in order to skip clips that have no effect. |
300 void recordClipIfNecessary(); | 300 void recordClipIfNecessary(); |
301 // Records any trace markers for a command after adding it to the buffer. | 301 // Records any trace markers for a command |
302 void recordTraceMarkersIfNecessary(); | 302 void recordTraceMarkersIfNecessary(Cmd*); |
303 | 303 SkString getCmdString(int index) const { |
| 304 SkASSERT(index < fGpuCmdMarkers.count()); |
| 305 return fGpuCmdMarkers[index].toString(); |
| 306 } |
304 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } | 307 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } |
305 | 308 |
306 GrBatchTarget* getBatchTarget() { return &fBatchTarget; } | 309 GrBatchTarget* getBatchTarget() { return &fBatchTarget; } |
307 | 310 |
308 // TODO: Use a single allocator for commands and records | 311 // TODO: Use a single allocator for commands and records |
309 enum { | 312 enum { |
310 kCmdBufferInitialSizeInBytes = 8 * 1024, | 313 kCmdBufferInitialSizeInBytes = 8 * 1024, |
311 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 314 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
312 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 315 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
313 }; | 316 }; |
314 | 317 |
315 CmdBuffer fCmdBuffer; | 318 CmdBuffer fCmdBuffer; |
316 SetState* fPrevState; | 319 SetState* fPrevState; |
317 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 320 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
318 SkChunkAlloc fPathIndexBuffer; | 321 SkChunkAlloc fPathIndexBuffer; |
319 SkChunkAlloc fPathTransformBuffer; | 322 SkChunkAlloc fPathTransformBuffer; |
320 uint32_t fDrawID; | 323 uint32_t fDrawID; |
321 GrBatchTarget fBatchTarget; | 324 GrBatchTarget fBatchTarget; |
322 // TODO hack until batch is everywhere | 325 // TODO hack until batch is everywhere |
323 DrawBatch* fDrawBatch; | 326 DrawBatch* fDrawBatch; |
324 | 327 |
325 // This will go away when everything uses batch. However, in the short term
anything which | 328 // This will go away when everything uses batch. However, in the short term
anything which |
326 // might be put into the GrInOrderDrawBuffer needs to make sure it closes th
e last batch | 329 // might be put into the GrInOrderDrawBuffer needs to make sure it closes th
e last batch |
327 void closeBatch() { | 330 inline void closeBatch(); |
328 if (fDrawBatch) { | |
329 fBatchTarget.resetNumberOfDraws(); | |
330 fDrawBatch->execute(this->getGpu(), fPrevState); | |
331 fDrawBatch->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); | |
332 fDrawBatch = NULL; | |
333 } | |
334 } | |
335 | 331 |
336 typedef GrFlushToGpuDrawTarget INHERITED; | 332 typedef GrFlushToGpuDrawTarget INHERITED; |
337 }; | 333 }; |
338 | 334 |
339 #endif | 335 #endif |
OLD | NEW |