Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
skgpu::graphite::TextureProxy Class Reference

#include <TextureProxy.h>

Inheritance diagram for skgpu::graphite::TextureProxy:
SkRefCnt SkRefCntBase

Public Types

using LazyInstantiateCallback = std::function< sk_sp< Texture >(ResourceProvider *)>
 

Public Member Functions

 TextureProxy ()=delete
 
 ~TextureProxy () override
 
int numSamples () const
 
Mipmapped mipmapped () const
 
SkISize dimensions () const
 
const TextureInfotextureInfo () const
 
const char * label () const
 
bool isLazy () const
 
bool isFullyLazy () const
 
bool isVolatile () const
 
bool isProtected () const
 
size_t uninstantiatedGpuMemorySize () const
 
bool instantiate (ResourceProvider *)
 
bool lazyInstantiate (ResourceProvider *)
 
bool isInstantiated () const
 
void deinstantiate ()
 
sk_sp< TexturerefTexture () const
 
const Texturetexture () const
 
Texturetexture ()
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static bool InstantiateIfNotLazy (ResourceProvider *, TextureProxy *)
 
static bool InstantiateIfNotLazy (ScratchResourceManager *, TextureProxy *)
 
static sk_sp< TextureProxyMake (const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, std::string_view label, skgpu::Budgeted)
 
static sk_sp< TextureProxyMakeLazy (const Caps *, SkISize dimensions, const TextureInfo &, skgpu::Budgeted, Volatile, LazyInstantiateCallback &&)
 
static sk_sp< TextureProxyMakeFullyLazy (const TextureInfo &, skgpu::Budgeted, Volatile, LazyInstantiateCallback &&)
 
static sk_sp< TextureProxyWrap (sk_sp< Texture >)
 

Detailed Description

Definition at line 28 of file TextureProxy.h.

Member Typedef Documentation

◆ LazyInstantiateCallback

Definition at line 92 of file TextureProxy.h.

Constructor & Destructor Documentation

◆ TextureProxy()

skgpu::graphite::TextureProxy::TextureProxy ( )
delete

◆ ~TextureProxy()

skgpu::graphite::TextureProxy::~TextureProxy ( )
override

Definition at line 57 of file TextureProxy.cpp.

57{}

Member Function Documentation

◆ deinstantiate()

void skgpu::graphite::TextureProxy::deinstantiate ( )

Definition at line 145 of file TextureProxy.cpp.

145 {
146 SkASSERT(fVolatile == Volatile::kYes && SkToBool(fLazyInstantiateCallback));
147
148 fTexture.reset();
149}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35

◆ dimensions()

SkISize skgpu::graphite::TextureProxy::dimensions ( ) const

Definition at line 59 of file TextureProxy.cpp.

59 {
60 SkASSERT(!this->isFullyLazy() || this->isInstantiated());
61 return this->isInstantiated() ? fTexture->dimensions() : fDimensions;
62}

◆ instantiate()

bool skgpu::graphite::TextureProxy::instantiate ( ResourceProvider resourceProvider)

Definition at line 89 of file TextureProxy.cpp.

89 {
90 SkASSERT(!this->isLazy());
91
92 if (fTexture) {
93 return true;
94 }
95
96 fTexture = resourceProvider->findOrCreateScratchTexture(fDimensions, fInfo, fLabel, fBudgeted);
97 if (!fTexture) {
98 return false;
99 }
100 SkDEBUGCODE(this->validateTexture(fTexture.get()));
101 return true;
102}
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()

◆ InstantiateIfNotLazy() [1/2]

bool skgpu::graphite::TextureProxy::InstantiateIfNotLazy ( ResourceProvider resourceProvider,
TextureProxy textureProxy 
)
static

Definition at line 119 of file TextureProxy.cpp.

120 {
121 if (textureProxy->isLazy()) {
122 return true;
123 }
124
125 return textureProxy->instantiate(resourceProvider);
126}

◆ InstantiateIfNotLazy() [2/2]

bool skgpu::graphite::TextureProxy::InstantiateIfNotLazy ( ScratchResourceManager scratchManager,
TextureProxy textureProxy 
)
static

Definition at line 128 of file TextureProxy.cpp.

129 {
130 if (textureProxy->isLazy() || textureProxy->isInstantiated()) {
131 return true;
132 }
133
134 textureProxy->fTexture = scratchManager->getScratchTexture(textureProxy->dimensions(),
135 textureProxy->textureInfo(),
136 textureProxy->fLabel);
137 if (!textureProxy->fTexture) {
138 return false;
139 }
140 SkDEBUGCODE(textureProxy->validateTexture(textureProxy->fTexture.get()));
141 return true;
142}

◆ isFullyLazy()

bool skgpu::graphite::TextureProxy::isFullyLazy ( ) const

Definition at line 68 of file TextureProxy.cpp.

68 {
69 bool result = fDimensions.width() < 0;
70 SkASSERT(result == (fDimensions.height() < 0));
71 SkASSERT(!result || this->isLazy());
72 return result;
73}
GAsyncResult * result
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ isInstantiated()

bool skgpu::graphite::TextureProxy::isInstantiated ( ) const
inline

Definition at line 78 of file TextureProxy.h.

78{ return SkToBool(fTexture); }

◆ isLazy()

bool skgpu::graphite::TextureProxy::isLazy ( ) const

Definition at line 64 of file TextureProxy.cpp.

64 {
65 return SkToBool(fLazyInstantiateCallback);
66}

◆ isProtected()

