Home | History | Annotate | Download | only in gpu
      1 /*
      2  * Copyright 2015 Google Inc.
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef GrCommandBuilder_DEFINED
      9 #define GrCommandBuilder_DEFINED
     10 
     11 #include "GrTargetCommands.h"
     12 
     13 class GrInOrderDrawBuffer;
     14 
     15 class GrCommandBuilder : ::SkNoncopyable {
     16 public:
     17     typedef GrTargetCommands::Cmd Cmd;
     18     typedef GrTargetCommands::State State;
     19 
     20     static GrCommandBuilder* Create(GrGpu* gpu, bool reorder);
     21 
     22     virtual ~GrCommandBuilder() {}
     23 
     24     void reset() { fCommands.reset(); }
     25     void flush(GrInOrderDrawBuffer* iodb) { fCommands.flush(iodb); }
     26 
     27     virtual Cmd* recordClearStencilClip(const SkIRect& rect,
     28                                         bool insideClip,
     29                                         GrRenderTarget* renderTarget);
     30     virtual Cmd* recordDiscard(GrRenderTarget*);
     31     virtual Cmd* recordDrawBatch(State*, GrBatch*) = 0;
     32     virtual Cmd* recordStencilPath(const GrPipelineBuilder&,
     33                                    const GrPathProcessor*,
     34                                    const GrPath*,
     35                                    const GrScissorState&,
     36                                    const GrStencilSettings&) = 0;
     37     virtual Cmd* recordDrawPath(State*,
     38                                 const GrPathProcessor*,
     39                                 const GrPath*,
     40                                 const GrStencilSettings&) = 0;
     41     virtual Cmd* recordDrawPaths(State*,
     42                                  GrInOrderDrawBuffer*,
     43                                  const GrPathProcessor*,
     44                                  const GrPathRange*,
     45                                  const void*,
     46                                  GrDrawTarget::PathIndexType,
     47                                  const float transformValues[],
     48                                  GrDrawTarget::PathTransformType ,
     49                                  int,
     50                                  const GrStencilSettings&,
     51                                  const GrDrawTarget::PipelineInfo&) = 0;
     52     virtual Cmd* recordClear(const SkIRect* rect,
     53                              GrColor,
     54                              bool canIgnoreRect,
     55                              GrRenderTarget*);
     56     virtual Cmd* recordCopySurface(GrSurface* dst,
     57                                    GrSurface* src,
     58                                    const SkIRect& srcRect,
     59                                    const SkIPoint& dstPoint);
     60     virtual Cmd* recordXferBarrierIfNecessary(const GrPipeline&, const GrDrawTargetCaps&);
     61 
     62 protected:
     63     typedef GrTargetCommands::DrawBatch DrawBatch;
     64     typedef GrTargetCommands::StencilPath StencilPath;
     65     typedef GrTargetCommands::DrawPath DrawPath;
     66     typedef GrTargetCommands::DrawPaths DrawPaths;
     67     typedef GrTargetCommands::Clear Clear;
     68     typedef GrTargetCommands::ClearStencilClip ClearStencilClip;
     69     typedef GrTargetCommands::CopySurface CopySurface;
     70     typedef GrTargetCommands::XferBarrier XferBarrier;
     71 
     72     GrCommandBuilder(GrGpu* gpu) : fCommands(gpu) {}
     73 
     74     GrTargetCommands::CmdBuffer* cmdBuffer() { return fCommands.cmdBuffer(); }
     75     GrBatchTarget* batchTarget() { return fCommands.batchTarget(); }
     76 
     77 private:
     78     GrTargetCommands fCommands;
     79 
     80 };
     81 
     82 #endif
     83