| Index: src/gpu/GrInOrderDrawBuffer.h
|
| diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
|
| index 6a6cd88f6ae9301af7935a8ea61e34f8fc33fe97..8ca0e47349e1a941caceafdeee2dae64d8a1ba04 100644
|
| --- a/src/gpu/GrInOrderDrawBuffer.h
|
| +++ b/src/gpu/GrInOrderDrawBuffer.h
|
| @@ -9,6 +9,9 @@
|
| #define GrInOrderDrawBuffer_DEFINED
|
|
|
| #include "GrFlushToGpuDrawTarget.h"
|
| +
|
| +#include "GrBatch.h"
|
| +#include "GrBatchBuffer.h"
|
| #include "GrOptDrawState.h"
|
| #include "GrPath.h"
|
| #include "GrTRecorder.h"
|
| @@ -53,13 +56,14 @@ public:
|
| private:
|
| typedef GrGpu::DrawArgs DrawArgs;
|
| 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 SetState;
|
| @@ -179,6 +183,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,
|
| @@ -187,6 +192,14 @@ private:
|
| , fPrimitiveProcessor(primProc)
|
| , 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 SetState*) SK_OVERRIDE;
|
|
|
| typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor;
|
| @@ -196,6 +209,15 @@ private:
|
| GrBatchTracker fBatchTracker;
|
| };
|
|
|
| + struct BatchDraw : public Cmd {
|
| + BatchDraw(GrBatch* batch) : Cmd(kBatchDraw), fBatch(batch) {}
|
| +
|
| + void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
|
| +
|
| + // TODO it wouldn't be too hard to let batches allocate in the cmd buffer
|
| + SkAutoTDelete<GrBatch> fBatch;
|
| + };
|
| +
|
| typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
|
| typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
|
|
|
| @@ -208,6 +230,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,
|
| @@ -253,11 +280,18 @@ 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*);
|
| +
|
| // 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.
|
| @@ -265,6 +299,8 @@ private:
|
|
|
| bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; }
|
|
|
| + GrBatchBuffer* getBatchBuffer() { return &fBatchBuffer; }
|
| +
|
| // TODO: Use a single allocator for commands and records
|
| enum {
|
| kCmdBufferInitialSizeInBytes = 8 * 1024,
|
| @@ -278,6 +314,7 @@ private:
|
| SkTDArray<char> fPathIndexBuffer;
|
| SkTDArray<float> fPathTransformBuffer;
|
| uint32_t fDrawID;
|
| + GrBatchBuffer fBatchBuffer;
|
|
|
| typedef GrFlushToGpuDrawTarget INHERITED;
|
| };
|
|
|