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