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" // NO_G3_REWRITE 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 const wgpu::TextureView&); 39 ~DawnTexture()40 ~DawnTexture() override {} 41 dawnTexture()42 const wgpu::Texture& dawnTexture() const { return fTexture; } sampleTextureView()43 const wgpu::TextureView& sampleTextureView() const { return fSampleTextureView; } renderTextureView()44 const wgpu::TextureView& renderTextureView() const { return fRenderTextureView; } 45 46 private: 47 DawnTexture(const DawnSharedContext*, 48 SkISize dimensions, 49 const TextureInfo&, 50 wgpu::Texture, 51 wgpu::TextureView sampleTextureView, 52 wgpu::TextureView renderTextureView, 53 Ownership, 54 skgpu::Budgeted); 55 56 void freeGpuData() override; 57 58 static std::pair<wgpu::TextureView, wgpu::TextureView> CreateTextureViews( 59 const wgpu::Texture& texture, const TextureInfo& info); 60 61 void setBackendLabel(char const* label) override; 62 63 wgpu::Texture fTexture; 64 wgpu::TextureView fSampleTextureView; 65 wgpu::TextureView fRenderTextureView; 66 }; 67 68 } // namespace skgpu::graphite 69 70 #endif // skgpu_graphite_DawnTexture_DEFINED 71