aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrInOrderDrawBuffer.h
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2015-01-28 12:53:54 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-28 12:53:54 -0800
commit4d8da81562852e0ff7e18b66ee1cebd50ad81ee8 (patch)
tree42ca42baff53262473f93429bc49a6a85e33b7b4 /src/gpu/GrInOrderDrawBuffer.h
parent52f401ee7bdb39f7c9ba6cca4ee1db9b93d5cb45 (diff)
GrBatchPrototype
Diffstat (limited to 'src/gpu/GrInOrderDrawBuffer.h')
-rw-r--r--src/gpu/GrInOrderDrawBuffer.h58
1 files changed, 51 insertions, 7 deletions
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index afa7d27394..bf9237d426 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 "GrBatchTarget.h"
#include "GrPipeline.h"
#include "GrPath.h"
#include "GrTRecorder.h"
@@ -50,16 +53,21 @@ public:
void discard(GrRenderTarget*) SK_OVERRIDE;
+ void willReserveVertexAndIndexSpace(int vertexCount,
+ size_t vertexStride,
+ int indexCount);
+
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,
+ kDrawBatch_Cmd = 8,
};
struct SetState;
@@ -180,6 +188,7 @@ private:
// TODO: rename to SetPipeline once pp, batch tracker, and desc are removed
struct SetState : public Cmd {
+ // TODO get rid of the prim proc version of this when we use batch everywhere
SetState(const GrPipelineBuilder& pipelineBuilder, const GrPrimitiveProcessor* primProc,
const GrDrawTargetCaps& caps,
const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy)
@@ -187,6 +196,13 @@ private:
, fPrimitiveProcessor(primProc)
, fPipeline(pipelineBuilder, primProc, caps, scissor, dstCopy) {}
+ SetState(GrBatch* batch,
+ const GrPipelineBuilder& pipelineBuilder,
+ const GrDrawTargetCaps& caps,
+ const GrScissorState& scissor, const GrDeviceCoordTexture* dstCopy)
+ : Cmd(kSetState_Cmd)
+ , fPipeline(batch, pipelineBuilder, caps, scissor, dstCopy) {}
+
void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE;
typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimitiveProcessor;
@@ -196,6 +212,17 @@ private:
GrBatchTracker fBatchTracker;
};
+ struct DrawBatch : public Cmd {
+ DrawBatch(GrBatch* batch) : Cmd(kDrawBatch_Cmd), 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;
@@ -208,6 +235,10 @@ private:
const DrawInfo&,
const GrScissorState&,
const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
+ void onDrawBatch(GrBatch*,
+ const GrPipelineBuilder&,
+ const GrScissorState&,
+ const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE;
void onDrawRect(GrPipelineBuilder*,
GrColor,
const SkMatrix& viewMatrix,
@@ -253,10 +284,16 @@ private:
// Determines whether the current draw operation requires a new GrPipeline and if so
// records it. If the draw can be skipped false is returned and no new GrPipeline is
// recorded.
+ // TODO delete the primproc variant when we have batches everywhere
bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrPipelineBuilder&,
const GrPrimitiveProcessor*,
const GrScissorState&,
const GrDeviceCoordTexture*);
+ bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(GrBatch*,
+ const GrPipelineBuilder&,
+ 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.
@@ -264,6 +301,8 @@ private:
bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; }
+ GrBatchTarget* getBatchTarget() { return &fBatchTarget; }
+
// TODO: Use a single allocator for commands and records
enum {
kCmdBufferInitialSizeInBytes = 8 * 1024,
@@ -277,6 +316,11 @@ private:
SkTDArray<char> fPathIndexBuffer;
SkTDArray<float> fPathTransformBuffer;
uint32_t fDrawID;
+ GrBatchTarget fBatchTarget;
+ // TODO hack until batch is everywhere
+ DrawBatch* fDrawBatch;
+
+ void closeBatch();
typedef GrFlushToGpuDrawTarget INHERITED;
};