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 "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
12 #include "GrTargetCommands.h" | 12 #include "GrCommandBuilder.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 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 if (0 != xformBytes) { | 65 if (0 != xformBytes) { |
66 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, | 66 *xformsLocation = (float*) fPathTransformBuffer.alloc(count * xformB
ytes, |
67 SkChunkAlloc::kTh
row_AllocFailType); | 67 SkChunkAlloc::kTh
row_AllocFailType); |
68 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); | 68 SkASSERT(SkIsAlign4((uintptr_t)*xformsLocation)); |
69 memcpy(*xformsLocation, transformValues, count * xformBytes); | 69 memcpy(*xformsLocation, transformValues, count * xformBytes); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
| 74 friend class GrCommandBuilder; |
74 friend class GrTargetCommands; | 75 friend class GrTargetCommands; |
75 typedef GrTargetCommands::State State; | 76 typedef GrTargetCommands::State State; |
76 | 77 |
77 State* allocState(const GrPrimitiveProcessor* primProc = NULL) { | 78 State* allocState(const GrPrimitiveProcessor* primProc = NULL) { |
78 void* allocation = fPipelineBuffer.alloc(sizeof(State), SkChunkAlloc::kT
hrow_AllocFailType); | 79 void* allocation = fPipelineBuffer.alloc(sizeof(State), SkChunkAlloc::kT
hrow_AllocFailType); |
79 return SkNEW_PLACEMENT_ARGS(allocation, State, (primProc)); | 80 return SkNEW_PLACEMENT_ARGS(allocation, State, (primProc)); |
80 } | 81 } |
81 | 82 |
82 void unallocState(State* state) { | 83 void unallocState(State* state) { |
83 state->unref(); | 84 state->unref(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 enum { | 142 enum { |
142 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 143 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
143 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 144 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
144 kPipelineBufferMinReserve = 32 * sizeof(State), | 145 kPipelineBufferMinReserve = 32 * sizeof(State), |
145 }; | 146 }; |
146 | 147 |
147 // every 100 flushes we should reset our fPipelineBuffer to prevent us from
holding at a | 148 // every 100 flushes we should reset our fPipelineBuffer to prevent us from
holding at a |
148 // highwater mark | 149 // highwater mark |
149 static const int kPipelineBufferHighWaterMark = 100; | 150 static const int kPipelineBufferHighWaterMark = 100; |
150 | 151 |
151 GrTargetCommands fCommands; | 152 SkAutoTDelete<GrCommandBuilder> fCommands; |
152 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 153 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
153 SkChunkAlloc fPathIndexBuffer; | 154 SkChunkAlloc fPathIndexBuffer; |
154 SkChunkAlloc fPathTransformBuffer; | 155 SkChunkAlloc fPathTransformBuffer; |
155 SkChunkAlloc fPipelineBuffer; | 156 SkChunkAlloc fPipelineBuffer; |
156 uint32_t fDrawID; | 157 uint32_t fDrawID; |
157 SkAutoTUnref<State> fPrevState; | 158 SkAutoTUnref<State> fPrevState; |
158 | 159 |
159 typedef GrClipTarget INHERITED; | 160 typedef GrClipTarget INHERITED; |
160 }; | 161 }; |
161 | 162 |
162 #endif | 163 #endif |
OLD | NEW |