Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
 
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 sk_sp< TextureProxyMake (const Caps *, ResourceProvider *, SkISize dimensions, const TextureInfo &, 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 27 of file TextureProxy.h.

Member Typedef Documentation

◆ LazyInstantiateCallback

Definition at line 75 of file TextureProxy.h.

Constructor & Destructor Documentation

◆ TextureProxy()

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

◆ ~TextureProxy()

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

Definition at line 48 of file TextureProxy.cpp.

48{}

Member Function Documentation

◆ deinstantiate()

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

Definition at line 119 of file TextureProxy.cpp.

119 {
120 SkASSERT(fVolatile == Volatile::kYes && SkToBool(fLazyInstantiateCallback));
121
122 fTexture.reset();
123}
#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 50 of file TextureProxy.cpp.

50 {
51 SkASSERT(!this->isFullyLazy() || this->isInstantiated());
52 return this->isInstantiated() ? fTexture->dimensions() : fDimensions;
53}

◆ instantiate()

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

Definition at line 80 of file TextureProxy.cpp.

80 {
81 SkASSERT(!this->isLazy());
82
83 if (fTexture) {
84 return true;
85 }
86
87 fTexture = resourceProvider->findOrCreateScratchTexture(fDimensions, fInfo, fBudgeted);
88 if (!fTexture) {
89 return false;
90 }
91 SkDEBUGCODE(this->validateTexture(fTexture.get()));
92 return true;
93}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23

◆ InstantiateIfNotLazy()

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

Definition at line 110 of file TextureProxy.cpp.

111 {
112 if (textureProxy->isLazy()) {
113 return true;
114 }
115
116 return textureProxy->instantiate(resourceProvider);
117}

◆ isFullyLazy()

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

Definition at line 59 of file TextureProxy.cpp.

59 {
60 bool result = fDimensions.width() < 0;
61 SkASSERT(result == (fDimensions.height() < 0));
62 SkASSERT(!result || this->isLazy());
63 return result;
64}
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 62 of file TextureProxy.h.

62{ return SkToBool(fTexture); }

◆ isLazy()

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

Definition at line 55 of file TextureProxy.cpp.

55 {
56 return SkToBool(fLazyInstantiateCallback);
57}

◆ isProtected()

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

Definition at line 72 of file TextureProxy.cpp.

72 {
73 return fInfo.isProtected() == Protected::kYes;
74}
Protected isProtected() const
Definition TextureInfo.h:80

◆ isVolatile()

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

Definition at line 66 of file TextureProxy.cpp.

66 {
67 SkASSERT(fVolatile == Volatile::kNo || SkToBool(fLazyInstantiateCallback));
68
69 return fVolatile == Volatile::kYes;
70}

◆ lazyInstantiate()

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

Definition at line 95 of file TextureProxy.cpp.

95 {
96 SkASSERT(this->isLazy());
97
98 if (fTexture) {
99 return true;
100 }
101
102 fTexture = fLazyInstantiateCallback(resourceProvider);
103 if (!fTexture) {
104 return false;
105 }
106 SkDEBUGCODE(this->validateTexture(fTexture.get()));
107 return true;
108}

◆ Make()

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

Definition at line 133 of file TextureProxy.cpp.

137 {
138 if (dimensions.width() < 1 || dimensions.height() < 1 ||
139 dimensions.width() > caps->maxTextureSize() ||
140 dimensions.height() > caps->maxTextureSize() ||
141 !textureInfo.isValid()) {
142 return nullptr;
143 }
144
146 if (budgeted == Budgeted::kNo) {
147 // Instantiate immediately to avoid races later on if the client starts to use the wrapping
148 // object on multiple threads.
149 if (!proxy->instantiate(resourceProvider)) {
150 return nullptr;
151 }
152 }
153 return proxy;
154}
const TextureInfo & textureInfo() const

◆ MakeFullyLazy()

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

Definition at line 173 of file TextureProxy.cpp.

176 {
178
180 SkISize::Make(-1, -1), textureInfo, budgeted, isVolatile, std::move(callback)));
181}
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 156 of file TextureProxy.cpp.

161 {
163 if (dimensions.width() < 1 || dimensions.height() < 1 ||
164 dimensions.width() > caps->maxTextureSize() ||
165 dimensions.height() > caps->maxTextureSize()) {
166 return nullptr;
167 }
168
170 isVolatile, std::move(callback)));
171}

◆ mipmapped()

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

Definition at line 34 of file TextureProxy.h.

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

◆ numSamples()

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

Definition at line 33 of file TextureProxy.h.

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

◆ refTexture()

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

Definition at line 125 of file TextureProxy.cpp.

125 {
126 return fTexture;
127}

◆ texture() [1/2]

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

Definition at line 66 of file TextureProxy.h.

66{ return fTexture.get(); }

◆ texture() [2/2]

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

Definition at line 129 of file TextureProxy.cpp.

129 {
130 return fTexture.get();
131}

◆ textureInfo()

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

Definition at line 37 of file TextureProxy.h.

37{ return fInfo; }

◆ uninstantiatedGpuMemorySize()

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

Definition at line 76 of file TextureProxy.cpp.

76 {
77 return ComputeSize(fDimensions, fInfo);
78}
size_t ComputeSize(SkISize dimensions, const TextureInfo &info)

◆ Wrap()

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

Definition at line 183 of file TextureProxy.cpp.

183 {
184 return sk_sp<TextureProxy>(new TextureProxy(std::move(texture)));
185}
const Texture * texture() const

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