| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 139     bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 139     bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 
| 140                                                           const GrPrimitiveProce
     ssor*, | 140                                                           const GrPrimitiveProce
     ssor*, | 
| 141                                                           const GrDrawTarget::Pi
     pelineInfo&); | 141                                                           const GrDrawTarget::Pi
     pelineInfo&); | 
| 142     bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 142     bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrInOrderDrawBuffer*, | 
| 143                                                           GrBatch*, | 143                                                           GrBatch*, | 
| 144                                                           const GrDrawTarget::Pi
     pelineInfo&); | 144                                                           const GrDrawTarget::Pi
     pelineInfo&); | 
| 145 | 145 | 
| 146     struct Draw : public Cmd { | 146     struct Draw : public Cmd { | 
| 147         Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_CmdType), fInfo(inf
     o) {} | 147         Draw(const GrDrawTarget::DrawInfo& info) : Cmd(kDraw_CmdType), fInfo(inf
     o) {} | 
| 148 | 148 | 
| 149         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 149         void execute(GrGpu*, const SetState*) override; | 
| 150 | 150 | 
| 151         GrDrawTarget::DrawInfo     fInfo; | 151         GrDrawTarget::DrawInfo     fInfo; | 
| 152     }; | 152     }; | 
| 153 | 153 | 
| 154     struct StencilPath : public Cmd { | 154     struct StencilPath : public Cmd { | 
| 155         StencilPath(const GrPath* path, GrRenderTarget* rt) | 155         StencilPath(const GrPath* path, GrRenderTarget* rt) | 
| 156             : Cmd(kStencilPath_CmdType) | 156             : Cmd(kStencilPath_CmdType) | 
| 157             , fRenderTarget(rt) | 157             , fRenderTarget(rt) | 
| 158             , fPath(path) {} | 158             , fPath(path) {} | 
| 159 | 159 | 
| 160         const GrPath* path() const { return fPath.get(); } | 160         const GrPath* path() const { return fPath.get(); } | 
| 161 | 161 | 
| 162         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 162         void execute(GrGpu*, const SetState*) override; | 
| 163 | 163 | 
| 164         SkMatrix                                                fViewMatrix; | 164         SkMatrix                                                fViewMatrix; | 
| 165         bool                                                    fUseHWAA; | 165         bool                                                    fUseHWAA; | 
| 166         GrStencilSettings                                       fStencil; | 166         GrStencilSettings                                       fStencil; | 
| 167         GrScissorState                                          fScissor; | 167         GrScissorState                                          fScissor; | 
| 168     private: | 168     private: | 
| 169         GrPendingIOResource<GrRenderTarget, kWrite_GrIOType>    fRenderTarget; | 169         GrPendingIOResource<GrRenderTarget, kWrite_GrIOType>    fRenderTarget; | 
| 170         GrPendingIOResource<const GrPath, kRead_GrIOType>       fPath; | 170         GrPendingIOResource<const GrPath, kRead_GrIOType>       fPath; | 
| 171     }; | 171     }; | 
| 172 | 172 | 
| 173     struct DrawPath : public Cmd { | 173     struct DrawPath : public Cmd { | 
| 174         DrawPath(const GrPath* path) : Cmd(kDrawPath_CmdType), fPath(path) {} | 174         DrawPath(const GrPath* path) : Cmd(kDrawPath_CmdType), fPath(path) {} | 
| 175 | 175 | 
| 176         const GrPath* path() const { return fPath.get(); } | 176         const GrPath* path() const { return fPath.get(); } | 
| 177 | 177 | 
| 178         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 178         void execute(GrGpu*, const SetState*) override; | 
| 179 | 179 | 
| 180         GrStencilSettings       fStencilSettings; | 180         GrStencilSettings       fStencilSettings; | 
| 181 | 181 | 
| 182     private: | 182     private: | 
| 183         GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 183         GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 
| 184     }; | 184     }; | 
| 185 | 185 | 
| 186     struct DrawPaths : public Cmd { | 186     struct DrawPaths : public Cmd { | 
| 187         DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_CmdType), fPath
     Range(pathRange) {} | 187         DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_CmdType), fPath
     Range(pathRange) {} | 
