| 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 "include/gpu/graphite/dawn/DawnGraphiteTypes.h" |
| 13 |
#include "src/gpu/graphite/Texture.h" |
| 14 |
#include "src/gpu/graphite/TextureInfoPriv.h" |
| 15 |
|
| 16 |
#include "webgpu/webgpu_cpp.h" // NO_G3_REWRITE |
| 17 |
|
| 18 |
namespace skgpu::graphite { |
| 19 |
class DawnSharedContext; |
| 20 |
|
| 21 |
class DawnTexture : public Texture { |
| 22 |
public: |
| 23 |
static wgpu::Texture MakeDawnTexture(const DawnSharedContext*, |
| 24 |
SkISize dimensions, |
| 25 |
const TextureInfo&); |
| 26 |
|
| 27 |
static sk_sp<Texture> Make(const DawnSharedContext*, |
| 28 |
SkISize dimensions, |
| 29 |
const TextureInfo&); |
| 30 |
|
| 31 |
static sk_sp<Texture> MakeWrapped(const DawnSharedContext*, |
| 32 |
SkISize dimensions, |
| 33 |
const TextureInfo&, |
| 34 |
wgpu::Texture); |
| 35 |
|
| 36 |
static sk_sp<Texture> MakeWrapped(const DawnSharedContext*, |
| 37 |
SkISize dimensions, |
| 38 |
const TextureInfo&, |
| 39 |
const wgpu::TextureView&); |
| 40 |
|
| 41 |
~DawnTexture() override {} |
| 42 |
|
| 43 |
const wgpu::Texture& dawnTexture() const { return fTexture; } |
| 44 |
const wgpu::TextureView& sampleTextureView() const { return fSampleTextureView; } |
| 45 |
const wgpu::TextureView& renderTextureView() const { return fRenderTextureView; } |
| 46 |
|
| 47 |
const DawnTextureInfo& dawnTextureInfo() const { |
| 48 |
return TextureInfoPriv::Get<DawnTextureInfo>(this->textureInfo()); |
| 49 |
} |
| 50 |
|
| 51 |
private: |
| 52 |
DawnTexture(const DawnSharedContext*, |
| 53 |
SkISize dimensions, |
| 54 |
const TextureInfo&, |
| 55 |
wgpu::Texture, |
| 56 |
wgpu::TextureView sampleTextureView, |
| 57 |
wgpu::TextureView renderTextureView, |
| 58 |
Ownership); |
| 59 |
|
| 60 |
void freeGpuData() override; |
| 61 |
|
| 62 |
static std::pair<wgpu::TextureView, wgpu::TextureView> CreateTextureViews( |
| 63 |
const wgpu::Texture& texture, const TextureInfo& info); |
| 64 |
|
| 65 |
void setBackendLabel(char const* label) override; |
| 66 |
|
| 67 |
wgpu::Texture fTexture; |
| 68 |
wgpu::TextureView fSampleTextureView; |
| 69 |
wgpu::TextureView fRenderTextureView; |
| 70 |
}; |
| 71 |
|
| 72 |
} // namespace skgpu::graphite |
| 73 |
|
| 74 |
#endif // skgpu_graphite_DawnTexture_DEFINED |