bool skgpu::graphite::TextureProxy::isProtected ( ) const

Definition at line 81 of file TextureProxy.cpp.

81 {
82 return fInfo.isProtected() == Protected::kYes;
83}
Protected isProtected() const
Definition: TextureInfo.h:80

◆ isVolatile()

bool skgpu::graphite::TextureProxy::isVolatile ( ) const

Definition at line 75 of file TextureProxy.cpp.

75 {
76 SkASSERT(fVolatile == Volatile::kNo || SkToBool(fLazyInstantiateCallback));
77
78 return fVolatile == Volatile::kYes;
79}

◆ label()

const char * skgpu::graphite::TextureProxy::label ( ) const
inline

Definition at line 40 of file TextureProxy.h.

40{ return fLabel.c_str(); }

◆ lazyInstantiate()

bool skgpu::graphite::TextureProxy::lazyInstantiate ( ResourceProvider resourceProvider)

Definition at line 104 of file TextureProxy.cpp.

104 {
105 SkASSERT(this->isLazy());
106
107 if (fTexture) {
108 return true;
109 }
110
111 fTexture = fLazyInstantiateCallback(resourceProvider);
112 if (!fTexture) {
113 return false;
114 }
115 SkDEBUGCODE(this->validateTexture(fTexture.get()));
116 return true;
117}

◆ Make()

sk_sp< TextureProxy > skgpu::graphite::TextureProxy::Make ( const Caps caps,
ResourceProvider resourceProvider,
SkISize  dimensions,
const TextureInfo textureInfo,
std::string_view  label,
skgpu::Budgeted  budgeted 
)
static

Definition at line 159 of file TextureProxy.cpp.

164 {
165 if (dimensions.width() < 1 || dimensions.height() < 1 ||
166 dimensions.width() > caps->maxTextureSize() ||
167 dimensions.height() > caps->maxTextureSize() ||
168 !textureInfo.isValid()) {
169 return nullptr;
170 }
171
174 std::move(label),
175 budgeted)};
176 if (budgeted == Budgeted::kNo) {
177 // Instantiate immediately to avoid races later on if the client starts to use the wrapping
178 // object on multiple threads.
179 if (!proxy->instantiate(resourceProvider)) {
180 return nullptr;
181 }
182 }
183 return proxy;
184}
const char * label() const
Definition: TextureProxy.h:40
const TextureInfo & textureInfo() const
Definition: TextureProxy.h:38

◆ MakeFullyLazy()

sk_sp< TextureProxy > skgpu::graphite::TextureProxy::MakeFullyLazy ( const TextureInfo textureInfo,
skgpu::Budgeted  budgeted,
Volatile  isVolatile,
LazyInstantiateCallback &&  callback 
)
static

Definition at line 206 of file TextureProxy.cpp.

209 {
211
214 budgeted,
216 std::move(callback)));
217}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ MakeLazy()

sk_sp< TextureProxy > skgpu::graphite::TextureProxy::MakeLazy ( const Caps caps,
SkISize  dimensions,
const TextureInfo textureInfo,
skgpu::Budgeted  budgeted,
Volatile  isVolatile,
LazyInstantiateCallback &&  callback 
)
static

Definition at line 186 of file TextureProxy.cpp.

191 {
193 if (dimensions.width() < 1 || dimensions.height() < 1 ||
194 dimensions.width() > caps->maxTextureSize() ||
195 dimensions.height() > caps->maxTextureSize()) {
196 return nullptr;
197 }
198
201 budgeted,
203 std::move(callback)));
204}

◆ mipmapped()

Mipmapped skgpu::graphite::TextureProxy::mipmapped ( ) const
inline

Definition at line 35 of file TextureProxy.h.

35{ return fInfo.mipmapped(); }
Mipmapped mipmapped() const
Definition: TextureInfo.h:79

◆ numSamples()

int skgpu::graphite::TextureProxy::numSamples ( ) const
inline

Definition at line 34 of file TextureProxy.h.

34{ return fInfo.numSamples(); }
uint32_t numSamples() const
Definition: TextureInfo.h:78

◆ refTexture()

sk_sp< Texture > skgpu::graphite::TextureProxy::refTexture ( ) const

Definition at line 151 of file TextureProxy.cpp.

151 {
152 return fTexture;
153}

◆ texture() [1/2]

Texture * skgpu::graphite::TextureProxy::texture ( )
inline

Definition at line 82 of file TextureProxy.h.

82{ return fTexture.get(); }

◆ texture() [2/2]

const Texture * skgpu::graphite::TextureProxy::texture ( ) const

Definition at line 155 of file TextureProxy.cpp.

155 {
156 return fTexture.get();
157}

◆ textureInfo()

const TextureInfo & skgpu::graphite::TextureProxy::textureInfo ( ) const
inline

Definition at line 38 of file TextureProxy.h.

38{ return fInfo; }

◆ uninstantiatedGpuMemorySize()

size_t skgpu::graphite::TextureProxy::uninstantiatedGpuMemorySize ( ) const

Definition at line 85 of file TextureProxy.cpp.

85 {
86 return ComputeSize(fDimensions, fInfo);
87}
size_t ComputeSize(SkISize dimensions, const TextureInfo &info)

◆ Wrap()

sk_sp< TextureProxy > skgpu::graphite::TextureProxy::Wrap ( sk_sp< Texture texture)
static

Definition at line 219 of file TextureProxy.cpp.

219 {
220 return sk_sp<TextureProxy>(new TextureProxy(std::move(texture)));
221}
const Texture * texture() const

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