| 188 | 188 | 
| 189         const GrPathRange* pathRange() const { return fPathRange.get();  } | 189         const GrPathRange* pathRange() const { return fPathRange.get();  } | 
| 190 | 190 | 
| 191         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 191         void execute(GrGpu*, const SetState*) override; | 
| 192 | 192 | 
| 193         char*                           fIndices; | 193         char*                           fIndices; | 
| 194         GrDrawTarget::PathIndexType     fIndexType; | 194         GrDrawTarget::PathIndexType     fIndexType; | 
| 195         float*                          fTransforms; | 195         float*                          fTransforms; | 
| 196         GrDrawTarget::PathTransformType fTransformType; | 196         GrDrawTarget::PathTransformType fTransformType; | 
| 197         int                             fCount; | 197         int                             fCount; | 
| 198         GrStencilSettings               fStencilSettings; | 198         GrStencilSettings               fStencilSettings; | 
| 199 | 199 | 
| 200     private: | 200     private: | 
| 201         GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; | 201         GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; | 
| 202     }; | 202     }; | 
| 203 | 203 | 
| 204     // This is also used to record a discard by setting the color to GrColor_ILL
     EGAL | 204     // This is also used to record a discard by setting the color to GrColor_ILL
     EGAL | 
| 205     struct Clear : public Cmd { | 205     struct Clear : public Cmd { | 
| 206         Clear(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarget(rt) {} | 206         Clear(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarget(rt) {} | 
| 207 | 207 | 
| 208         GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 208         GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 
| 209 | 209 | 
| 210         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 210         void execute(GrGpu*, const SetState*) override; | 
| 211 | 211 | 
| 212         SkIRect fRect; | 212         SkIRect fRect; | 
| 213         GrColor fColor; | 213         GrColor fColor; | 
| 214         bool    fCanIgnoreRect; | 214         bool    fCanIgnoreRect; | 
| 215 | 215 | 
| 216     private: | 216     private: | 
| 217         GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 217         GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 
| 218     }; | 218     }; | 
| 219 | 219 | 
| 220     // This command is ONLY used by the clip mask manager to clear the stencil c
     lip bits | 220     // This command is ONLY used by the clip mask manager to clear the stencil c
     lip bits | 
| 221     struct ClearStencilClip : public Cmd { | 221     struct ClearStencilClip : public Cmd { | 
| 222         ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarge
     t(rt) {} | 222         ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_CmdType), fRenderTarge
     t(rt) {} | 
| 223 | 223 | 
| 224         GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 224         GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } | 
| 225 | 225 | 
| 226         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 226         void execute(GrGpu*, const SetState*) override; | 
| 227 | 227 | 
| 228         SkIRect fRect; | 228         SkIRect fRect; | 
| 229         bool    fInsideClip; | 229         bool    fInsideClip; | 
| 230 | 230 | 
| 231     private: | 231     private: | 
| 232         GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 232         GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 
| 233     }; | 233     }; | 
| 234 | 234 | 
| 235     struct CopySurface : public Cmd { | 235     struct CopySurface : public Cmd { | 
| 236         CopySurface(GrSurface* dst, GrSurface* src) | 236         CopySurface(GrSurface* dst, GrSurface* src) | 
| 237             : Cmd(kCopySurface_CmdType) | 237             : Cmd(kCopySurface_CmdType) | 
| 238             , fDst(dst) | 238             , fDst(dst) | 
| 239             , fSrc(src) { | 239             , fSrc(src) { | 
| 240         } | 240         } | 
| 241 | 241 | 
| 242         GrSurface* dst() const { return fDst.get(); } | 242         GrSurface* dst() const { return fDst.get(); } | 
| 243         GrSurface* src() const { return fSrc.get(); } | 243         GrSurface* src() const { return fSrc.get(); } | 
| 244 | 244 | 
| 245         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 245         void execute(GrGpu*, const SetState*) override; | 
| 246 | 246 | 
| 247         SkIPoint    fDstPoint; | 247         SkIPoint    fDstPoint; | 
| 248         SkIRect     fSrcRect; | 248         SkIRect     fSrcRect; | 
| 249 | 249 | 
| 250     private: | 250     private: | 
| 251         GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 251         GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 
| 252         GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 252         GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 
| 253     }; | 253     }; | 
| 254 | 254 | 
| 255     // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed | 255     // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed | 
| 256     struct SetState : public Cmd { | 256     struct SetState : public Cmd { | 
| 257         // TODO get rid of the prim proc parameter when we use batch everywhere | 257         // TODO get rid of the prim proc parameter when we use batch everywhere | 
| 258         SetState(const GrPrimitiveProcessor* primProc = NULL) | 258         SetState(const GrPrimitiveProcessor* primProc = NULL) | 
| 259         : Cmd(kSetState_CmdType) | 259         : Cmd(kSetState_CmdType) | 
| 260         , fPrimitiveProcessor(primProc) {} | 260         , fPrimitiveProcessor(primProc) {} | 
| 261 | 261 | 
| 262         ~SetState() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipelin
     e(); } | 262         ~SetState() { reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipelin
     e(); } | 
| 263 | 263 | 
| 264         // This function is only for getting the location in memory where we wil
     l create our | 264         // This function is only for getting the location in memory where we wil
     l create our | 
| 265         // pipeline object. | 265         // pipeline object. | 
| 266         GrPipeline* pipelineLocation() { return reinterpret_cast<GrPipeline*>(fP
     ipeline.get()); } | 266         GrPipeline* pipelineLocation() { return reinterpret_cast<GrPipeline*>(fP
     ipeline.get()); } | 
| 267 | 267 | 
| 268         const GrPipeline* getPipeline() const { | 268         const GrPipeline* getPipeline() const { | 
| 269             return reinterpret_cast<const GrPipeline*>(fPipeline.get()); | 269             return reinterpret_cast<const GrPipeline*>(fPipeline.get()); | 
| 270         } | 270         } | 
| 271 | 271 | 
| 272         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 272         void execute(GrGpu*, const SetState*) override; | 
| 273 | 273 | 
| 274         typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
     tiveProcessor; | 274         typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi
     tiveProcessor; | 
| 275         ProgramPrimitiveProcessor               fPrimitiveProcessor; | 275         ProgramPrimitiveProcessor               fPrimitiveProcessor; | 
| 276         SkAlignedSStorage<sizeof(GrPipeline)>   fPipeline; | 276         SkAlignedSStorage<sizeof(GrPipeline)>   fPipeline; | 
| 277         GrProgramDesc                           fDesc; | 277         GrProgramDesc                           fDesc; | 
| 278         GrBatchTracker                          fBatchTracker; | 278         GrBatchTracker                          fBatchTracker; | 
| 279     }; | 279     }; | 
| 280 | 280 | 
| 281     struct DrawBatch : public Cmd { | 281     struct DrawBatch : public Cmd { | 
| 282         DrawBatch(GrBatch* batch, GrBatchTarget* batchTarget) | 282         DrawBatch(GrBatch* batch, GrBatchTarget* batchTarget) | 
| 283             : Cmd(kDrawBatch_CmdType) | 283             : Cmd(kDrawBatch_CmdType) | 
| 284             , fBatch(SkRef(batch)) | 284             , fBatch(SkRef(batch)) | 
| 285             , fBatchTarget(batchTarget) { | 285             , fBatchTarget(batchTarget) { | 
| 286             SkASSERT(!batch->isUsed()); | 286             SkASSERT(!batch->isUsed()); | 
| 287         } | 287         } | 
| 288 | 288 | 
| 289         void execute(GrGpu*, const SetState*) SK_OVERRIDE; | 289         void execute(GrGpu*, const SetState*) override; | 
| 290 | 290 | 
| 291         // TODO it wouldn't be too hard to let batches allocate in the cmd buffe
     r | 291         // TODO it wouldn't be too hard to let batches allocate in the cmd buffe
     r | 
| 292         SkAutoTUnref<GrBatch>  fBatch; | 292         SkAutoTUnref<GrBatch>  fBatch; | 
| 293 | 293 | 
| 294     private: | 294     private: | 
| 295         GrBatchTarget*         fBatchTarget; | 295         GrBatchTarget*         fBatchTarget; | 
| 296     }; | 296     }; | 
| 297 | 297 | 
| 298      static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | 298      static const int kCmdBufferInitialSizeInBytes = 8 * 1024; | 
| 299 | 299 | 
| 300      typedef void* TCmdAlign; // This wouldn't be enough align if a command used
      long double. | 300      typedef void* TCmdAlign; // This wouldn't be enough align if a command used
      long double. | 
| 301      typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 301      typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 
| 302 | 302 | 
| 303      CmdBuffer                           fCmdBuffer; | 303      CmdBuffer                           fCmdBuffer; | 
| 304      SetState*                           fPrevState; | 304      SetState*                           fPrevState; | 
| 305      GrBatchTarget                       fBatchTarget; | 305      GrBatchTarget                       fBatchTarget; | 
| 306      // TODO hack until batch is everywhere | 306      // TODO hack until batch is everywhere | 
| 307      GrTargetCommands::DrawBatch*        fDrawBatch; | 307      GrTargetCommands::DrawBatch*        fDrawBatch; | 
| 308 | 308 | 
| 309      // This will go away when everything uses batch.  However, in the short ter
     m anything which | 309      // This will go away when everything uses batch.  However, in the short ter
     m anything which | 
| 310      // might be put into the GrInOrderDrawBuffer needs to make sure it closes t
     he last batch | 310      // might be put into the GrInOrderDrawBuffer needs to make sure it closes t
     he last batch | 
| 311      void closeBatch(); | 311      void closeBatch(); | 
| 312 }; | 312 }; | 
| 313 | 313 | 
| 314 #endif | 314 #endif | 
| 315 | 315 | 
| OLD | NEW | 
|---|