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