egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 1 | /* |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 7 | |
| 8 | #ifndef GrGLGpuCommandBuffer_DEFINED |
| 9 | #define GrGLGpuCommandBuffer_DEFINED |
| 10 | |
| 11 | #include "GrGpuCommandBuffer.h" |
| 12 | |
Hal Canary | 466c7d6 | 2017-07-03 15:11:49 -0400 | [diff] [blame] | 13 | #include "GrGLGpu.h" |
| 14 | #include "GrGLRenderTarget.h" |
Brian Salomon | 742e31d | 2016-12-07 17:06:19 -0500 | [diff] [blame] | 15 | #include "GrOpFlushState.h" |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 16 | |
Robert Phillips | 009e9af | 2017-06-15 14:01:04 -0400 | [diff] [blame] | 17 | class GrGLGpu; |
Greg Daniel | 65a0927 | 2016-10-12 09:47:22 -0400 | [diff] [blame] | 18 | class GrGLRenderTarget; |
| 19 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 20 | class GrGLGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer { |
| 21 | public: |
| 22 | GrGLGpuTextureCommandBuffer(GrGLGpu* gpu, GrTexture* texture, GrSurfaceOrigin origin) |
| 23 | : INHERITED(texture, origin) |
| 24 | , fGpu(gpu) { |
| 25 | } |
| 26 | |
| 27 | ~GrGLGpuTextureCommandBuffer() override {} |
| 28 | |
| 29 | void submit() override {} |
| 30 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 31 | void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, |
| 32 | const SkIPoint& dstPoint) override { |
| 33 | fGpu->copySurface(fTexture, fOrigin, src, srcOrigin, srcRect, dstPoint); |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void insertEventMarker(const char* msg) override { |
| 37 | fGpu->insertEventMarker(msg); |
| 38 | } |
| 39 | |
| 40 | private: |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 41 | GrGLGpu* fGpu; |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 42 | |
| 43 | typedef GrGpuTextureCommandBuffer INHERITED; |
| 44 | }; |
| 45 | |
| 46 | class GrGLGpuRTCommandBuffer : public GrGpuRTCommandBuffer { |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 47 | /** |
| 48 | * We do not actually buffer up draws or do any work in the this class for GL. Instead commands |
| 49 | * are immediately sent to the gpu to execute. Thus all the commands in this class are simply |
| 50 | * pass through functions to corresponding calls in the GrGLGpu class. |
| 51 | */ |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 52 | public: |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 53 | GrGLGpuRTCommandBuffer(GrGLGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin, |
Robert Phillips | 6b47c7d | 2017-08-29 07:24:09 -0400 | [diff] [blame] | 54 | const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo, |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 55 | const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 56 | : INHERITED(rt, origin) |
Robert Phillips | 6b47c7d | 2017-08-29 07:24:09 -0400 | [diff] [blame] | 57 | , fGpu(gpu) |
| 58 | , fColorLoadAndStoreInfo(colorInfo) |
| 59 | , fStencilLoadAndStoreInfo(stencilInfo) { |
Robert Phillips | 9521447 | 2017-08-08 18:00:03 -0400 | [diff] [blame] | 60 | } |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 61 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 62 | ~GrGLGpuRTCommandBuffer() override {} |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 63 | |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 64 | void begin() override; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 65 | void end() override {} |
| 66 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 67 | void discard() override { } |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 68 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 69 | void insertEventMarker(const char* msg) override { |
Robert Phillips | 65a88fa | 2017-08-08 08:36:22 -0400 | [diff] [blame] | 70 | fGpu->insertEventMarker(msg); |
| 71 | } |
| 72 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 73 | void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) override { |
Greg Daniel | 77b53f6 | 2016-10-18 11:48:51 -0400 | [diff] [blame] | 74 | state->doUpload(upload); |
| 75 | } |
| 76 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 77 | void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, |
| 78 | const SkIPoint& dstPoint) override { |
| 79 | fGpu->copySurface(fRenderTarget, fOrigin, src, srcOrigin, srcRect, dstPoint); |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | void submit() override {} |
| 83 | |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 84 | private: |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 85 | GrGpu* gpu() override { return fGpu; } |
| 86 | |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 87 | void onDraw(const GrPipeline& pipeline, |
| 88 | const GrPrimitiveProcessor& primProc, |
Chris Dalton | 46983b7 | 2017-06-06 12:27:16 -0600 | [diff] [blame] | 89 | const GrMesh mesh[], |
| 90 | const GrPipeline::DynamicState dynamicStates[], |
Greg Daniel | 36a77ee | 2016-10-18 10:33:25 -0400 | [diff] [blame] | 91 | int meshCount, |
| 92 | const SkRect& bounds) override { |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 93 | SkASSERT(pipeline.renderTarget() == fRenderTarget); |
Chris Dalton | 46983b7 | 2017-06-06 12:27:16 -0600 | [diff] [blame] | 94 | fGpu->draw(pipeline, primProc, mesh, dynamicStates, meshCount); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 97 | void onClear(const GrFixedClip& clip, GrColor color) override { |
| 98 | fGpu->clear(clip, color, fRenderTarget, fOrigin); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 101 | void onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) override { |
| 102 | fGpu->clearStencilClip(clip, insideStencilMask, fRenderTarget, fOrigin); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Robert Phillips | 6b47c7d | 2017-08-29 07:24:09 -0400 | [diff] [blame] | 105 | GrGLGpu* fGpu; |
| 106 | GrGpuRTCommandBuffer::LoadAndStoreInfo fColorLoadAndStoreInfo; |
| 107 | GrGpuRTCommandBuffer::StencilLoadAndStoreInfo fStencilLoadAndStoreInfo; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 108 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 109 | typedef GrGpuRTCommandBuffer INHERITED; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | #endif |
| 113 | |