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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 SkIRect fSrcRect; | 174 SkIRect fSrcRect; |
175 | 175 |
176 private: | 176 private: |
177 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 177 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
178 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 178 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
179 }; | 179 }; |
180 | 180 |
181 struct SetState : public Cmd { | 181 struct SetState : public Cmd { |
182 SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primP
roc, | 182 SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primP
roc, |
183 const GrDrawTargetCaps& caps, | 183 const GrDrawTargetCaps& caps, |
184 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC
opy, | 184 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC
opy) |
185 GrGpu::DrawType drawType) | |
186 : Cmd(kSetState_Cmd) | 185 : Cmd(kSetState_Cmd) |
187 , fPrimitiveProcessor(primProc) | 186 , fPrimitiveProcessor(primProc) |
188 , fState(drawState, primProc, caps, scissor, dstCopy) | 187 , fState(drawState, primProc, caps, scissor, dstCopy) {} |
189 , fDrawType(drawType) {} | |
190 | 188 |
191 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; | 189 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
192 | 190 |
193 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
tiveProcessor; | 191 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
tiveProcessor; |
194 ProgramPrimitiveProcessor fPrimitiveProcessor; | 192 ProgramPrimitiveProcessor fPrimitiveProcessor; |
195 const GrOptDrawState fState; | 193 const GrOptDrawState fState; |
196 GrProgramDesc fDesc; | 194 GrProgramDesc fDesc; |
197 GrBatchTracker fBatchTracker; | 195 GrBatchTracker fBatchTracker; |
198 GrGpu::DrawType fDrawType; | |
199 }; | 196 }; |
200 | 197 |
201 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 198 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
202 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 199 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
203 | 200 |
204 void onReset() SK_OVERRIDE; | 201 void onReset() SK_OVERRIDE; |
205 void onFlush() SK_OVERRIDE; | 202 void onFlush() SK_OVERRIDE; |
206 | 203 |
207 // overrides from GrDrawTarget | 204 // overrides from GrDrawTarget |
208 void onDraw(const GrDrawState&, | 205 void onDraw(const GrDrawState&, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 247 |
251 // Attempts to concat instances from info onto the previous draw. info must
represent an | 248 // Attempts to concat instances from info onto the previous draw. info must
represent an |
252 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. | 249 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. |
253 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); | 250 int concatInstancedDraw(const GrDrawState&, const DrawInfo&); |
254 | 251 |
255 // Determines whether the current draw operation requires a new GrOptDrawSta
te and if so | 252 // Determines whether the current draw operation requires a new GrOptDrawSta
te and if so |
256 // records it. If the draw can be skipped false is returned and no new GrOpt
DrawState is | 253 // records it. If the draw can be skipped false is returned and no new GrOpt
DrawState is |
257 // recorded. | 254 // recorded. |
258 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, | 255 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, |
259 const GrPrimitiveProcess
or*, | 256 const GrPrimitiveProcess
or*, |
260 GrGpu::DrawType, | |
261 const GrScissorState&, | 257 const GrScissorState&, |
262 const GrDeviceCoordTextu
re*); | 258 const GrDeviceCoordTextu
re*); |
263 // We lazily record clip changes in order to skip clips that have no effect. | 259 // We lazily record clip changes in order to skip clips that have no effect. |
264 void recordClipIfNecessary(); | 260 void recordClipIfNecessary(); |
265 // Records any trace markers for a command after adding it to the buffer. | 261 // Records any trace markers for a command after adding it to the buffer. |
266 void recordTraceMarkersIfNecessary(); | 262 void recordTraceMarkersIfNecessary(); |
267 | 263 |
268 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } | 264 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } |
269 | 265 |
270 // TODO: Use a single allocator for commands and records | 266 // TODO: Use a single allocator for commands and records |
271 enum { | 267 enum { |
272 kCmdBufferInitialSizeInBytes = 8 * 1024, | 268 kCmdBufferInitialSizeInBytes = 8 * 1024, |
273 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's | 269 kPathIdxBufferMinReserve = 2 * 64, // 64 uint16_t's |
274 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms | 270 kPathXformBufferMinReserve = 2 * 64, // 64 two-float transforms |
275 }; | 271 }; |
276 | 272 |
277 CmdBuffer fCmdBuffer; | 273 CmdBuffer fCmdBuffer; |
278 SetState* fPrevState; | 274 SetState* fPrevState; |
279 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; | 275 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; |
280 SkTDArray<char> fPathIndexBuffer; | 276 SkTDArray<char> fPathIndexBuffer; |
281 SkTDArray<float> fPathTransformBuffer; | 277 SkTDArray<float> fPathTransformBuffer; |
282 uint32_t fDrawID; | 278 uint32_t fDrawID; |
283 | 279 |
284 typedef GrFlushToGpuDrawTarget INHERITED; | 280 typedef GrFlushToGpuDrawTarget INHERITED; |
285 }; | 281 }; |
286 | 282 |
287 #endif | 283 #endif |
OLD | NEW |