| 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 "GrPendingProgramElement.h" | 11 #include "GrPendingProgramElement.h" |
| 12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
| 13 #include "GrTRecorder.h" | 13 #include "GrTRecorder.h" |
| 14 | 14 |
| 15 /* | 15 /* |
| 16 * GrBatch instances use this object to allocate space for their geometry and to
issue the draws | 16 * GrBatch instances use this object to allocate space for their geometry and to
issue the draws |
| 17 * that render their batch. | 17 * that render their batch. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 class GrIndexBufferAllocPool; |
| 21 class GrVertexBufferAllocPool; |
| 22 |
| 20 class GrBatchTarget : public SkNoncopyable { | 23 class GrBatchTarget : public SkNoncopyable { |
| 21 public: | 24 public: |
| 22 GrBatchTarget(GrGpu* gpu, | 25 GrBatchTarget(GrGpu* gpu, |
| 23 GrVertexBufferAllocPool* vpool, | 26 GrVertexBufferAllocPool* vpool, |
| 24 GrIndexBufferAllocPool* ipool) | 27 GrIndexBufferAllocPool* ipool) |
| 25 : fGpu(gpu) | 28 : fGpu(gpu) |
| 26 , fVertexPool(vpool) | 29 , fVertexPool(vpool) |
| 27 , fIndexPool(ipool) | 30 , fIndexPool(ipool) |
| 28 , fFlushBuffer(kFlushBufferInitialSizeInBytes) {} | 31 , fFlushBuffer(kFlushBufferInitialSizeInBytes) {} |
| 29 | 32 |
| 30 typedef GrDrawTarget::DrawInfo DrawInfo; | 33 typedef GrDrawTarget::DrawInfo DrawInfo; |
| 31 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli
ne) { | 34 void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeli
ne) { |
| 32 GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipelin
e)); | 35 GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipelin
e)); |
| 33 } | 36 } |
| 34 | 37 |
| 35 void draw(const GrDrawTarget::DrawInfo& draw) { | 38 void draw(const GrDrawTarget::DrawInfo& draw) { |
| 36 fFlushBuffer.back().fDraws.push_back(draw); | 39 fFlushBuffer.back().fDraws.push_back(draw); |
| 37 } | 40 } |
| 38 void flush(); | 41 void flush(); |
| 39 | 42 |
| 40 // TODO This goes away when everything uses batch | 43 // TODO This goes away when everything uses batch |
| 41 GrBatchTracker* currentBatchTracker() { | 44 GrBatchTracker* currentBatchTracker() { |
| 42 SkASSERT(!fFlushBuffer.empty()); | 45 SkASSERT(!fFlushBuffer.empty()); |
| 43 return &fFlushBuffer.back().fBatchTracker; | 46 return &fFlushBuffer.back().fBatchTracker; |
| 44 } | 47 } |
| 45 | 48 |
| 49 const GrDrawTargetCaps& caps() const { return *fGpu->caps(); } |
| 50 |
| 46 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; } | 51 GrVertexBufferAllocPool* vertexPool() { return fVertexPool; } |
| 47 GrIndexBufferAllocPool* indexPool() { return fIndexPool; } | 52 GrIndexBufferAllocPool* indexPool() { return fIndexPool; } |
| 48 | 53 |
| 49 private: | 54 private: |
| 50 GrGpu* fGpu; | 55 GrGpu* fGpu; |
| 51 GrVertexBufferAllocPool* fVertexPool; | 56 GrVertexBufferAllocPool* fVertexPool; |
| 52 GrIndexBufferAllocPool* fIndexPool; | 57 GrIndexBufferAllocPool* fIndexPool; |
| 53 | 58 |
| 54 typedef void* TBufferAlign; // This wouldn't be enough align if a command us
ed long double. | 59 typedef void* TBufferAlign; // This wouldn't be enough align if a command us
ed long double. |
| 55 | 60 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 69 kFlushBufferInitialSizeInBytes = 8 * sizeof(BufferedFlush), | 74 kFlushBufferInitialSizeInBytes = 8 * sizeof(BufferedFlush), |
| 70 kDrawRecorderInitialSizeInBytes = 8 * sizeof(DrawInfo), | 75 kDrawRecorderInitialSizeInBytes = 8 * sizeof(DrawInfo), |
| 71 }; | 76 }; |
| 72 | 77 |
| 73 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer; | 78 typedef GrTRecorder<BufferedFlush, TBufferAlign> FlushBuffer; |
| 74 | 79 |
| 75 FlushBuffer fFlushBuffer; | 80 FlushBuffer fFlushBuffer; |
| 76 }; | 81 }; |
| 77 | 82 |
| 78 #endif | 83 #endif |
| OLD | NEW |