Chromium Code Reviews| Index: src/gpu/GrInOrderDrawBuffer.h |
| diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h |
| index d73354648ede0c4d97a48839defe93fb526c7a6a..6e05419471dab040ffff7fb41882b5f063aa4af9 100644 |
| --- a/src/gpu/GrInOrderDrawBuffer.h |
| +++ b/src/gpu/GrInOrderDrawBuffer.h |
| @@ -9,6 +9,8 @@ |
| #define GrInOrderDrawBuffer_DEFINED |
| #include "GrFlushToGpuDrawTarget.h" |
| + |
| +#include "GrBatch.h" |
| #include "GrOptDrawState.h" |
| #include "GrPath.h" |
| #include "GrTRecorder.h" |
| @@ -52,13 +54,14 @@ public: |
| private: |
| enum { |
| - kDraw_Cmd = 1, |
| - kStencilPath_Cmd = 2, |
| - kSetState_Cmd = 3, |
| - kClear_Cmd = 4, |
| - kCopySurface_Cmd = 5, |
| - kDrawPath_Cmd = 6, |
| - kDrawPaths_Cmd = 7, |
| + kDraw_Cmd = 1, |
| + kStencilPath_Cmd = 2, |
| + kSetState_Cmd = 3, |
| + kClear_Cmd = 4, |
| + kCopySurface_Cmd = 5, |
| + kDrawPath_Cmd = 6, |
| + kDrawPaths_Cmd = 7, |
| + kBatchDraw = 8, |
| }; |
| struct Cmd : ::SkNoncopyable { |
| @@ -176,6 +179,7 @@ private: |
| }; |
| struct SetState : public Cmd { |
| + // TODO get rid of the prim proc version of this when we use batch everywhere |
| SetState(const GrDrawState& drawState, const GrPrimitiveProcessor* primProc, |
| const GrDrawTargetCaps& caps, |
| const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy, |
| @@ -183,11 +187,29 @@ private: |
| : Cmd(kSetState_Cmd) |
| , fState(drawState, primProc, caps, scissor, dstCopy, drawType) {} |
| + SetState(GrBatch* batch, |
| + const GrDrawState& drawState, |
| + const GrDrawTargetCaps& caps, |
| + const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy, |
| + GrGpu::DrawType drawType) |
| + : Cmd(kSetState_Cmd) |
| + , fState(batch, drawState, caps, scissor, dstCopy, drawType) {} |
| + |
| void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; |
| GrOptDrawState fState; |
| }; |
| + struct BatchDraw : public Cmd { |
| + BatchDraw(GrBatch* batch) : Cmd(kBatchDraw), fBatch(batch) {} |
| + |
| + void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) SK_OVERRIDE; |
| + |
| + // TODO it wouldn't be too hard to let batches allocate in the cmd buffer |
|
bsalomon
2015/01/20 16:14:03
as opposed to in the mem pool? should grbatch be r
joshualitt
2015/01/20 17:03:08
Right, as opposed to the mem pool. I don't think
|
| + SkAutoTDelete<GrBatch> fBatch; |
| + |
|
bsalomon
2015/01/20 16:14:03
extra \n
|
| + }; |
| + |
| typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. |
| typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
| @@ -200,6 +222,11 @@ private: |
| const DrawInfo&, |
| const GrScissorState&, |
| const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| + void onBatchDraw(GrBatch*, |
| + const GrDrawState&, |
| + GrPrimitiveType type, |
| + const GrScissorState&, |
| + const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; |
| void onDrawRect(GrDrawState*, |
| GrColor, |
| const SkMatrix& viewMatrix, |
| @@ -245,11 +272,20 @@ private: |
| // Determines whether the current draw operation requires a new GrOptDrawState and if so |
| // records it. If the draw can be skipped false is returned and no new GrOptDrawState is |
| // recorded. |
| + // TODO delete the primproc variant when we have batches everywhere |
| bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrDrawState&, |
| const GrPrimitiveProcessor*, |
| GrGpu::DrawType, |
| const GrScissorState&, |
| const GrDeviceCoordTexture*); |
| + bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(GrBatch*, |
| + const GrDrawState&, |
| + GrGpu::DrawType, |
| + const GrScissorState&, |
| + const GrDeviceCoordTexture*); |
| + bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(SetState*); |
| + |
| + |
| // We lazily record clip changes in order to skip clips that have no effect. |
| void recordClipIfNecessary(); |
| // Records any trace markers for a command after adding it to the buffer. |