| 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 "GrBatch.h" | 11 #include "GrBatch.h" |
| 12 #include "GrBatchTarget.h" | 12 #include "GrBatchTarget.h" |
| 13 #include "GrDrawTarget.h" | 13 #include "GrDrawTarget.h" |
| 14 #include "GrGpu.h" | 14 #include "GrGpu.h" |
| 15 #include "GrPath.h" | 15 #include "GrPath.h" |
| 16 #include "GrPendingProgramElement.h" | 16 #include "GrPendingProgramElement.h" |
| 17 #include "GrRenderTarget.h" | 17 #include "GrRenderTarget.h" |
| 18 #include "GrTRecorder.h" | 18 #include "GrTRecorder.h" |
| 19 #include "SkRect.h" | 19 #include "SkRect.h" |
| 20 #include "SkTypes.h" | 20 #include "SkTypes.h" |
| 21 | 21 |
| 22 // This is just to get a flag | |
| 23 // TODO remove this when batch is everywhere | |
| 24 #include "GrTextContext.h" | |
| 25 #ifdef USE_BITMAP_TEXTBLOBS | |
| 26 #define CLOSE_BATCH | |
| 27 #else | |
| 28 #define CLOSE_BATCH this->closeBatch(); | |
| 29 #endif | |
| 30 | |
| 31 class GrInOrderDrawBuffer; | 22 class GrInOrderDrawBuffer; |
| 32 class GrVertexBufferAllocPool; | 23 class GrVertexBufferAllocPool; |
| 33 class GrIndexBufferAllocPool; | 24 class GrIndexBufferAllocPool; |
| 34 | 25 |
| 35 class GrTargetCommands : ::SkNoncopyable { | 26 class GrTargetCommands : ::SkNoncopyable { |
| 36 struct SetState; | 27 struct SetState; |
| 37 | 28 |
| 38 public: | 29 public: |
| 39 GrTargetCommands(GrGpu* gpu, | 30 GrTargetCommands(GrGpu* gpu, |
| 40 GrVertexBufferAllocPool* vertexPool, | 31 GrVertexBufferAllocPool* vertexPool, |
| 41 GrIndexBufferAllocPool* indexPool) | 32 GrIndexBufferAllocPool* indexPool) |
| 42 : fCmdBuffer(kCmdBufferInitialSizeInBytes) | 33 : fCmdBuffer(kCmdBufferInitialSizeInBytes) |
| 43 , fPrevState(NULL) | 34 , fPrevState(NULL) |
| 44 , fBatchTarget(gpu, vertexPool, indexPool) | 35 , fBatchTarget(gpu, vertexPool, indexPool) { |
| 45 , fDrawBatch(NULL) { | |
| 46 } | 36 } |
| 47 | 37 |
| 48 class Cmd : ::SkNoncopyable { | 38 class Cmd : ::SkNoncopyable { |
| 49 public: | 39 public: |
| 50 enum CmdType { | 40 enum CmdType { |
| 51 kDraw_CmdType = 1, | 41 kStencilPath_CmdType = 1, |
| 52 kStencilPath_CmdType = 2, | 42 kSetState_CmdType = 2, |
| 53 kSetState_CmdType = 3, | 43 kClear_CmdType = 3, |
| 54 kClear_CmdType = 4, | 44 kCopySurface_CmdType = 4, |
| 55 kCopySurface_CmdType = 5, | 45 kDrawPath_CmdType = 5, |
| 56 kDrawPath_CmdType = 6, | 46 kDrawPaths_CmdType = 6, |
| 57 kDrawPaths_CmdType = 7, | 47 kDrawBatch_CmdType = 7, |
| 58 kDrawBatch_CmdType = 8, | 48 kXferBarrier_CmdType = 8, |
| 59 kXferBarrier_CmdType = 9, | |
| 60 }; | 49 }; |
| 61 | 50 |
| 62 Cmd(CmdType type) : fMarkerID(-1), fType(type) {} | 51 Cmd(CmdType type) : fMarkerID(-1), fType(type) {} |
| 63 virtual ~Cmd() {} | 52 virtual ~Cmd() {} |
| 64 | 53 |
| 65 virtual void execute(GrGpu*, const SetState*) = 0; | 54 virtual void execute(GrGpu*, const SetState*) = 0; |
| 66 | 55 |
| 67 CmdType type() const { return fType; } | 56 CmdType type() const { return fType; } |
| 68 | 57 |
| 69 // trace markers | 58 // trace markers |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 136 |
| 148 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 137 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, |
| 149 const GrPrimitiveProce
ssor*, | 138 const GrPrimitiveProce
ssor*, |
| 150 const GrDrawTarget::Pi
pelineInfo&); | 139 const GrDrawTarget::Pi
pelineInfo&); |
| 151 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 140 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, |
| 152 GrBatch*, | 141 GrBatch*, |
| 153 const GrDrawTarget::Pi
pelineInfo&); | 142 const GrDrawTarget::Pi
pelineInfo&); |
| 154 | 143 |
| 155 void recordXferBarrierIfNecessary(GrInOrderDrawBuffer*, const GrDrawTarget::
PipelineInfo&); | 144 void recordXferBarrierIfNecessary(GrInOrderDrawBuffer*, const GrDrawTarget::
PipelineInfo&); |
| 156 | 145 |
| 157 struct Draw : public Cmd { | |
| 158 Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_CmdType), fInfo(inf
o) {} | |
| 159 | |
| 160 void execute(GrGpu*, const SetState*) override; | |
| 161 | |
| 162 GrDrawTarget::DrawInfo fInfo; | |
| 163 }; | |
| 164 | |
| 165 struct StencilPath : public Cmd { | 146 struct StencilPath : public Cmd { |
| 166 StencilPath(const GrPath* path, GrRenderTarget* rt) | 147 StencilPath(const GrPath* path, GrRenderTarget* rt) |
| 167 : Cmd(kStencilPath_CmdType) | 148 : Cmd(kStencilPath_CmdType) |
| 168 , fRenderTarget(rt) | 149 , fRenderTarget(rt) |
| 169 , fPath(path) {} | 150 , fPath(path) {} |
| 170 | 151 |
| 171 const GrPath* path() const { return fPath.get(); } | 152 const GrPath* path() const { return fPath.get(); } |
| 172 | 153 |
| 173 void execute(GrGpu*, const SetState*) override; | 154 void execute(GrGpu*, const SetState*) override; |
| 174 | 155 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 }; | 302 }; |
| 322 | 303 |
| 323 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | 304 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; |
| 324 | 305 |
| 325 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 306 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
| 326 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 307 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| 327 | 308 |
| 328 CmdBuffer fCmdBuffer; | 309 CmdBuffer fCmdBuffer; |
| 329 SetState* fPrevState; | 310 SetState* fPrevState; |
| 330 GrBatchTarget fBatchTarget; | 311 GrBatchTarget fBatchTarget; |
| 331 // TODO hack until batch is everywhere | |
| 332 GrTargetCommands::DrawBatch* fDrawBatch; | |
| 333 | |
| 334 // This will go away when everything uses batch. However, in the short ter
m anything which | |
| 335 // might be put into the GrInOrderDrawBuffer needs to make sure it closes t
he last batch | |
| 336 void closeBatch(); | |
| 337 }; | 312 }; |
| 338 | 313 |
| 339 #endif | 314 #endif |
| 340 | 315 |
| OLD | NEW |