Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Unified Diff: src/gpu/GrInOrderDrawBuffer.h

Issue 845103005: GrBatchPrototype (Closed) Base URL: https://skia.googlesource.com/skia.git@lc2
Patch Set: removing dstread Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrGeometryProcessor.cpp ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrInOrderDrawBuffer.h
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index afa7d27394d8428fcaa735466e29d287e5f81032..bf9237d4268896b2793f9c4671253653c108443b 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;
};
« no previous file with comments | « src/gpu/GrGeometryProcessor.cpp ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698