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 |
11 #include "GrBatchTarget.h" | 11 #include "GrBatchTarget.h" |
12 #include "GrDrawTarget.h" | 12 #include "GrDrawTarget.h" |
13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
14 #include "GrPath.h" | 14 #include "GrPath.h" |
15 #include "GrPendingProgramElement.h" | 15 #include "GrPendingProgramElement.h" |
16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
17 #include "GrTRecorder.h" | 17 #include "GrTRecorder.h" |
18 #include "SkRect.h" | 18 #include "SkRect.h" |
19 #include "SkTypes.h" | 19 #include "SkTypes.h" |
20 | 20 |
21 #include "batches/GrBatch.h" | 21 #include "batches/GrBatch.h" |
22 | 22 |
23 class GrBufferedDrawTarget; | 23 class GrBufferedDrawTarget; |
24 | 24 |
25 // TODO: Convert all commands into GrBatch and remove this class. Xferbarrier wi
ll just become a | 25 // TODO: Convert all commands into GrBatch and remove this class. |
26 // batch blocker (when there is overlap) and the xp is responsible for issuing a
ny barrier calls | |
27 // on the backend. | |
28 class GrTargetCommands : ::SkNoncopyable { | 26 class GrTargetCommands : ::SkNoncopyable { |
29 public: | 27 public: |
30 GrTargetCommands(GrGpu* gpu) | 28 GrTargetCommands(GrGpu* gpu) |
31 : fCmdBuffer(kCmdBufferInitialSizeInBytes) | 29 : fCmdBuffer(kCmdBufferInitialSizeInBytes) |
32 , fBatchTarget(gpu) { | 30 , fBatchTarget(gpu) { |
33 } | 31 } |
34 | 32 |
35 class Cmd : ::SkNoncopyable { | 33 class Cmd : ::SkNoncopyable { |
36 public: | 34 public: |
37 enum CmdType { | 35 enum CmdType { |
38 kStencilPath_CmdType = 1, | 36 kStencilPath_CmdType = 1, |
39 kClear_CmdType = 2, | 37 kClear_CmdType = 2, |
40 kClearStencil_CmdType = 3, | 38 kClearStencil_CmdType = 3, |
41 kCopySurface_CmdType = 4, | 39 kCopySurface_CmdType = 4, |
42 kDrawPath_CmdType = 5, | 40 kDrawPath_CmdType = 5, |
43 kDrawPaths_CmdType = 6, | 41 kDrawPaths_CmdType = 6, |
44 kDrawBatch_CmdType = 7, | 42 kDrawBatch_CmdType = 7, |
45 kXferBarrier_CmdType = 8, | |
46 }; | 43 }; |
47 | 44 |
48 Cmd(CmdType type) | 45 Cmd(CmdType type) |
49 : fType(type) | 46 : fType(type) |
50 #if GR_BATCH_SPEW | 47 #if GR_BATCH_SPEW |
51 , fUniqueID(GenID(&gUniqueID)) | 48 , fUniqueID(GenID(&gUniqueID)) |
52 #endif | 49 #endif |
53 {} | 50 {} |
54 virtual ~Cmd() {} | 51 virtual ~Cmd() {} |
55 | 52 |
(...skipping 20 matching lines...) Expand all Loading... |
76 void reset(); | 73 void reset(); |
77 void flush(GrBufferedDrawTarget*); | 74 void flush(GrBufferedDrawTarget*); |
78 | 75 |
79 private: | 76 private: |
80 friend class GrCommandBuilder; | 77 friend class GrCommandBuilder; |
81 friend class GrBufferedDrawTarget; // This goes away when State becomes just
a pipeline | 78 friend class GrBufferedDrawTarget; // This goes away when State becomes just
a pipeline |
82 friend class GrReorderCommandBuilder; | 79 friend class GrReorderCommandBuilder; |
83 | 80 |
84 typedef GrGpu::DrawArgs DrawArgs; | 81 typedef GrGpu::DrawArgs DrawArgs; |
85 | 82 |
86 void recordXferBarrierIfNecessary(const GrPipeline&, GrBufferedDrawTarget*); | |
87 | |
88 // TODO: This can be just a pipeline once paths are in batch, and it should
live elsewhere | 83 // TODO: This can be just a pipeline once paths are in batch, and it should
live elsewhere |
89 struct StateForPathDraw : public SkNVRefCnt<StateForPathDraw> { | 84 struct StateForPathDraw : public SkNVRefCnt<StateForPathDraw> { |
90 // TODO get rid of the prim proc parameter when we use batch everywhere | 85 // TODO get rid of the prim proc parameter when we use batch everywhere |
91 StateForPathDraw(const GrPrimitiveProcessor* primProc = NULL) | 86 StateForPathDraw(const GrPrimitiveProcessor* primProc = NULL) |
92 : fPrimitiveProcessor(primProc) | 87 : fPrimitiveProcessor(primProc) |
93 , fCompiled(false) {} | 88 , fCompiled(false) {} |
94 | 89 |
95 ~StateForPathDraw() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~G
rPipeline(); } | 90 ~StateForPathDraw() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~G
rPipeline(); } |
96 | 91 |
97 // This function is only for getting the location in memory where we wil
l create our | 92 // This function is only for getting the location in memory where we wil
l create our |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 SkASSERT(!batch->isUsed()); | 239 SkASSERT(!batch->isUsed()); |
245 } | 240 } |
246 | 241 |
247 GrBatch* batch() { return fBatch; } | 242 GrBatch* batch() { return fBatch; } |
248 void execute(GrGpu*) override; | 243 void execute(GrGpu*) override; |
249 private: | 244 private: |
250 SkAutoTUnref<GrBatch> fBatch; | 245 SkAutoTUnref<GrBatch> fBatch; |
251 GrBatchTarget* fBatchTarget; | 246 GrBatchTarget* fBatchTarget; |
252 }; | 247 }; |
253 | 248 |
254 struct XferBarrier : public Cmd { | |
255 XferBarrier(GrRenderTarget* rt) | |
256 : Cmd(kXferBarrier_CmdType) | |
257 , fRenderTarget(rt) { | |
258 } | |
259 | |
260 void execute(GrGpu*) override; | |
261 | |
262 GrXferBarrierType fBarrierType; | |
263 | |
264 private: | |
265 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | |
266 }; | |
267 | |
268 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | 249 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; |
269 | 250 |
270 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 251 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
271 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 252 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
272 | 253 |
273 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } | 254 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } |
274 GrBatchTarget* batchTarget() { return &fBatchTarget; } | 255 GrBatchTarget* batchTarget() { return &fBatchTarget; } |
275 | 256 |
276 CmdBuffer fCmdBuffer; | 257 CmdBuffer fCmdBuffer; |
277 GrBatchTarget fBatchTarget; | 258 GrBatchTarget fBatchTarget; |
278 }; | 259 }; |
279 | 260 |
280 #endif | 261 #endif |
281 | 262 |
OLD | NEW |