blob: 86beee78af7317f89b9e1acc36999f0f32ce215d [file] [log] [blame]
egdaniel066df7c2016-06-08 14:02:27 -07001/*
Robert Phillipsb0e93a22017-08-29 08:26:54 -04002 * 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 */
egdaniel066df7c2016-06-08 14:02:27 -07007
8#ifndef GrGLGpuCommandBuffer_DEFINED
9#define GrGLGpuCommandBuffer_DEFINED
10
11#include "GrGpuCommandBuffer.h"
12
Hal Canary466c7d62017-07-03 15:11:49 -040013#include "GrGLGpu.h"
14#include "GrGLRenderTarget.h"
Brian Salomon742e31d2016-12-07 17:06:19 -050015#include "GrOpFlushState.h"
egdaniel066df7c2016-06-08 14:02:27 -070016
Robert Phillips009e9af2017-06-15 14:01:04 -040017class GrGLGpu;
Greg Daniel65a09272016-10-12 09:47:22 -040018class GrGLRenderTarget;
19
Greg Daniel500d58b2017-08-24 15:59:33 -040020class GrGLGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer {
21public:
Robert Phillips5b5d84c2018-08-09 15:12:18 -040022 GrGLGpuTextureCommandBuffer(GrGLGpu* gpu) : fGpu(gpu) {}
Greg Daniel500d58b2017-08-24 15:59:33 -040023
Robert Phillipsb0e93a22017-08-29 08:26:54 -040024 void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
25 const SkIPoint& dstPoint) override {
26 fGpu->copySurface(fTexture, fOrigin, src, srcOrigin, srcRect, dstPoint);
Greg Daniel500d58b2017-08-24 15:59:33 -040027 }
28
29 void insertEventMarker(const char* msg) override {
30 fGpu->insertEventMarker(msg);
31 }
32
Robert Phillips5b5d84c2018-08-09 15:12:18 -040033 void reset() {
34 fTexture = nullptr;
35 }
36
Greg Daniel500d58b2017-08-24 15:59:33 -040037private:
Robert Phillipsb0e93a22017-08-29 08:26:54 -040038 GrGLGpu* fGpu;
Greg Daniel500d58b2017-08-24 15:59:33 -040039
40 typedef GrGpuTextureCommandBuffer INHERITED;
41};
42
43class GrGLGpuRTCommandBuffer : public GrGpuRTCommandBuffer {
egdaniel9cb63402016-06-23 08:37:05 -070044/**
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 */
egdaniel066df7c2016-06-08 14:02:27 -070049public:
Robert Phillips5b5d84c2018-08-09 15:12:18 -040050 GrGLGpuRTCommandBuffer(GrGLGpu* gpu) : fGpu(gpu) {}
egdaniel066df7c2016-06-08 14:02:27 -070051
Robert Phillipscb2e2352017-08-30 16:44:40 -040052 void begin() override;
egdaniel066df7c2016-06-08 14:02:27 -070053 void end() override {}
54
Robert Phillips19e51dc2017-08-09 09:30:51 -040055 void discard() override { }
egdaniel066df7c2016-06-08 14:02:27 -070056
Robert Phillips19e51dc2017-08-09 09:30:51 -040057 void insertEventMarker(const char* msg) override {
Robert Phillips65a88fa2017-08-08 08:36:22 -040058 fGpu->insertEventMarker(msg);
59 }
60
Brian Salomon943ed792017-10-30 09:37:55 -040061 void inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override {
Greg Daniel77b53f62016-10-18 11:48:51 -040062 state->doUpload(upload);
63 }
64
Robert Phillipsb0e93a22017-08-29 08:26:54 -040065 void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
66 const SkIPoint& dstPoint) override {
67 fGpu->copySurface(fRenderTarget, fOrigin, src, srcOrigin, srcRect, dstPoint);
Greg Daniel500d58b2017-08-24 15:59:33 -040068 }
69
Robert Phillips5b5d84c2018-08-09 15:12:18 -040070 void set(GrRenderTarget*, GrSurfaceOrigin,
71 const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
72 const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&);
73
74 void reset() {
75 fRenderTarget = nullptr;
76 }
Greg Daniel500d58b2017-08-24 15:59:33 -040077
egdaniel066df7c2016-06-08 14:02:27 -070078private:
egdaniel9cb63402016-06-23 08:37:05 -070079 GrGpu* gpu() override { return fGpu; }
80
Brian Salomonff168d92018-06-23 15:17:27 -040081 void onDraw(const GrPrimitiveProcessor& primProc,
82 const GrPipeline& pipeline,
Brian Salomon49348902018-06-26 09:12:38 -040083 const GrPipeline::FixedDynamicState* fixedDynamicState,
84 const GrPipeline::DynamicStateArrays* dynamicStateArrays,
Chris Dalton46983b72017-06-06 12:27:16 -060085 const GrMesh mesh[],
Greg Daniel36a77ee2016-10-18 10:33:25 -040086 int meshCount,
87 const SkRect& bounds) override {
Robert Phillipsd0fe8752019-01-31 14:13:59 -050088 fGpu->draw(fRenderTarget, fOrigin, primProc, pipeline, fixedDynamicState,
89 dynamicStateArrays, mesh, meshCount);
egdaniel9cb63402016-06-23 08:37:05 -070090 }
91
Brian Osman9a9baae2018-11-05 15:06:26 -050092 void onClear(const GrFixedClip& clip, const SkPMColor4f& color) override {
Robert Phillips19e51dc2017-08-09 09:30:51 -040093 fGpu->clear(clip, color, fRenderTarget, fOrigin);
egdaniel9cb63402016-06-23 08:37:05 -070094 }
95
Robert Phillips19e51dc2017-08-09 09:30:51 -040096 void onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) override {
97 fGpu->clearStencilClip(clip, insideStencilMask, fRenderTarget, fOrigin);
egdaniel9cb63402016-06-23 08:37:05 -070098 }
99
Robert Phillips6b47c7d2017-08-29 07:24:09 -0400100 GrGLGpu* fGpu;
101 GrGpuRTCommandBuffer::LoadAndStoreInfo fColorLoadAndStoreInfo;
102 GrGpuRTCommandBuffer::StencilLoadAndStoreInfo fStencilLoadAndStoreInfo;
egdaniel066df7c2016-06-08 14:02:27 -0700103
Greg Daniel500d58b2017-08-24 15:59:33 -0400104 typedef GrGpuRTCommandBuffer INHERITED;
egdaniel066df7c2016-06-08 14:02:27 -0700105};
106
107#endif
108