Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::DawnTexture Class Reference

#include <DawnTexture.h>

Inheritance diagram for skgpu::graphite::DawnTexture:
skgpu::graphite::Texture skgpu::graphite::Resource

Public Member Functions

 ~DawnTexture () override
 
const wgpu::Texture & dawnTexture () const
 
const wgpu::TextureView & sampleTextureView () const
 
const wgpu::TextureView & renderTextureView () const
 
- Public Member Functions inherited from skgpu::graphite::Texture
 ~Texture () override
 
int numSamples () const
 
Mipmapped mipmapped () const
 
SkISize dimensions () const
 
const TextureInfotextureInfo () const
 
void setReleaseCallback (sk_sp< RefCntedCallback >)
 
const char * getResourceType () const override
 
- Public Member Functions inherited from skgpu::graphite::Resource
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
Resourceoperator= (const Resource &)=delete
 
Resourceoperator= (Resource &&)=delete
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
Ownership ownership () const
 
skgpu::Budgeted budgeted () const
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
virtual const char * getResourceType () const =0
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
bool wasDestroyed () const
 
const GraphiteResourceKeykey () const
 
void setKey (const GraphiteResourceKey &key)
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual void prepareForReturnToCache (const std::function< void()> &takeRef)
 

Static Public Member Functions

static wgpu::Texture MakeDawnTexture (const DawnSharedContext *, SkISize dimensions, const TextureInfo &)
 
static sk_sp< TextureMake (const DawnSharedContext *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted)
 
static sk_sp< TextureMakeWrapped (const DawnSharedContext *, SkISize dimensions, const TextureInfo &, wgpu::Texture)
 
static sk_sp< TextureMakeWrapped (const DawnSharedContext *, SkISize dimensions, const TextureInfo &, const wgpu::TextureView &)
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::graphite::Texture
 Texture (const SharedContext *, SkISize dimensions, const TextureInfo &info, sk_sp< MutableTextureState > mutableState, Ownership, skgpu::Budgeted)
 
MutableTextureStatemutableState () const
 
void invokeReleaseProc () override
 
void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const override
 
- Protected Member Functions inherited from skgpu::graphite::Resource
 Resource (const SharedContext *, Ownership, skgpu::Budgeted, size_t gpuMemorySize, bool commandBufferRefsAsUsageRefs=false)
 
virtual ~Resource ()
 
const SharedContextsharedContext () const
 
virtual void onDumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump, const char *dumpName) const
 
void setDeleteASAP ()
 

Detailed Description

Definition at line 19 of file DawnTexture.h.

Constructor & Destructor Documentation

◆ ~DawnTexture()

skgpu::graphite::DawnTexture::~DawnTexture ( )
inlineoverride

Definition at line 40 of file DawnTexture.h.

40{}

Member Function Documentation

◆ dawnTexture()

const wgpu::Texture & skgpu::graphite::DawnTexture::dawnTexture ( ) const
inline

Definition at line 42 of file DawnTexture.h.

42{ return fTexture; }

◆ Make()

sk_sp< Texture > skgpu::graphite::DawnTexture::Make ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
skgpu::Budgeted  budgeted 
)
static

Definition at line 131 of file DawnTexture.cpp.

134 {
136 if (!texture) {
137 return {};
138 }
139 auto [sampleTextureView, renderTextureView] = CreateTextureViews(texture, info);
140 return sk_sp<Texture>(new DawnTexture(sharedContext,
142 info,
143 std::move(texture),
144 std::move(sampleTextureView),
145 std::move(renderTextureView),
147 budgeted));
148}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static wgpu::Texture MakeDawnTexture(const DawnSharedContext *, SkISize dimensions, const TextureInfo &)
Definition: DawnTexture.cpp:22
const wgpu::TextureView & renderTextureView() const
Definition: DawnTexture.h:44
const wgpu::TextureView & sampleTextureView() const
Definition: DawnTexture.h:43
skgpu::Budgeted budgeted() const
Definition: Resource.h:100
const SharedContext * sharedContext() const
Definition: Resource.h:189
SkISize dimensions() const
Definition: Texture.h:31
FlTexture * texture

