• 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 GrDawnTexture_DEFINED
9 #define GrDawnTexture_DEFINED
10 
11 #include "src/gpu/ganesh/GrTexture.h"
12 #include "webgpu/webgpu_cpp.h"
13 
14 class GrDawnGpu;
15 
16 class GrDawnTexture : public GrTexture {
17 public:
18     static sk_sp<GrDawnTexture> Make(GrDawnGpu*,
19                                      SkISize dimensions,
20                                      wgpu::TextureFormat format,
21                                      GrRenderable,
22                                      int sampleCnt,
23                                      skgpu::Budgeted,
24                                      int mipLevels,
25                                      GrMipmapStatus,
26                                      std::string_view label);
27 
28     static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, SkISize dimensions, GrRenderable,
29                                             int sampleCnt, GrWrapCacheable, GrIOType,
30                                             const GrDawnTextureInfo&, std::string_view label);
31 
32     ~GrDawnTexture() override;
33 
34     GrBackendTexture getBackendTexture() const override;
35     GrBackendFormat backendFormat() const override;
36 
textureParamsModified()37     void textureParamsModified() override {}
38 
texture()39     wgpu::Texture texture() const { return fInfo.fTexture; }
format()40     wgpu::TextureFormat format() const { return fInfo.fFormat; }
41 protected:
42     GrDawnTexture(GrDawnGpu*,
43                   SkISize dimensions,
44                   const GrDawnTextureInfo&,
45                   GrMipmapStatus,
46                   std::string_view label);
47 
48     GrDawnGpu* getDawnGpu() const;
49 
50     void onAbandon() override;
51     void onRelease() override;
52 
onStealBackendTexture(GrBackendTexture *,SkImage::BackendTextureReleaseProc *)53     bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override {
54         return false;
55     }
56 
57 private:
58     GrDawnTextureInfo        fInfo;
59 
onSetLabel()60     void onSetLabel() override{}
61 
62     using INHERITED = GrTexture;
63 };
64 
65 #endif
66