| 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 |
| 26 // batch blocker (when there is overlap) and the xp is responsible for issuing a
ny barrier calls |
| 27 // on the backend. |
| 25 class GrTargetCommands : ::SkNoncopyable { | 28 class GrTargetCommands : ::SkNoncopyable { |
| 26 public: | 29 public: |
| 27 GrTargetCommands(GrGpu* gpu) | 30 GrTargetCommands(GrGpu* gpu) |
| 28 : fCmdBuffer(kCmdBufferInitialSizeInBytes) | 31 : fCmdBuffer(kCmdBufferInitialSizeInBytes) |
| 29 , fBatchTarget(gpu) { | 32 , fBatchTarget(gpu) { |
| 30 } | 33 } |
| 31 | 34 |
| 32 class Cmd : ::SkNoncopyable { | 35 class Cmd : ::SkNoncopyable { |
| 33 public: | 36 public: |
| 34 enum CmdType { | 37 enum CmdType { |
| 35 kStencilPath_CmdType = 1, | 38 kStencilPath_CmdType = 1, |
| 36 kSetState_CmdType = 2, | 39 kClear_CmdType = 2, |
| 37 kClear_CmdType = 3, | 40 kClearStencil_CmdType = 3, |
| 38 kClearStencil_CmdType = 4, | 41 kCopySurface_CmdType = 4, |
| 39 kCopySurface_CmdType = 5, | 42 kDrawPath_CmdType = 5, |
| 40 kDrawPath_CmdType = 6, | 43 kDrawPaths_CmdType = 6, |
| 41 kDrawPaths_CmdType = 7, | 44 kDrawBatch_CmdType = 7, |
| 42 kDrawBatch_CmdType = 8, | 45 kXferBarrier_CmdType = 8, |
| 43 kXferBarrier_CmdType = 9, | |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 Cmd(CmdType type) | 48 Cmd(CmdType type) |
| 47 : fMarkerID(-1) | 49 : fMarkerID(-1) |
| 48 , fType(type) | 50 , fType(type) |
| 49 #if GR_BATCH_SPEW | 51 #if GR_BATCH_SPEW |
| 50 , fUniqueID(GenID(&gUniqueID)) | 52 , fUniqueID(GenID(&gUniqueID)) |
| 51 #endif | 53 #endif |
| 52 {} | 54 {} |
| 53 virtual ~Cmd() {} | 55 virtual ~Cmd() {} |
| (...skipping 29 matching lines...) Expand all Loading... |
| 83 private: | 85 private: |
| 84 friend class GrCommandBuilder; | 86 friend class GrCommandBuilder; |
| 85 friend class GrBufferedDrawTarget; // This goes away when State becomes just
a pipeline | 87 friend class GrBufferedDrawTarget; // This goes away when State becomes just
a pipeline |
| 86 friend class GrReorderCommandBuilder; | 88 friend class GrReorderCommandBuilder; |
| 87 | 89 |
| 88 typedef GrGpu::DrawArgs DrawArgs; | 90 typedef GrGpu::DrawArgs DrawArgs; |
| 89 | 91 |
| 90 void recordXferBarrierIfNecessary(const GrPipeline&, GrBufferedDrawTarget*); | 92 void recordXferBarrierIfNecessary(const GrPipeline&, GrBufferedDrawTarget*); |
| 91 | 93 |
| 92 // TODO: This can be just a pipeline once paths are in batch, and it should
live elsewhere | 94 // TODO: This can be just a pipeline once paths are in batch, and it should
live elsewhere |
| 93 struct State : public SkNVRefCnt<State> { | 95 struct StateForPathDraw : public SkNVRefCnt<StateForPathDraw> { |
| 94 // TODO get rid of the prim proc parameter when we use batch everywhere | 96 // TODO get rid of the prim proc parameter when we use batch everywhere |
| 95 State(const GrPrimitiveProcessor* primProc = NULL) | 97 StateForPathDraw(const GrPrimitiveProcessor* primProc = NULL) |
| 96 : fPrimitiveProcessor(primProc) | 98 : fPrimitiveProcessor(primProc) |
| 97 , fCompiled(false) {} | 99 , fCompiled(false) {} |
| 98 | 100 |
| 99 ~State() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipeline()
; } | 101 ~StateForPathDraw() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~G
rPipeline(); } |
| 100 | 102 |
| 101 // This function is only for getting the location in memory where we wil
l create our | 103 // This function is only for getting the location in memory where we wil
l create our |
| 102 // pipeline object. | 104 // pipeline object. |
| 103 void* pipelineLocation() { return fPipeline.get(); } | 105 void* pipelineLocation() { return fPipeline.get(); } |
| 104 | 106 |
| 105 const GrPipeline* getPipeline() const { | 107 const GrPipeline* getPipeline() const { |
| 106 return reinterpret_cast<const GrPipeline*>(fPipeline.get()); | 108 return reinterpret_cast<const GrPipeline*>(fPipeline.get()); |
| 107 } | 109 } |
| 108 GrRenderTarget* getRenderTarget() const { | 110 GrRenderTarget* getRenderTarget() const { |
| 109 return this->getPipeline()->getRenderTarget(); | 111 return this->getPipeline()->getRenderTarget(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 124 } | 126 } |
| 125 | 127 |
| 126 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
tiveProcessor; | 128 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
tiveProcessor; |
| 127 ProgramPrimitiveProcessor fPrimitiveProcessor; | 129 ProgramPrimitiveProcessor fPrimitiveProcessor; |
| 128 SkAlignedSStorage<sizeof(GrPipeline)> fPipeline; | 130 SkAlignedSStorage<sizeof(GrPipeline)> fPipeline; |
| 129 GrProgramDesc fDesc; | 131 GrProgramDesc fDesc; |
| 130 GrBatchTracker fBatchTracker; | 132 GrBatchTracker fBatchTracker; |
| 131 bool fCompiled; | 133 bool fCompiled; |
| 132 }; | 134 }; |
| 133 // TODO remove this when State is just a pipeline | 135 // TODO remove this when State is just a pipeline |
| 134 friend SkNVRefCnt<State>; | 136 friend SkNVRefCnt<StateForPathDraw>; |
| 135 | 137 |
| 136 struct StencilPath : public Cmd { | 138 struct StencilPath : public Cmd { |
| 137 StencilPath(const GrPath* path, GrRenderTarget* rt) | 139 StencilPath(const GrPath* path, GrRenderTarget* rt) |
| 138 : Cmd(kStencilPath_CmdType) | 140 : Cmd(kStencilPath_CmdType) |
| 139 , fRenderTarget(rt) | 141 , fRenderTarget(rt) |
| 140 , fPath(path) {} | 142 , fPath(path) {} |
| 141 | 143 |
| 142 const GrPath* path() const { return fPath.get(); } | 144 const GrPath* path() const { return fPath.get(); } |
| 143 | 145 |
| 144 void execute(GrGpu*) override; | 146 void execute(GrGpu*) override; |
| 145 | 147 |
| 146 SkMatrix fViewMatrix; | 148 SkMatrix fViewMatrix; |
| 147 bool fUseHWAA; | 149 bool fUseHWAA; |
| 148 GrStencilSettings fStencil; | 150 GrStencilSettings fStencil; |
| 149 GrScissorState fScissor; | 151 GrScissorState fScissor; |
| 150 private: | 152 private: |
| 151 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 153 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 152 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 154 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 153 }; | 155 }; |
| 154 | 156 |
| 155 struct DrawPath : public Cmd { | 157 struct DrawPath : public Cmd { |
| 156 DrawPath(State* state, const GrPath* path) | 158 DrawPath(StateForPathDraw* state, const GrPath* path) |
| 157 : Cmd(kDrawPath_CmdType) | 159 : Cmd(kDrawPath_CmdType) |
| 158 , fState(SkRef(state)) | 160 , fState(SkRef(state)) |
| 159 , fPath(path) {} | 161 , fPath(path) {} |
| 160 | 162 |
| 161 const GrPath* path() const { return fPath.get(); } | 163 const GrPath* path() const { return fPath.get(); } |
| 162 | 164 |
| 163 void execute(GrGpu*) override; | 165 void execute(GrGpu*) override; |
| 164 | 166 |
| 165 SkAutoTUnref<State> fState; | 167 SkAutoTUnref<StateForPathDraw> fState; |
| 166 GrStencilSettings fStencilSettings; | 168 GrStencilSettings fStencilSettings; |
| 167 private: | 169 private: |
| 168 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 170 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 169 }; | 171 }; |
| 170 | 172 |
| 171 struct DrawPaths : public Cmd { | 173 struct DrawPaths : public Cmd { |
| 172 DrawPaths(State* state, const GrPathRange* pathRange) | 174 DrawPaths(StateForPathDraw* state, const GrPathRange* pathRange) |
| 173 : Cmd(kDrawPaths_CmdType) | 175 : Cmd(kDrawPaths_CmdType) |
| 174 , fState(SkRef(state)) | 176 , fState(SkRef(state)) |
| 175 , fPathRange(pathRange) {} | 177 , fPathRange(pathRange) {} |
| 176 | 178 |
| 177 const GrPathRange* pathRange() const { return fPathRange.get(); } | 179 const GrPathRange* pathRange() const { return fPathRange.get(); } |
| 178 | 180 |
| 179 void execute(GrGpu*) override; | 181 void execute(GrGpu*) override; |
| 180 | 182 |
| 181 SkAutoTUnref<State> fState; | 183 SkAutoTUnref<StateForPathDraw> fState; |
| 182 char* fIndices; | 184 char* fIndices; |
| 183 GrDrawTarget::PathIndexType fIndexType; | 185 GrDrawTarget::PathIndexType fIndexType; |
| 184 float* fTransforms; | 186 float* fTransforms; |
| 185 GrDrawTarget::PathTransformType fTransformType; | 187 GrDrawTarget::PathTransformType fTransformType; |
| 186 int fCount; | 188 int fCount; |
| 187 GrStencilSettings fStencilSettings; | 189 GrStencilSettings fStencilSettings; |
| 188 | 190 |
| 189 private: | 191 private: |
| 190 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; | 192 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; |
| 191 }; | 193 }; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 236 |
| 235 SkIPoint fDstPoint; | 237 SkIPoint fDstPoint; |
| 236 SkIRect fSrcRect; | 238 SkIRect fSrcRect; |
| 237 | 239 |
| 238 private: | 240 private: |
| 239 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 241 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
| 240 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 242 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
| 241 }; | 243 }; |
| 242 | 244 |
| 243 struct DrawBatch : public Cmd { | 245 struct DrawBatch : public Cmd { |
| 244 DrawBatch(const State* state, GrBatch* batch, GrBatchTarget* batchTarget
) | 246 DrawBatch(GrBatch* batch, GrBatchTarget* batchTarget) |
| 245 : Cmd(kDrawBatch_CmdType) | 247 : Cmd(kDrawBatch_CmdType) |
| 246 , fState(SkRef(state)) | |
| 247 , fBatch(SkRef(batch)) | 248 , fBatch(SkRef(batch)) |
| 248 , fBatchTarget(batchTarget) { | 249 , fBatchTarget(batchTarget) { |
| 249 SkASSERT(!batch->isUsed()); | 250 SkASSERT(!batch->isUsed()); |
| 250 } | 251 } |
| 251 | 252 |
| 253 GrBatch* batch() { return fBatch; } |
| 252 void execute(GrGpu*) override; | 254 void execute(GrGpu*) override; |
| 253 | |
| 254 SkAutoTUnref<const State> fState; | |
| 255 SkAutoTUnref<GrBatch> fBatch; | |
| 256 | |
| 257 private: | 255 private: |
| 256 SkAutoTUnref<GrBatch> fBatch; |
| 258 GrBatchTarget* fBatchTarget; | 257 GrBatchTarget* fBatchTarget; |
| 259 }; | 258 }; |
| 260 | 259 |
| 261 struct XferBarrier : public Cmd { | 260 struct XferBarrier : public Cmd { |
| 262 XferBarrier(GrRenderTarget* rt) | 261 XferBarrier(GrRenderTarget* rt) |
| 263 : Cmd(kXferBarrier_CmdType) | 262 : Cmd(kXferBarrier_CmdType) |
| 264 , fRenderTarget(rt) { | 263 , fRenderTarget(rt) { |
| 265 } | 264 } |
| 266 | 265 |
| 267 void execute(GrGpu*) override; | 266 void execute(GrGpu*) override; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 279 | 278 |
| 280 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } | 279 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } |
| 281 GrBatchTarget* batchTarget() { return &fBatchTarget; } | 280 GrBatchTarget* batchTarget() { return &fBatchTarget; } |
| 282 | 281 |
| 283 CmdBuffer fCmdBuffer; | 282 CmdBuffer fCmdBuffer; |
| 284 GrBatchTarget fBatchTarget; | 283 GrBatchTarget fBatchTarget; |
| 285 }; | 284 }; |
| 286 | 285 |
| 287 #endif | 286 #endif |
| 288 | 287 |
| OLD | NEW |