◆ MakeDawnTexture()

wgpu::Texture skgpu::graphite::DawnTexture::MakeDawnTexture ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info 
)
static

Definition at line 22 of file DawnTexture.cpp.

24 {
25 const Caps* caps = sharedContext->caps();
26 if (dimensions.width() > caps->maxTextureSize() ||
27 dimensions.height() > caps->maxTextureSize()) {
28 SKGPU_LOG_E("Texture creation failure: dimensions %d x %d too large.",
30 return {};
31 }
32
33 const DawnTextureSpec& dawnSpec = info.dawnTextureSpec();
34
35 if (dawnSpec.fUsage & wgpu::TextureUsage::TextureBinding && !caps->isTexturable(info)) {
36 return {};
37 }
38
39 if (dawnSpec.fUsage & wgpu::TextureUsage::RenderAttachment &&
40 !(caps->isRenderable(info) || DawnFormatIsDepthOrStencil(dawnSpec.fFormat))) {
41 return {};
42 }
43
44 if (dawnSpec.fUsage & wgpu::TextureUsage::StorageBinding && !caps->isStorage(info)) {
45 return {};
46 }
47
48 int numMipLevels = 1;
49 if (info.mipmapped() == Mipmapped::kYes) {
51 }
52
53 wgpu::TextureDescriptor desc;
54 desc.usage = dawnSpec.fUsage;
55 desc.dimension = wgpu::TextureDimension::e2D;
56 desc.size.width = dimensions.width();
57 desc.size.height = dimensions.height();
58 desc.size.depthOrArrayLayers = 1;
59 desc.format = dawnSpec.fFormat;
60 desc.mipLevelCount = numMipLevels;
61 desc.sampleCount = info.numSamples();
62 desc.viewFormatCount = 0;
63 desc.viewFormats = nullptr;
64
65 auto texture = sharedContext->device().CreateTexture(&desc);
66 if (!texture) {
67 return {};
68 }
69
70 return texture;
71}
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition: SkMipmap.cpp:134
const Caps * caps() const
Definition: SharedContext.h:39
bool DawnFormatIsDepthOrStencil(wgpu::TextureFormat format)
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ MakeWrapped() [1/2]

sk_sp< Texture > skgpu::graphite::DawnTexture::MakeWrapped ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
const wgpu::TextureView &  textureView 
)
static

Definition at line 170 of file DawnTexture.cpp.

173 {
174 if (!textureView) {
175 SKGPU_LOG_E("No valid texture view passed into MakeWrapped\n");
176 return {};
177 }
178 return sk_sp<Texture>(new DawnTexture(sharedContext,
180 info,
181 /*texture=*/nullptr,
182 /*sampleTextureView=*/textureView,
183 /*renderTextureView=*/textureView,
186}

◆ MakeWrapped() [2/2]

sk_sp< Texture > skgpu::graphite::DawnTexture::MakeWrapped ( const DawnSharedContext sharedContext,
SkISize  dimensions,
const TextureInfo info,
wgpu::Texture  texture 
)
static

Definition at line 150 of file DawnTexture.cpp.

153 {
154 if (!texture) {
155 SKGPU_LOG_E("No valid texture passed into MakeWrapped\n");
156 return {};
157 }
158
159 auto [sampleTextureView, renderTextureView] = CreateTextureViews(texture, info);
160 return sk_sp<Texture>(new DawnTexture(sharedContext,
162 info,
163 std::move(texture),
164 std::move(sampleTextureView),
165 std::move(renderTextureView),
168}

◆ renderTextureView()

const wgpu::TextureView & skgpu::graphite::DawnTexture::renderTextureView ( ) const
inline

Definition at line 44 of file DawnTexture.h.

44{ return fRenderTextureView; }

◆ sampleTextureView()

const wgpu::TextureView & skgpu::graphite::DawnTexture::sampleTextureView ( ) const
inline

Definition at line 43 of file DawnTexture.h.

43{ return fSampleTextureView; }

The documentation for this class was generated from the following files: