Index: src/gpu/GrInOrderDrawBuffer.h |
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h |
index ea1279bc578e82c0aac1944d5a81ed8abe2c980b..a5d6261ea88564b16dd47678a6834001ecadc33b 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) |
@@ -186,6 +191,13 @@ private: |
, fPrimitiveProcessor(primProc) |
, fState(drawState, primProc, caps, scissor, dstCopy) {} |
+ SetState(GrBatch* batch, |
+ const GrDrawState& drawState, |
+ const GrDrawTargetCaps& caps, |
+ const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy) |
+ : Cmd(kSetState_Cmd) |
+ , fState(batch, drawState, caps, scissor, dstCopy) {} |
+ |
void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor; |
@@ -195,6 +207,17 @@ private: |
GrBatchTracker fBatchTracker; |
}; |
+ struct BatchDraw : public Cmd { |
+ BatchDraw(GrBatch* batch) : Cmd(kBatchDraw), fBatch(SkRef(batch)) { |
+ SkASSERT(!batch->isUsed()); |
+ } |
+ |
+ void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
+ |
+ // TODO it wouldn't be too hard to let batches allocate in the cmd buffer |
+ SkAutoTUnref<GrBatch> fBatch; |
+ }; |
+ |
typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. |
typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
@@ -207,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, |
@@ -252,10 +280,16 @@ 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*, |
const GrScissorState&, |
const GrDeviceCoordTexture*); |
+ bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(GrBatch*, |
+ const GrDrawState&, |
+ 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. |
@@ -263,6 +297,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, |
@@ -276,6 +312,7 @@ private: |
SkTDArray<char> fPathIndexBuffer; |
SkTDArray<float> fPathTransformBuffer; |
uint32_t fDrawID; |
+ GrBatchBuffer fBatchBuffer; |
typedef GrFlushToGpuDrawTarget INHERITED; |
}; |