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 GrTargetCommands_DEFINED | 8 #ifndef GrTargetCommands_DEFINED |
9 #define GrTargetCommands_DEFINED | 9 #define GrTargetCommands_DEFINED |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 class GrTargetCommands : ::SkNoncopyable { | 26 class GrTargetCommands : ::SkNoncopyable { |
27 struct SetState; | 27 struct SetState; |
28 | 28 |
29 public: | 29 public: |
30 GrTargetCommands(GrGpu* gpu, | 30 GrTargetCommands(GrGpu* gpu, |
31 GrVertexBufferAllocPool* vertexPool, | 31 GrVertexBufferAllocPool* vertexPool, |
32 GrIndexBufferAllocPool* indexPool) | 32 GrIndexBufferAllocPool* indexPool) |
33 : fCmdBuffer(kCmdBufferInitialSizeInBytes) | 33 : fCmdBuffer(kCmdBufferInitialSizeInBytes) |
34 , fPrevState(NULL) | 34 , fPrevState(NULL) |
35 , fBatchTarget(gpu, vertexPool, indexPool) | 35 , fBatchTarget(gpu, vertexPool, indexPool) |
36 , fDrawBatch(NULL) { | 36 , fDrawBatch(NULL) |
| 37 , fXferBarrier(NULL) { |
37 } | 38 } |
38 | 39 |
39 class Cmd : ::SkNoncopyable { | 40 class Cmd : ::SkNoncopyable { |
40 public: | 41 public: |
41 enum CmdType { | 42 enum CmdType { |
42 kDraw_CmdType = 1, | 43 kDraw_CmdType = 1, |
43 kStencilPath_CmdType = 2, | 44 kStencilPath_CmdType = 2, |
44 kSetState_CmdType = 3, | 45 kSetState_CmdType = 3, |
45 kClear_CmdType = 4, | 46 kClear_CmdType = 4, |
46 kCopySurface_CmdType = 5, | 47 kCopySurface_CmdType = 5, |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 void execute(GrGpu*, const SetState*) override; | 299 void execute(GrGpu*, const SetState*) override; |
299 | 300 |
300 // TODO it wouldn't be too hard to let batches allocate in the cmd buffe
r | 301 // TODO it wouldn't be too hard to let batches allocate in the cmd buffe
r |
301 SkAutoTUnref<GrBatch> fBatch; | 302 SkAutoTUnref<GrBatch> fBatch; |
302 | 303 |
303 private: | 304 private: |
304 GrBatchTarget* fBatchTarget; | 305 GrBatchTarget* fBatchTarget; |
305 }; | 306 }; |
306 | 307 |
307 struct XferBarrier : public Cmd { | 308 struct XferBarrier : public Cmd { |
308 XferBarrier(GrXferBarrierType type) | 309 XferBarrier(GrXferBarrierType type, GrRenderTarget* rt) |
309 : Cmd(kXferBarrier_CmdType) | 310 : Cmd(kXferBarrier_CmdType) |
310 , fType(type) {} | 311 , fType(type) |
| 312 , fRenderTarget(rt) {} |
311 | 313 |
312 void execute(GrGpu*, const SetState*) override; | 314 void execute(GrGpu*, const SetState*) override; |
313 | 315 |
314 const GrXferBarrierType fType; | 316 const GrXferBarrierType fType; |
315 SkIRect fBounds; | 317 SkIRect fReadBounds; |
| 318 SkIRect fInvalidBounds; |
| 319 |
| 320 // The cmd buffer keeps these ptrs alive. |
| 321 GrRenderTarget* const fRenderTarget; |
| 322 SkSTArray<4, const GrXferProcessor*, true> fXferProcessors; |
316 }; | 323 }; |
317 | 324 |
318 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | 325 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; |
319 | 326 |
320 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 327 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
321 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 328 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
322 | 329 |
323 CmdBuffer fCmdBuffer; | 330 CmdBuffer fCmdBuffer; |
324 SetState* fPrevState; | 331 SetState* fPrevState; |
325 GrBatchTarget fBatchTarget; | 332 GrBatchTarget fBatchTarget; |
326 // TODO hack until batch is everywhere | 333 // TODO hack until batch is everywhere |
327 GrTargetCommands::DrawBatch* fDrawBatch; | 334 GrTargetCommands::DrawBatch* fDrawBatch; |
| 335 XferBarrier* fXferBarrier; |
328 | 336 |
329 // This will go away when everything uses batch. However, in the short ter
m anything which | 337 // This will go away when everything uses batch. However, in the short ter
m anything which |
330 // might be put into the GrInOrderDrawBuffer needs to make sure it closes t
he last batch | 338 // might be put into the GrInOrderDrawBuffer needs to make sure it closes t
he last batch |
331 void closeBatch(); | 339 void closeBatch(); |
332 }; | 340 }; |
333 | 341 |
334 #endif | 342 #endif |
335 | 343 |
OLD | NEW |