blob: af74ead4ac4e6a02157e99a59cec83a7e31d02f4 [file] [log] [blame]
Timothy Liange70604e2018-07-19 09:49:46 -04001/*
2 * Copyright 2018 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 */
7
8#ifndef GrMtlGpuCommandBuffer_DEFINED
9#define GrMtlGpuCommandBuffer_DEFINED
10
11#include "GrGpuCommandBuffer.h"
Timothy Liang7ac582e2018-08-06 09:47:23 -040012#include "GrMtlGpu.h"
Timothy Liange70604e2018-07-19 09:49:46 -040013
Timothy Liang7ac582e2018-08-06 09:47:23 -040014#import <metal/metal.h>
15
Timothy Liange70604e2018-07-19 09:49:46 -040016class GrMtlRenderTarget;
17
18class GrMtlGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer {
19public:
20 GrMtlGpuTextureCommandBuffer(GrMtlGpu* gpu, GrTexture* texture, GrSurfaceOrigin origin)
21 : INHERITED(texture, origin)
22 , fGpu(gpu) {
Timothy Liange70604e2018-07-19 09:49:46 -040023 }
24
25 ~GrMtlGpuTextureCommandBuffer() override {}
26
27 void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
Timothy Liange35055f2018-07-20 16:53:00 -040028 const SkIPoint& dstPoint) override {
29 fGpu->copySurface(fTexture, fOrigin, src, srcOrigin, srcRect, dstPoint);
30 }
Timothy Liange70604e2018-07-19 09:49:46 -040031
32 void insertEventMarker(const char* msg) override {}
33
34private:
35 void submit() override {}
36
37 GrMtlGpu* fGpu;
38
39 typedef GrGpuTextureCommandBuffer INHERITED;
40};
41
42class GrMtlGpuRTCommandBuffer : public GrGpuRTCommandBuffer {
43public:
44 GrMtlGpuRTCommandBuffer(GrMtlGpu* gpu, GrRenderTarget* rt, GrSurfaceOrigin origin,
45 const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
46 const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo)
47 : INHERITED(rt, origin)
48 , fGpu(gpu)
49 , fColorLoadAndStoreInfo(colorInfo)
50 , fStencilLoadAndStoreInfo(stencilInfo) {
51 // Silence unused var warning
52 (void)fColorLoadAndStoreInfo;
53 (void)fStencilLoadAndStoreInfo;
54 }
55
56 ~GrMtlGpuRTCommandBuffer() override {}
57
58 void begin() override {}
59 void end() override {}
60
61 void discard() override {}
62
63 void insertEventMarker(const char* msg) override {}
64
65 void inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override {}
66
67 void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect,
Timothy Liange35055f2018-07-20 16:53:00 -040068 const SkIPoint& dstPoint) override {
69 fGpu->copySurface(fRenderTarget, fOrigin, src, srcOrigin, srcRect, dstPoint);
70 }
Timothy Liange70604e2018-07-19 09:49:46 -040071
72 void submit() override {}
73
74private:
75 GrGpu* gpu() override { return fGpu; }
76
77 void onDraw(const GrPrimitiveProcessor& primProc,
78 const GrPipeline& pipeline,
79 const GrPipeline::FixedDynamicState* fixedDynamicState,
80 const GrPipeline::DynamicStateArrays* dynamicStateArrays,
81 const GrMesh mesh[],
82 int meshCount,
83 const SkRect& bounds) override {}
84
85 void onClear(const GrFixedClip& clip, GrColor color) override {}
86
87 void onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) override {}
88
89 GrMtlGpu* fGpu;
90 GrGpuRTCommandBuffer::LoadAndStoreInfo fColorLoadAndStoreInfo;
91 GrGpuRTCommandBuffer::StencilLoadAndStoreInfo fStencilLoadAndStoreInfo;
92
93 typedef GrGpuRTCommandBuffer INHERITED;
94};
95
96#endif
97