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 GrDawnAttachment_DEFINED 9 #define GrDawnAttachment_DEFINED 10 11 #include "include/gpu/GrBackendSurface.h" 12 #include "src/gpu/ganesh/GrAttachment.h" 13 14 #include "webgpu/webgpu_cpp.h" 15 16 class GrDawnGpu; 17 18 class GrDawnAttachment : public GrAttachment { 19 public: 20 static sk_sp<GrDawnAttachment> MakeStencil(GrDawnGpu* gpu, SkISize dimensions, int sampleCnt); 21 22 ~GrDawnAttachment() override; view()23 wgpu::TextureView view() const { return fView; } backendFormat()24 GrBackendFormat backendFormat() const override { 25 return GrBackendFormat::MakeDawn(wgpu::TextureFormat::Depth24PlusStencil8); 26 } 27 28 protected: 29 void onRelease() override; 30 void onAbandon() override; 31 32 private: 33 GrDawnAttachment(GrDawnGpu* gpu, 34 SkISize dimensions, 35 UsageFlags supportedUsages, 36 int samples, 37 wgpu::Texture texture, 38 wgpu::TextureView view, 39 std::string_view label); 40 41 GrDawnGpu* getDawnGpu() const; 42 43 wgpu::Texture fTexture; 44 wgpu::TextureView fView; 45 46 using INHERITED = GrAttachment; 47 }; 48 49 #endif 50