Timothy Liang | e70604e | 2018-07-19 09:49:46 -0400 | [diff] [blame] | 1 | /* |
| 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 Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame^] | 12 | #include "GrMtlGpu.h" |
Timothy Liang | e70604e | 2018-07-19 09:49:46 -0400 | [diff] [blame] | 13 | |
Timothy Liang | 7ac582e | 2018-08-06 09:47:23 -0400 | [diff] [blame^] | 14 | #import <metal/metal.h> |
| 15 | |
Timothy Liang | e70604e | 2018-07-19 09:49:46 -0400 | [diff] [blame] | 16 | class GrMtlRenderTarget; |
| 17 | |
| 18 | class GrMtlGpuTextureCommandBuffer : public GrGpuTextureCommandBuffer { |
| 19 | public: |
| 20 | GrMtlGpuTextureCommandBuffer(GrMtlGpu* gpu, GrTexture* texture, GrSurfaceOrigin origin) |
| 21 | : INHERITED(texture, origin) |
| 22 | , fGpu(gpu) { |
Timothy Liang | e70604e | 2018-07-19 09:49:46 -0400 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | ~GrMtlGpuTextureCommandBuffer() override {} |
| 26 | |
| 27 | void copy(GrSurface* src, GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, |
Timothy Liang | e35055f | 2018-07-20 16:53:00 -0400 | [diff] [blame] | 28 | const SkIPoint& dstPoint) override { |
| 29 | fGpu->copySurface(fTexture, fOrigin, src, srcOrigin, srcRect, dstPoint); |
| 30 | } |
Timothy Liang | e70604e | 2018-07-19 09:49:46 -0400 | [diff] [blame] | 31 | |
| 32 | void insertEventMarker(const char* msg) override {} |
| 33 | |
| 34 | private: |
| 35 | void submit() override {} |
| 36 | |
| 37 | GrMtlGpu* fGpu; |
| 38 | |
| 39 | typedef GrGpuTextureCommandBuffer INHERITED; |
| 40 | }; |
| 41 | |
| 42 | class GrMtlGpuRTCommandBuffer : public GrGpuRTCommandBuffer { |
| 43 | public: |
| 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 Liang | e35055f | 2018-07-20 16:53:00 -0400 | [diff] [blame] | 68 | const SkIPoint& dstPoint) override { |
| 69 | fGpu->copySurface(fRenderTarget, fOrigin, src, srcOrigin, srcRect, dstPoint); |
| 70 | } |
Timothy Liang | e70604e | 2018-07-19 09:49:46 -0400 | [diff] [blame] | 71 | |
| 72 | void submit() override {} |
| 73 | |
| 74 | private: |
| 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 | |