| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 public: | 49 public: |
| 50 enum CmdType { | 50 enum CmdType { |
| 51 kDraw_CmdType = 1, | 51 kDraw_CmdType = 1, |
| 52 kStencilPath_CmdType = 2, | 52 kStencilPath_CmdType = 2, |
| 53 kSetState_CmdType = 3, | 53 kSetState_CmdType = 3, |
| 54 kClear_CmdType = 4, | 54 kClear_CmdType = 4, |
| 55 kCopySurface_CmdType = 5, | 55 kCopySurface_CmdType = 5, |
| 56 kDrawPath_CmdType = 6, | 56 kDrawPath_CmdType = 6, |
| 57 kDrawPaths_CmdType = 7, | 57 kDrawPaths_CmdType = 7, |
| 58 kDrawBatch_CmdType = 8, | 58 kDrawBatch_CmdType = 8, |
| 59 kXferBarrier_CmdType = 9, |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 Cmd(CmdType type) : fMarkerID(-1), fType(type) {} | 62 Cmd(CmdType type) : fMarkerID(-1), fType(type) {} |
| 62 virtual ~Cmd() {} | 63 virtual ~Cmd() {} |
| 63 | 64 |
| 64 virtual void execute(GrGpu*, const SetState*) = 0; | 65 virtual void execute(GrGpu*, const SetState*) = 0; |
| 65 | 66 |
| 66 CmdType type() const { return fType; } | 67 CmdType type() const { return fType; } |
| 67 | 68 |
| 68 // trace markers | 69 // trace markers |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. | 145 // instanced draw. The caller must have already recorded a new draw state an
d clip if necessary. |
| 145 int concatInstancedDraw(GrInOrderDrawBuffer*, const GrDrawTarget::DrawInfo&)
; | 146 int concatInstancedDraw(GrInOrderDrawBuffer*, const GrDrawTarget::DrawInfo&)
; |
| 146 | 147 |
| 147 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 148 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, |
| 148 const GrPrimitiveProce
ssor*, | 149 const GrPrimitiveProce
ssor*, |
| 149 const GrDrawTarget::Pi
pelineInfo&); | 150 const GrDrawTarget::Pi
pelineInfo&); |
| 150 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 151 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, |
| 151 GrBatch*, | 152 GrBatch*, |
| 152 const GrDrawTarget::Pi
pelineInfo&); | 153 const GrDrawTarget::Pi
pelineInfo&); |
| 153 | 154 |
| 155 void recordXferBarrierIfNecessary(GrInOrderDrawBuffer*, const GrDrawTarget::
PipelineInfo&); |
| 156 |
| 154 struct Draw : public Cmd { | 157 struct Draw : public Cmd { |
| 155 Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_CmdType), fInfo(inf
o) {} | 158 Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_CmdType), fInfo(inf
o) {} |
| 156 | 159 |
| 157 void execute(GrGpu*, const SetState*) override; | 160 void execute(GrGpu*, const SetState*) override; |
| 158 | 161 |
| 159 GrDrawTarget::DrawInfo fInfo; | 162 GrDrawTarget::DrawInfo fInfo; |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 struct StencilPath : public Cmd { | 165 struct StencilPath : public Cmd { |
| 163 StencilPath(const GrPath* path, GrRenderTarget* rt) | 166 StencilPath(const GrPath* path, GrRenderTarget* rt) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 272 |
| 270 ~SetState() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipelin
e(); } | 273 ~SetState() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipelin
e(); } |
| 271 | 274 |
| 272 // This function is only for getting the location in memory where we wil
l create our | 275 // This function is only for getting the location in memory where we wil
l create our |
| 273 // pipeline object. | 276 // pipeline object. |
| 274 GrPipeline* pipelineLocation() { return reinterpret_cast<GrPipeline*>(fP
ipeline.get()); } | 277 GrPipeline* pipelineLocation() { return reinterpret_cast<GrPipeline*>(fP
ipeline.get()); } |
| 275 | 278 |
| 276 const GrPipeline* getPipeline() const { | 279 const GrPipeline* getPipeline() const { |
| 277 return reinterpret_cast<const GrPipeline*>(fPipeline.get()); | 280 return reinterpret_cast<const GrPipeline*>(fPipeline.get()); |
| 278 } | 281 } |
| 282 GrRenderTarget* getRenderTarget() const { |
| 283 return this->getPipeline()->getRenderTarget(); |
| 284 } |
| 285 const GrXferProcessor* getXferProcessor() const { |
| 286 return this->getPipeline()->getXferProcessor(); |
| 287 } |
| 279 | 288 |
| 280 void execute(GrGpu*, const SetState*) override; | 289 void execute(GrGpu*, const SetState*) override; |
| 281 | 290 |
| 282 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
tiveProcessor; | 291 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
tiveProcessor; |
| 283 ProgramPrimitiveProcessor fPrimitiveProcessor; | 292 ProgramPrimitiveProcessor fPrimitiveProcessor; |
| 284 SkAlignedSStorage<sizeof(GrPipeline)> fPipeline; | 293 SkAlignedSStorage<sizeof(GrPipeline)> fPipeline; |
| 285 GrProgramDesc fDesc; | 294 GrProgramDesc fDesc; |
| 286 GrBatchTracker fBatchTracker; | 295 GrBatchTracker fBatchTracker; |
| 287 }; | 296 }; |
| 288 | 297 |
| 289 struct DrawBatch : public Cmd { | 298 struct DrawBatch : public Cmd { |
| 290 DrawBatch(GrBatch* batch, GrBatchTarget* batchTarget) | 299 DrawBatch(GrBatch* batch, GrBatchTarget* batchTarget) |
| 291 : Cmd(kDrawBatch_CmdType) | 300 : Cmd(kDrawBatch_CmdType) |
| 292 , fBatch(SkRef(batch)) | 301 , fBatch(SkRef(batch)) |
| 293 , fBatchTarget(batchTarget) { | 302 , fBatchTarget(batchTarget) { |
| 294 SkASSERT(!batch->isUsed()); | 303 SkASSERT(!batch->isUsed()); |
| 295 } | 304 } |
| 296 | 305 |
| 297 void execute(GrGpu*, const SetState*) override; | 306 void execute(GrGpu*, const SetState*) override; |
| 298 | 307 |
| 299 // TODO it wouldn't be too hard to let batches allocate in the cmd buffe
r | 308 // TODO it wouldn't be too hard to let batches allocate in the cmd buffe
r |
| 300 SkAutoTUnref<GrBatch> fBatch; | 309 SkAutoTUnref<GrBatch> fBatch; |
| 301 | 310 |
| 302 private: | 311 private: |
| 303 GrBatchTarget* fBatchTarget; | 312 GrBatchTarget* fBatchTarget; |
| 304 }; | 313 }; |
| 305 | 314 |
| 315 struct XferBarrier : public Cmd { |
| 316 XferBarrier() : Cmd(kXferBarrier_CmdType) {} |
| 317 |
| 318 void execute(GrGpu*, const SetState*) override; |
| 319 |
| 320 GrXferBarrierType fBarrierType; |
| 321 }; |
| 322 |
| 306 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | 323 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; |
| 307 | 324 |
| 308 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 325 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
| 309 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 326 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| 310 | 327 |
| 311 CmdBuffer fCmdBuffer; | 328 CmdBuffer fCmdBuffer; |
| 312 SetState* fPrevState; | 329 SetState* fPrevState; |
| 313 GrBatchTarget fBatchTarget; | 330 GrBatchTarget fBatchTarget; |
| 314 // TODO hack until batch is everywhere | 331 // TODO hack until batch is everywhere |
| 315 GrTargetCommands::DrawBatch* fDrawBatch; | 332 GrTargetCommands::DrawBatch* fDrawBatch; |
| 316 | 333 |
| 317 // This will go away when everything uses batch. However, in the short ter
m anything which | 334 // This will go away when everything uses batch. However, in the short ter
m anything which |
| 318 // might be put into the GrInOrderDrawBuffer needs to make sure it closes t
he last batch | 335 // might be put into the GrInOrderDrawBuffer needs to make sure it closes t
he last batch |
| 319 void closeBatch(); | 336 void closeBatch(); |
| 320 }; | 337 }; |
| 321 | 338 |
| 322 #endif | 339 #endif |
| 323 | 340 |
| OLD | NEW |