blob: 0ec79c6f59791c6f8e68a7882c2dd6760c0637f1 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrGpuCommandBuffer.h"
egdaniel066df7c2016-06-08 14:02:27 -070012
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "src/gpu/GrOpFlushState.h"
14#include "src/gpu/gl/GrGLGpu.h"
15#include "src/gpu/gl/GrGLRenderTarget.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
Greg Daniel46cfbc62019-06-07 11:43:30 -040024 void copy(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override {
25 fGpu->copySurface(fTexture, src, srcRect, dstPoint);
Greg Daniel500d58b2017-08-24 15:59:33 -040026 }
27
Brian Salomonab32f652019-05-10 14:24:50 -040028 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 Daniel500d58b2017-08-24 15:59:33 -040034 void insertEventMarker(const char* msg) override {
35 fGpu->insertEventMarker(msg);
36 }
37
Robert Phillips5b5d84c2018-08-09 15:12:18 -040038 void reset() {
39 fTexture = nullptr;
40 }
41
Greg Daniel500d58b2017-08-24 15:59:33 -040042private:
Robert Phillipsb0e93a22017-08-29 08:26:54 -040043 GrGLGpu* fGpu;
Greg Daniel500d58b2017-08-24 15:59:33 -040044
45 typedef GrGpuTextureCommandBuffer INHERITED;
46};
47
48class GrGLGpuRTCommandBuffer : public GrGpuRTCommandBuffer {
egdaniel9cb63402016-06-23 08:37:05 -070049/**
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 */
egdaniel066df7c2016-06-08 14:02:27 -070054public:
Robert Phillips5b5d84c2018-08-09 15:12:18 -040055 GrGLGpuRTCommandBuffer(GrGLGpu* gpu) : fGpu(gpu) {}
egdaniel066df7c2016-06-08 14:02:27 -070056
Michael Ludwig6e17f1d2019-05-15 14:00:20 +000057 void begin() override;
58 void end() override {}
egdaniel066df7c2016-06-08 14:02:27 -070059
Robert Phillips19e51dc2017-08-09 09:30:51 -040060 void discard() override { }
egdaniel066df7c2016-06-08 14:02:27 -070061
Robert Phillips19e51dc2017-08-09 09:30:51 -040062 void insertEventMarker(const char* msg) override {
Robert Phillips65a88fa2017-08-08 08:36:22 -040063 fGpu->insertEventMarker(msg);
64 }
65
Brian Salomon943ed792017-10-30 09:37:55 -040066 void inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override {
Greg Daniel77b53f62016-10-18 11:48:51 -040067 state->doUpload(upload);
68 }
69
Greg Daniel46cfbc62019-06-07 11:43:30 -040070 void copy(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) override {
71 fGpu->copySurface(fRenderTarget, src,srcRect, dstPoint);
Greg Daniel500d58b2017-08-24 15:59:33 -040072 }
73
Brian Salomonab32f652019-05-10 14:24:50 -040074 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 Ludwig6e17f1d2019-05-15 14:00:20 +000080 void set(GrRenderTarget*, GrSurfaceOrigin,
81 const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
82 const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&);
Robert Phillips5b5d84c2018-08-09 15:12:18 -040083
84 void reset() {
85 fRenderTarget = nullptr;
86 }
Greg Daniel500d58b2017-08-24 15:59:33 -040087
egdaniel066df7c2016-06-08 14:02:27 -070088private:
egdaniel9cb63402016-06-23 08:37:05 -070089 GrGpu* gpu() override { return fGpu; }
90
Brian Salomonff168d92018-06-23 15:17:27 -040091 void onDraw(const GrPrimitiveProcessor& primProc,
92 const GrPipeline& pipeline,
Brian Salomon49348902018-06-26 09:12:38 -040093 const GrPipeline::FixedDynamicState* fixedDynamicState,
94 const GrPipeline::DynamicStateArrays* dynamicStateArrays,
Chris Dalton46983b72017-06-06 12:27:16 -060095 const GrMesh mesh[],
Greg Daniel36a77ee2016-10-18 10:33:25 -040096 int meshCount,
97 const SkRect& bounds) override {
Robert Phillipsd0fe8752019-01-31 14:13:59 -050098 fGpu->draw(fRenderTarget, fOrigin, primProc, pipeline, fixedDynamicState,
99 dynamicStateArrays, mesh, meshCount);
egdaniel9cb63402016-06-23 08:37:05 -0700100 }
101
Brian Osman9a9baae2018-11-05 15:06:26 -0500102 void onClear(const GrFixedClip& clip, const SkPMColor4f& color) override {
Robert Phillips19e51dc2017-08-09 09:30:51 -0400103 fGpu->clear(clip, color, fRenderTarget, fOrigin);
egdaniel9cb63402016-06-23 08:37:05 -0700104 }
105
Robert Phillips19e51dc2017-08-09 09:30:51 -0400106 void onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) override {
107 fGpu->clearStencilClip(clip, insideStencilMask, fRenderTarget, fOrigin);
egdaniel9cb63402016-06-23 08:37:05 -0700108 }
109
Robert Phillips6b47c7d2017-08-29 07:24:09 -0400110 GrGLGpu* fGpu;
111 GrGpuRTCommandBuffer::LoadAndStoreInfo fColorLoadAndStoreInfo;
112 GrGpuRTCommandBuffer::StencilLoadAndStoreInfo fStencilLoadAndStoreInfo;
egdaniel066df7c2016-06-08 14:02:27 -0700113
Greg Daniel500d58b2017-08-24 15:59:33 -0400114 typedef GrGpuRTCommandBuffer INHERITED;
egdaniel066df7c2016-06-08 14:02:27 -0700115};
116
117#endif
118