1 /* 2 * Copyright 2019 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 GrDawnRenderTarget_DEFINED 9 #define GrDawnRenderTarget_DEFINED 10 11 #include "include/gpu/dawn/GrDawnTypes.h" 12 #include "src/gpu/ganesh/GrRenderTarget.h" 13 14 class GrDawnGpu; 15 16 class GrDawnRenderTarget: public GrRenderTarget { 17 public: 18 static sk_sp<GrDawnRenderTarget> MakeWrapped(GrDawnGpu*, 19 SkISize dimensions, 20 int sampleCnt, 21 const GrDawnRenderTargetInfo&, 22 std::string_view label); 23 24 ~GrDawnRenderTarget() override; 25 canAttemptStencilAttachment(bool useMSAASurface)26 bool canAttemptStencilAttachment(bool useMSAASurface) const override { 27 SkASSERT(useMSAASurface == (this->numSamples() > 1)); 28 return true; 29 } 30 31 GrBackendRenderTarget getBackendRenderTarget() const override; 32 GrBackendFormat backendFormat() const override; textureView()33 wgpu::TextureView textureView() const { return fInfo.fTextureView; } 34 35 protected: 36 GrDawnRenderTarget(GrDawnGpu* gpu, 37 SkISize dimensions, 38 int sampleCnt, 39 const GrDawnRenderTargetInfo& info, 40 std::string_view label); 41 42 void onAbandon() override; 43 void onRelease() override; 44 45 // This accounts for the texture's memory and any MSAA renderbuffer's memory. 46 size_t onGpuMemorySize() const override; 47 onSetLabel()48 void onSetLabel() override{} 49 50 bool completeStencilAttachment(GrAttachment* stencil, bool useMSAASurface) override; 51 GrDawnRenderTargetInfo fInfo; 52 using INHERITED = GrRenderTarget; 53 }; 54 55 #endif 56