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

Unified Diff: src/gpu/GrGpuCommandBuffer.h

Issue 2078483002: Start using GrGpuCommandBuffer in GrDrawTarget. (Closed) Base URL: https://skia.googlesource.com/skia.git@memoryWAR
Patch Set: Review updates Created 4 years, 6 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
Index: src/gpu/GrGpuCommandBuffer.h
diff --git a/src/gpu/GrGpuCommandBuffer.h b/src/gpu/GrGpuCommandBuffer.h
index 3c6e6116fb6a17f61bd0fb23ac0b270de0baa0c9..5f1a465056d599b73bcc1c1bee69147c56244de9 100644
--- a/src/gpu/GrGpuCommandBuffer.h
+++ b/src/gpu/GrGpuCommandBuffer.h
@@ -10,17 +10,43 @@
#include "GrColor.h"
+class GrGpu;
+class GrMesh;
+class GrPipeline;
+class GrPrimitiveProcessor;
class GrRenderTarget;
+struct SkIRect;
+/**
+ * The GrGpuCommandBuffer is a series of commands (draws, clears, and discards), which all target
+ * the same render target. It is possible that these commands execute immediately (GL), or get
+ * buffered up for later execution (Vulkan). Currently GrBatches will execute their draw commands
bsalomon 2016/06/23 02:12:55 Why "Currently"? Is this likely to change?
egdaniel 2016/06/23 13:57:08 Removed. I put currently at first, cause technical
+ * into a GrGpuCommandBuffer.
+ */
class GrGpuCommandBuffer {
public:
- enum LoadAndStoreOp {
- kLoadAndStore_LoadAndStoreOp,
- kLoadAndDiscard_LoadAndStoreOp,
- kClearAndStore_LoadAndStoreOp,
- kClearAndDiscard_LoadAndStoreOp,
- kDiscardAndStore_LoadAndStoreOp,
- kDiscardAndDiscard_LoadAndStoreOp,
+ enum LoadOp {
bsalomon 2016/06/23 02:12:55 enum classes? No strong preference but it is the f
egdaniel 2016/06/23 13:57:08 Done.
+ kLoad_LoadOp,
+ kClear_LoadOp,
+ kDiscard_LoadOp,
+ };
+
+ enum StoreOp {
+ kStore_StoreOp,
+ kDiscard_StoreOp,
+ };
+
+ struct LoadAndStoreInfo {
+ LoadOp fLoadOp;
+ StoreOp fStoreOp;
+ GrColor fClearColor;
+
+ LoadAndStoreInfo(LoadOp loadOp, StoreOp storeOp, GrColor color = GrColor_ILLEGAL)
bsalomon 2016/06/23 02:12:55 It seems like you have this constructor in order t
egdaniel 2016/06/23 13:57:08 when with pure struct.
+ : fLoadOp(loadOp)
+ , fStoreOp(storeOp)
+ , fClearColor(color) {
+ SkASSERT(kClear_LoadOp != fLoadOp || GrColor_ILLEGAL != fClearColor);
+ }
};
GrGpuCommandBuffer() {}
@@ -31,7 +57,46 @@ public:
// Sends the command buffer off to the GPU object to execute the commands built up in the
// buffer. The gpu object is allowed to defer execution of the commands until it is flushed.
- virtual void submit() = 0;
+ // The bounds should represent the bounds of all the draws put into the command buffer.
+ void submit(const SkIRect& bounds);
+
+ // We pass in an array of meshCount GrMesh to the draw. The backend should loop over each
+ // GrMesh object and emit a draw for it. Each draw will use the same GrPipeline and
+ // GrPrimitiveProcessor. This may fail if the draw would exceed any resource limits (e.g.
+ // number of vertex attributes is too large).
+ bool draw(const GrPipeline&,
+ const GrPrimitiveProcessor&,
+ const GrMesh*,
+ int meshCount);
+
+ /**
+ * Clear the passed in render target. Ignores the draw state and clip.
+ */
+ void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget);
+
+ void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget);
+ /**
+ * Discards the contents render target. nullptr indicates that the current render target should
+ * be discarded.
+ **/
+ // TODO: This should be removed in the future to favor using the load and store ops for discard
+ virtual void discard(GrRenderTarget* = nullptr) = 0;
+
+private:
+ virtual GrGpu* gpu() = 0;
+ virtual void onSubmit(const SkIRect& bounds) = 0;
+
+ // overridden by backend-specific derived class to perform the draw call.
+ virtual void onDraw(const GrPipeline&,
+ const GrPrimitiveProcessor&,
+ const GrMesh*,
+ int meshCount) = 0;
+
+ // overridden by backend-specific derived class to perform the clear.
+ virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0;
+
+ virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideClip) = 0;
+
};
#endif

Powered by Google App Engine
This is Rietveld 408576698