| 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 "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 12 #include "GrPath.h" | 12 #include "GrPath.h" |
| 13 #include "GrPendingProgramElement.h" | 13 #include "GrPendingProgramElement.h" |
| 14 #include "GrPrimitiveProcessor.h" | 14 #include "GrPrimitiveProcessor.h" |
| 15 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
| 16 #include "GrTRecorder.h" | 16 #include "GrTRecorder.h" |
| 17 | 17 |
| 18 #include "batches/GrDrawBatch.h" | 18 #include "batches/GrBatch.h" |
| 19 |
| 19 #include "SkRect.h" | 20 #include "SkRect.h" |
| 20 | 21 |
| 21 class GrResourceProvider; | 22 class GrResourceProvider; |
| 22 class GrBatchFlushState; | 23 class GrBatchFlushState; |
| 23 | 24 |
| 24 // TODO: Convert all commands into GrBatch and remove this class. | 25 // TODO: Convert all commands into GrBatch and remove this class. |
| 25 class GrTargetCommands : ::SkNoncopyable { | 26 class GrTargetCommands : ::SkNoncopyable { |
| 26 public: | 27 public: |
| 27 GrTargetCommands() : fCmdBuffer(kCmdBufferInitialSizeInBytes), fLastFlushTok
en(0) {} | 28 GrTargetCommands() : fCmdBuffer(kCmdBufferInitialSizeInBytes), fLastFlushTok
en(0) {} |
| 28 | 29 |
| 29 class Cmd : ::SkNoncopyable { | 30 class Cmd : ::SkNoncopyable { |
| 30 public: | 31 public: |
| 31 enum CmdType { | 32 enum CmdType { |
| 32 kStencilPath_CmdType = 1, | 33 kStencilPath_CmdType = 1, |
| 33 kClear_CmdType = 2, | 34 kClearStencil_CmdType = 2, |
| 34 kClearStencil_CmdType = 3, | 35 kCopySurface_CmdType = 3, |
| 35 kCopySurface_CmdType = 4, | 36 kDrawPath_CmdType = 4, |
| 36 kDrawPath_CmdType = 5, | 37 kDrawPaths_CmdType = 5, |
| 37 kDrawPaths_CmdType = 6, | 38 kDrawBatch_CmdType = 6, |
| 38 kDrawBatch_CmdType = 7, | |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 Cmd(CmdType type) | 41 Cmd(CmdType type) |
| 42 : fType(type) | 42 : fType(type) |
| 43 #if GR_BATCH_SPEW | 43 #if GR_BATCH_SPEW |
| 44 , fUniqueID(GenID(&gUniqueID)) | 44 , fUniqueID(GenID(&gUniqueID)) |
| 45 #endif | 45 #endif |
| 46 {} | 46 {} |
| 47 virtual ~Cmd() {} | 47 virtual ~Cmd() {} |
| 48 | 48 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 GrDrawTarget::PathIndexType fIndexType; | 170 GrDrawTarget::PathIndexType fIndexType; |
| 171 float* fTransforms; | 171 float* fTransforms; |
| 172 GrDrawTarget::PathTransformType fTransformType; | 172 GrDrawTarget::PathTransformType fTransformType; |
| 173 int fCount; | 173 int fCount; |
| 174 GrStencilSettings fStencilSettings; | 174 GrStencilSettings fStencilSettings; |
| 175 | 175 |
| 176 private: | 176 private: |
| 177 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; | 177 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 // This is also used to record a discard by setting the color to GrColor_ILL
EGAL | |
| 181 struct Clear : public Cmd { | |
| 182 Clear(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarget(rt) {} | |
| 183 | |
| 184 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | |
| 185 | |
| 186 void execute(GrBatchFlushState*) override; | |
| 187 | |
| 188 SkIRect fRect; | |
| 189 GrColor fColor; | |
| 190 | |
| 191 private: | |
| 192 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | |
| 193 }; | |
| 194 | |
| 195 // This command is ONLY used by the clip mask manager to clear the stencil c
lip bits | 180 // This command is ONLY used by the clip mask manager to clear the stencil c
lip bits |
| 196 struct ClearStencilClip : public Cmd { | 181 struct ClearStencilClip : public Cmd { |
| 197 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClearStencil_CmdType), fRend
erTarget(rt) {} | 182 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClearStencil_CmdType), fRend
erTarget(rt) {} |
| 198 | 183 |
| 199 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 184 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } |
| 200 | 185 |
| 201 void execute(GrBatchFlushState*) override; | 186 void execute(GrBatchFlushState*) override; |
| 202 | 187 |
| 203 SkIRect fRect; | 188 SkIRect fRect; |
| 204 bool fInsideClip; | 189 bool fInsideClip; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 221 | 206 |
| 222 SkIPoint fDstPoint; | 207 SkIPoint fDstPoint; |
| 223 SkIRect fSrcRect; | 208 SkIRect fSrcRect; |
| 224 | 209 |
| 225 private: | 210 private: |
| 226 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 211 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
| 227 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 212 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
| 228 }; | 213 }; |
| 229 | 214 |
| 230 struct DrawBatch : public Cmd { | 215 struct DrawBatch : public Cmd { |
| 231 DrawBatch(GrDrawBatch* batch) | 216 DrawBatch(GrBatch* batch) |
| 232 : Cmd(kDrawBatch_CmdType) | 217 : Cmd(kDrawBatch_CmdType) |
| 233 , fBatch(SkRef(batch)){ | 218 , fBatch(SkRef(batch)){ |
| 234 SkASSERT(!batch->isUsed()); | 219 SkASSERT(!batch->isUsed()); |
| 235 } | 220 } |
| 236 | 221 |
| 237 GrDrawBatch* batch() { return fBatch; } | 222 GrBatch* batch() { return fBatch; } |
| 238 void execute(GrBatchFlushState*) override; | 223 void execute(GrBatchFlushState*) override; |
| 239 | 224 |
| 240 private: | 225 private: |
| 241 SkAutoTUnref<GrDrawBatch> fBatch; | 226 SkAutoTUnref<GrBatch> fBatch; |
| 242 }; | 227 }; |
| 243 | 228 |
| 244 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | 229 static const int kCmdBufferInitialSizeInBytes = 8 * 1024; |
| 245 | 230 |
| 246 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. | 231 typedef void* TCmdAlign; // This wouldn't be enough align if a command used
long double. |
| 247 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 232 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| 248 | 233 |
| 249 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } | 234 CmdBuffer* cmdBuffer() { return &fCmdBuffer; } |
| 250 | 235 |
| 251 CmdBuffer fCmdBuffer; | 236 CmdBuffer fCmdBuffer; |
| 252 GrBatchToken fLastFlushToken; | 237 GrBatchToken fLastFlushToken; |
| 253 }; | 238 }; |
| 254 | 239 |
| 255 #endif | 240 #endif |
| OLD | NEW |