• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
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 skgpu_graphite_DawnTexture_DEFINED
9 #define skgpu_graphite_DawnTexture_DEFINED
10 
11 #include "include/core/SkRefCnt.h"
12 #include "src/gpu/graphite/Texture.h"
13 
14 #include "webgpu/webgpu_cpp.h"
15 
16 namespace skgpu::graphite {
17 class DawnSharedContext;
18 
19 class DawnTexture : public Texture {
20 public:
21     static wgpu::Texture MakeDawnTexture(const DawnSharedContext*,
22                                          SkISize dimensions,
23                                          const TextureInfo&);
24 
25     static sk_sp<Texture> Make(const DawnSharedContext*,
26                                SkISize dimensions,
27                                const TextureInfo&,
28                                skgpu::Budgeted);
29 
30     static sk_sp<Texture> MakeWrapped(const DawnSharedContext*,
31                                       SkISize dimensions,
32                                       const TextureInfo&,
33                                       wgpu::Texture);
34 
35     static sk_sp<Texture> MakeWrapped(const DawnSharedContext*,
36                                       SkISize dimensions,
37                                       const TextureInfo&,
38                                       wgpu::TextureView);
39 
~DawnTexture()40     ~DawnTexture() override {}
41 
dawnTexture()42     const wgpu::Texture& dawnTexture() const { return fTexture; }
dawnTextureView()43     const wgpu::TextureView& dawnTextureView() const { return fTextureView; }
44 
45 private:
46     DawnTexture(const DawnSharedContext* sharedContext,
47                 SkISize dimensions,
48                 const TextureInfo& info,
49                 wgpu::Texture,
50                 wgpu::TextureView,
51                 Ownership,
52                 skgpu::Budgeted);
53 
54     void freeGpuData() override;
55 
56     wgpu::Texture     fTexture;
57     wgpu::TextureView fTextureView;
58 };
59 
60 } // namepsace skgpu::graphite
61 
62 #endif // skgpu_graphite_DawnTexture_DEFINED
63