| 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 |
| 11 #include "GrFlushToGpuDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 12 #include "GrTargetCommands.h" | 12 #include "GrTargetCommands.h" |
| 13 #include "SkChunkAlloc.h" | 13 #include "SkChunkAlloc.h" |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws
for eventual | 16 * GrInOrderDrawBuffer is an implementation of GrDrawTarget that queues up draws
for eventual |
| 17 * playback into a GrGpu. In theory one draw buffer could playback into another.
When index or | 17 * playback into a GrGpu. In theory one draw buffer could playback into another.
When index or |
| 18 * vertex buffers are used as geometry sources it is the callers the draw buffer
only holds | 18 * vertex buffers are used as geometry sources it is the callers the draw buffer
only holds |
| 19 * references to the buffers. It is the callers responsibility to ensure that th
e data is still | 19 * references to the buffers. It is the callers responsibility to ensure that th
e data is still |
| 20 * valid when the draw buffer is played back into a GrGpu. Similarly, it is the
caller's | 20 * valid when the draw buffer is played back into a GrGpu. Similarly, it is the
caller's |
| 21 * responsibility to ensure that all referenced textures, buffers, and render-ta
rgets are associated | 21 * responsibility to ensure that all referenced textures, buffers, and render-ta
rgets are associated |
| 22 * in the GrGpu object that the buffer is played back into. The buffer requires
VB and IB pools to | 22 * in the GrGpu object that the buffer is played back into. The buffer requires
VB and IB pools to |
| 23 * store geometry. | 23 * store geometry. |
| 24 */ | 24 */ |
| 25 class GrInOrderDrawBuffer : public GrFlushToGpuDrawTarget { | 25 class GrInOrderDrawBuffer : public GrClipTarget { |
| 26 public: | 26 public: |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Creates a GrInOrderDrawBuffer | 29 * Creates a GrInOrderDrawBuffer |
| 30 * | 30 * |
| 31 * @param gpu the gpu object that this draw buffer flushes to. | 31 * @param context the context object that owns this draw buffer. |
| 32 * @param vertexPool pool where vertices for queued draws will be saved when | 32 * @param vertexPool pool where vertices for queued draws will be saved when |
| 33 * the vertex source is either reserved or array. | 33 * the vertex source is either reserved or array. |
| 34 * @param indexPool pool where indices for queued draws will be saved when | 34 * @param indexPool pool where indices for queued draws will be saved when |
| 35 * the index source is either reserved or array. | 35 * the index source is either reserved or array. |
| 36 */ | 36 */ |
| 37 GrInOrderDrawBuffer(GrGpu* gpu, | 37 GrInOrderDrawBuffer(GrContext* context, |
| 38 GrVertexBufferAllocPool* vertexPool, | 38 GrVertexBufferAllocPool* vertexPool, |
| 39 GrIndexBufferAllocPool* indexPool); | 39 GrIndexBufferAllocPool* indexPool); |
| 40 | 40 |
| 41 ~GrInOrderDrawBuffer() override; | 41 ~GrInOrderDrawBuffer() override; |
| 42 | 42 |
| 43 // tracking for draws | 43 // tracking for draws |
| 44 DrawToken getCurrentDrawToken() override { return DrawToken(this, fDrawID);
} | 44 DrawToken getCurrentDrawToken() override { return DrawToken(this, fDrawID);
} |
| 45 | 45 |
| 46 void clearStencilClip(const SkIRect& rect, | 46 void clearStencilClip(const SkIRect& rect, |
| 47 bool insideClip, | 47 bool insideClip, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 PathIndexType, | 100 PathIndexType, |
| 101 const float transformValues[], | 101 const float transformValues[], |
| 102 PathTransformType, | 102 PathTransformType, |
| 103 int count, | 103 int count, |
| 104 const GrStencilSettings&, | 104 const GrStencilSettings&, |
| 105 const PipelineInfo&) override; | 105 const PipelineInfo&) override; |
| 106 void onClear(const SkIRect* rect, | 106 void onClear(const SkIRect* rect, |
| 107 GrColor color, | 107 GrColor color, |
| 108 bool canIgnoreRect, | 108 bool canIgnoreRect, |
| 109 GrRenderTarget* renderTarget) override; | 109 GrRenderTarget* renderTarget) override; |
| 110 bool onCopySurface(GrSurface* dst, | 110 void onCopySurface(GrSurface* dst, |
| 111 GrSurface* src, | 111 GrSurface* src, |
| 112 const SkIRect& srcRect, | 112 const SkIRect& srcRect, |
| 113 const SkIPoint& dstPoint) override; | 113 const SkIPoint& dstPoint) override; |
| 114 | 114 |
| 115 // We lazily record clip changes in order to skip clips that have no effect. | 115 // We lazily record clip changes in order to skip clips that have no effect. |
| 116 void recordClipIfNecessary(); | 116 void recordClipIfNecessary(); |
| 117 // Records any trace markers for a command | 117 // Records any trace markers for a command |
| 118 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); | 118 void recordTraceMarkersIfNecessary(GrTargetCommands::Cmd*); |
| 119 SkString getCmdString(int index) const { | 119 SkString getCmdString(int index) const { |
| 120 SkASSERT(index < fGpuCmdMarkers.count()); | 120 SkASSERT(index < fGpuCmdMarkers.count()); |
| 121 return fGpuCmdMarkers[index].toString(); | 121 return fGpuCmdMarkers[index].toString(); |
| 122 } | 122 } |
| 123 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } | 123 bool isIssued(uint32_t drawID) override { return drawID != fDrawID; } |
| 124 | 124 |
| 125 // TODO: Use a single allocator for commands and records | 125 // TODO: Use a single allocator for commands and records |
| 126 enum { | 126 enum { |
| 127 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 127 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
| 128 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 128 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 GrTargetCommands fCommands; | 131 GrTargetCommands fCommands; |
| 132 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 132 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
| 133 SkChunkAlloc fPathIndexBuffer; | 133 SkChunkAlloc fPathIndexBuffer; |
| 134 SkChunkAlloc fPathTransformBuffer; | 134 SkChunkAlloc fPathTransformBuffer; |
| 135 uint32_t fDrawID; | 135 uint32_t fDrawID; |
| 136 | 136 |
| 137 typedef GrFlushToGpuDrawTarget INHERITED; | 137 typedef GrClipTarget INHERITED; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 #endif | 140 #endif |
| OLD | NEW |