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

Side by Side Diff: src/gpu/GrGpuCommandBuffer.h

Issue 2078483002: Start using GrGpuCommandBuffer in GrDrawTarget. (Closed) Base URL: https://skia.googlesource.com/skia.git@memoryWAR
Patch Set: remove errant lines 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrGpuCommandBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrGpuCommandBuffer_DEFINED 8 #ifndef GrGpuCommandBuffer_DEFINED
9 #define GrGpuCommandBuffer_DEFINED 9 #define GrGpuCommandBuffer_DEFINED
10 10
11 #include "GrColor.h" 11 #include "GrColor.h"
12 12
13 class GrGpu;
14 class GrMesh;
15 class GrPipeline;
16 class GrPrimitiveProcessor;
13 class GrRenderTarget; 17 class GrRenderTarget;
18 struct SkIRect;
14 19
20 /**
21 * The GrGpuCommandBuffer is a series of commands (draws, clears, and discards), which all target
22 * the same render target. It is possible that these commands execute immediatel y (GL), or get
23 * buffered up for later execution (Vulkan). GrBatches will execute their draw c ommands into a
24 * GrGpuCommandBuffer.
25 */
15 class GrGpuCommandBuffer { 26 class GrGpuCommandBuffer {
16 public: 27 public:
17 enum LoadAndStoreOp { 28 enum class LoadOp {
18 kLoadAndStore_LoadAndStoreOp, 29 kLoad,
19 kLoadAndDiscard_LoadAndStoreOp, 30 kClear,
20 kClearAndStore_LoadAndStoreOp, 31 kDiscard,
21 kClearAndDiscard_LoadAndStoreOp, 32 };
22 kDiscardAndStore_LoadAndStoreOp, 33
23 kDiscardAndDiscard_LoadAndStoreOp, 34 enum class StoreOp {
35 kStore,
36 kDiscard,
37 };
38
39 struct LoadAndStoreInfo {
40 LoadOp fLoadOp;
41 StoreOp fStoreOp;
42 GrColor fClearColor;
24 }; 43 };
25 44
26 GrGpuCommandBuffer() {} 45 GrGpuCommandBuffer() {}
27 virtual ~GrGpuCommandBuffer() {} 46 virtual ~GrGpuCommandBuffer() {}
28 47
29 // Signals the end of recording to the command buffer and that it can now be submitted. 48 // Signals the end of recording to the command buffer and that it can now be submitted.
30 virtual void end() = 0; 49 virtual void end() = 0;
31 50
32 // Sends the command buffer off to the GPU object to execute the commands bu ilt up in the 51 // Sends the command buffer off to the GPU object to execute the commands bu ilt up in the
33 // buffer. The gpu object is allowed to defer execution of the commands unti l it is flushed. 52 // buffer. The gpu object is allowed to defer execution of the commands unti l it is flushed.
34 virtual void submit() = 0; 53 // The bounds should represent the bounds of all the draws put into the comm and buffer.
54 void submit(const SkIRect& bounds);
55
56 // We pass in an array of meshCount GrMesh to the draw. The backend should l oop over each
57 // GrMesh object and emit a draw for it. Each draw will use the same GrPipel ine and
58 // GrPrimitiveProcessor. This may fail if the draw would exceed any resource limits (e.g.
59 // number of vertex attributes is too large).
60 bool draw(const GrPipeline&,
61 const GrPrimitiveProcessor&,
62 const GrMesh*,
63 int meshCount);
64
65 /**
66 * Clear the passed in render target. Ignores the draw state and clip.
67 */
68 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget) ;
69
70 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget);
71 /**
72 * Discards the contents render target. nullptr indicates that the current re nder target should
73 * be discarded.
74 **/
75 // TODO: This should be removed in the future to favor using the load and st ore ops for discard
76 virtual void discard(GrRenderTarget* = nullptr) = 0;
77
78 private:
79 virtual GrGpu* gpu() = 0;
80 virtual void onSubmit(const SkIRect& bounds) = 0;
81
82 // overridden by backend-specific derived class to perform the draw call.
83 virtual void onDraw(const GrPipeline&,
84 const GrPrimitiveProcessor&,
85 const GrMesh*,
86 int meshCount) = 0;
87
88 // overridden by backend-specific derived class to perform the clear.
89 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0;
90
91 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i nsideClip) = 0;
92
35 }; 93 };
36 94
37 #endif 95 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrGpuCommandBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698