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: |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 22 | GrGLGpuTextureCommandBuffer(GrGLGpu* gpu) : fGpu(gpu) {} |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 23 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 24 | void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, |
| 25 | const SkIPoint& dstPoint) override { |
| 26 | fGpu->copySurface(fTexture, fOrigin, src, srcOrigin, srcRect, dstPoint); |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | void insertEventMarker(const char* msg) override { |
| 30 | fGpu->insertEventMarker(msg); |
| 31 | } |
| 32 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 33 | void reset() { |
| 34 | fTexture = nullptr; |
| 35 | } |
| 36 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 37 | private: |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 38 | GrGLGpu* fGpu; |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 39 | |
| 40 | typedef GrGpuTextureCommandBuffer INHERITED; |
| 41 | }; |
| 42 | |
| 43 | class GrGLGpuRTCommandBuffer : public GrGpuRTCommandBuffer { |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 44 | /** |
| 45 | * We do not actually buffer up draws or do any work in the this class for GL. Instead commands |
| 46 | * are immediately sent to the gpu to execute. Thus all the commands in this class are simply |
| 47 | * pass through functions to corresponding calls in the GrGLGpu class. |
| 48 | */ |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 49 | public: |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 50 | GrGLGpuRTCommandBuffer(GrGLGpu* gpu) : fGpu(gpu) {} |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 51 | |
Robert Phillips | cb2e235 | 2017-08-30 16:44:40 -0400 | [diff] [blame] | 52 | void begin() override; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 53 | void end() override {} |
| 54 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 55 | void discard() override { } |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 56 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 57 | void insertEventMarker(const char* msg) override { |
Robert Phillips | 65a88fa | 2017-08-08 08:36:22 -0400 | [diff] [blame] | 58 | fGpu->insertEventMarker(msg); |
| 59 | } |
| 60 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 61 | void inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override { |
Greg Daniel | 77b53f6 | 2016-10-18 11:48:51 -0400 | [diff] [blame] | 62 | state->doUpload(upload); |
| 63 | } |
| 64 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 65 | void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, |
| 66 | const SkIPoint& dstPoint) override { |
| 67 | fGpu->copySurface(fRenderTarget, fOrigin, src, srcOrigin, srcRect, dstPoint); |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 68 | } |
| 69 | |
Robert Phillips | 5b5d84c | 2018-08-09 15:12:18 -0400 | [diff] [blame] | 70 | void set(GrRenderTarget*, GrSurfaceOrigin, |
| 71 | const GrGpuRTCommandBuffer::LoadAndStoreInfo&, |
| 72 | const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&); |
| 73 | |
| 74 | void reset() { |
| 75 | fRenderTarget = nullptr; |
| 76 | } |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 77 | |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 78 | private: |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 79 | GrGpu* gpu() override { return fGpu; } |
| 80 | |
Brian Salomon | ff168d9 | 2018-06-23 15:17:27 -0400 | [diff] [blame] | 81 | void onDraw(const GrPrimitiveProcessor& primProc, |
| 82 | const GrPipeline& pipeline, |
Brian Salomon | 4934890 | 2018-06-26 09:12:38 -0400 | [diff] [blame] | 83 | const GrPipeline::FixedDynamicState* fixedDynamicState, |
| 84 | const GrPipeline::DynamicStateArrays* dynamicStateArrays, |
Chris Dalton | 46983b7 | 2017-06-06 12:27:16 -0600 | [diff] [blame] | 85 | const GrMesh mesh[], |
Greg Daniel | 36a77ee | 2016-10-18 10:33:25 -0400 | [diff] [blame] | 86 | int meshCount, |
| 87 | const SkRect& bounds) override { |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 88 | fGpu->draw(fRenderTarget, fOrigin, primProc, pipeline, fixedDynamicState, |
| 89 | dynamicStateArrays, mesh, meshCount); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Brian Osman | 9a9baae | 2018-11-05 15:06:26 -0500 | [diff] [blame] | 92 | void onClear(const GrFixedClip& clip, const SkPMColor4f& color) override { |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 93 | fGpu->clear(clip, color, fRenderTarget, fOrigin); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Robert Phillips | 19e51dc | 2017-08-09 09:30:51 -0400 | [diff] [blame] | 96 | void onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) override { |
| 97 | fGpu->clearStencilClip(clip, insideStencilMask, fRenderTarget, fOrigin); |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Robert Phillips | 6b47c7d | 2017-08-29 07:24:09 -0400 | [diff] [blame] | 100 | GrGLGpu* fGpu; |
| 101 | GrGpuRTCommandBuffer::LoadAndStoreInfo fColorLoadAndStoreInfo; |
| 102 | GrGpuRTCommandBuffer::StencilLoadAndStoreInfo fStencilLoadAndStoreInfo; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 103 | |
Greg Daniel | 500d58b | 2017-08-24 15:59:33 -0400 | [diff] [blame] | 104 | typedef GrGpuRTCommandBuffer INHERITED; |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
| 107 | #endif |
| 108 | |