OLD | NEW |
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 |
15 class GrGpuCommandBuffer { | 20 class GrGpuCommandBuffer { |
16 public: | 21 public: |
17 enum LoadAndStoreOp { | 22 enum LoadAndStoreOp { |
18 kLoadAndStore_LoadAndStoreOp, | 23 kLoadAndStore_LoadAndStoreOp, |
19 kLoadAndDiscard_LoadAndStoreOp, | 24 kLoadAndDiscard_LoadAndStoreOp, |
20 kClearAndStore_LoadAndStoreOp, | 25 kClearAndStore_LoadAndStoreOp, |
21 kClearAndDiscard_LoadAndStoreOp, | 26 kClearAndDiscard_LoadAndStoreOp, |
22 kDiscardAndStore_LoadAndStoreOp, | 27 kDiscardAndStore_LoadAndStoreOp, |
23 kDiscardAndDiscard_LoadAndStoreOp, | 28 kDiscardAndDiscard_LoadAndStoreOp, |
24 }; | 29 }; |
25 | 30 |
26 GrGpuCommandBuffer() {} | 31 GrGpuCommandBuffer() {} |
27 virtual ~GrGpuCommandBuffer() {} | 32 virtual ~GrGpuCommandBuffer() {} |
28 | 33 |
29 // Signals the end of recording to the command buffer and that it can now be
submitted. | 34 // Signals the end of recording to the command buffer and that it can now be
submitted. |
30 virtual void end() = 0; | 35 virtual void end() = 0; |
31 | 36 |
32 // Sends the command buffer off to the GPU object to execute the commands bu
ilt up in the | 37 // 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. | 38 // buffer. The gpu object is allowed to defer execution of the commands unti
l it is flushed. |
34 virtual void submit() = 0; | 39 // The bounds should represent the bounds of all the draws put into the comm
and buffer. |
| 40 void submit(const SkIRect& bounds); |
| 41 |
| 42 // We pass in an array of meshCount GrMesh to the draw. The backend should l
oop over each |
| 43 // GrMesh object and emit a draw for it. Each draw will use the same GrPipel
ine and |
| 44 // GrPrimitiveProcessor. This may fail if the draw would exceed any resource
limits (e.g. |
| 45 // number of vertex attributes is too large). |
| 46 bool draw(const GrPipeline&, |
| 47 const GrPrimitiveProcessor&, |
| 48 const GrMesh*, |
| 49 int meshCount); |
| 50 |
| 51 /** |
| 52 * Clear the passed in render target. Ignores the draw state and clip. |
| 53 */ |
| 54 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
{ |
| 55 this->onClear(renderTarget, rect, color); |
| 56 } |
| 57 |
| 58 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget) { |
| 59 this->onClearStencilClip(renderTarget, rect, insideClip); |
| 60 } |
| 61 |
| 62 /** |
| 63 * Discards the contents render target. nullptr indicates that the current re
nder target should |
| 64 * be discarded. |
| 65 **/ |
| 66 // TODO: This should be removed in the future to favor using the load and st
ore ops for discard |
| 67 virtual void discard(GrRenderTarget* = nullptr) = 0; |
| 68 |
| 69 private: |
| 70 virtual GrGpu* gpu() = 0; |
| 71 virtual void onSubmit(const SkIRect& bounds) = 0; |
| 72 |
| 73 // overridden by backend-specific derived class to perform the draw call. |
| 74 virtual void onDraw(const GrPipeline&, |
| 75 const GrPrimitiveProcessor&, |
| 76 const GrMesh*, |
| 77 int meshCount) = 0; |
| 78 |
| 79 // overridden by backend-specific derived class to perform the clear. |
| 80 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) =
0; |
| 81 |
| 82 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
nsideClip) = 0; |
| 83 |
35 }; | 84 }; |
36 | 85 |
37 #endif | 86 #endif |
OLD | NEW |