Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Friends | List of all members
GrTextureProxy Class Reference

#include <GrTextureProxy.h>

Inheritance diagram for GrTextureProxy:
GrSurfaceProxy SkNVRefCnt< GrSurfaceProxy > GrTextureRenderTargetProxy

Classes

class  CacheAccess
 

Public Member Functions

GrTextureProxyasTextureProxy () override
 
const GrTextureProxyasTextureProxy () const override
 
bool instantiate (GrResourceProvider *) override
 
skgpu::Mipmapped mipmapped () const
 
bool mipmapsAreDirty () const
 
void markMipmapsDirty ()
 
void markMipmapsClean ()
 
skgpu::Mipmapped proxyMipmapped () const
 
GrTextureType textureType () const
 
bool hasRestrictedSampling () const
 
const skgpu::UniqueKeygetUniqueKey () const override
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
GrTextureProxyPriv texPriv ()
 
const GrTextureProxyPriv texPriv () const
 
 GrTextureProxy (const GrBackendFormat &, SkISize, skgpu::Mipmapped, GrMipmapStatus, SkBackingFit, skgpu::Budgeted, skgpu::Protected, GrInternalSurfaceFlags, UseAllocator, GrDDLProvider creatingProvider, std::string_view label)
 
 GrTextureProxy (LazyInstantiateCallback &&, const GrBackendFormat &, SkISize, skgpu::Mipmapped, GrMipmapStatus, SkBackingFit, skgpu::Budgeted, skgpu::Protected, GrInternalSurfaceFlags, UseAllocator, GrDDLProvider creatingProvider, std::string_view label)
 
 GrTextureProxy (sk_sp< GrSurface >, UseAllocator, GrDDLProvider creatingProvider)
 
 ~GrTextureProxy () override
 
sk_sp< GrSurfacecreateSurface (GrResourceProvider *) const override
 
void setTargetKeySync (bool sync)
 
- Public Member Functions inherited from GrSurfaceProxy
virtual ~GrSurfaceProxy ()
 
bool isLazy () const
 
bool isFullyLazy () const
 
SkISize dimensions () const
 
int width () const
 
int height () const
 
SkISize backingStoreDimensions () const
 
SkRect getBoundsRect () const
 
bool isFunctionallyExact () const
 
SkRect backingStoreBoundsRect () const
 
SkIRect backingStoreBoundsIRect () const
 
const GrBackendFormatbackendFormat () const
 
bool isFormatCompressed (const GrCaps *) const
 
UniqueID uniqueID () const
 
UniqueID underlyingUniqueID () const
 
void deinstantiate ()
 
bool canSkipResourceAllocator () const
 
virtual GrRenderTargetProxyasRenderTargetProxy ()
 
virtual const GrRenderTargetProxyasRenderTargetProxy () const
 
bool isInstantiated () const
 
void isUsedAsTaskTarget ()
 
int getTaskTargetCount () const
 
GrSurfacepeekSurface () const
 
GrTexturepeekTexture () const
 
GrRenderTargetpeekRenderTarget () const
 
skgpu::Budgeted isBudgeted () const
 
bool readOnly () const
 
bool framebufferOnly () const
 
bool requiresManualMSAAResolve () const
 
size_t gpuMemorySize () const
 
std::string_view getLabel () const
 
GrSurfaceProxyPriv priv ()
 
const GrSurfaceProxyPriv priv () const
 
bool isDDLTarget () const
 
GrProtected isProtected () const
 
bool isPromiseProxy ()
 
- Public Member Functions inherited from SkNVRefCnt< GrSurfaceProxy >
 SkNVRefCnt ()
 
 ~SkNVRefCnt ()
 
bool unique () const
 
void ref () const
 
void unref () const
 
void deref () const
 
bool refCntGreaterThan (int32_t threadIsolatedTestCnt) const
 

Static Public Member Functions

static bool ProxiesAreCompatibleAsDynamicState (const GrSurfaceProxy *first, const GrSurfaceProxy *second)
 
- Static Public Member Functions inherited from GrSurfaceProxy
static sk_sp< GrSurfaceProxyCopy (GrRecordingContext *, sk_sp< GrSurfaceProxy > src, GrSurfaceOrigin, skgpu::Mipmapped, SkIRect srcRect, SkBackingFit, skgpu::Budgeted, std::string_view label, RectsMustMatch=RectsMustMatch::kNo, sk_sp< GrRenderTask > *outTask=nullptr)
 
static sk_sp< GrSurfaceProxyCopy (GrRecordingContext *, sk_sp< GrSurfaceProxy > src, GrSurfaceOrigin, skgpu::Mipmapped, SkBackingFit, skgpu::Budgeted, std::string_view label, sk_sp< GrRenderTask > *outTask=nullptr)
 

Private Member Functions

LazySurfaceDesc callbackDesc () const override
 
size_t onUninstantiatedGpuMemorySize () const override
 

Friends

class(GrDDLProvider creatingProvider() const { return fCreatingProvider;}) protected GrProxyProvider
 
class GrTextureProxyPriv
 
class GrSurfaceProxyPriv
 

Additional Inherited Members

- Public Types inherited from GrSurfaceProxy
enum class  ResolveFlags { kNone = 0 , kMSAA = 1 << 0 , kMipMaps = 1 << 1 }
 
enum class  LazyInstantiationKeyMode { kUnsynced , kSynced }
 
enum class  UseAllocator { kNo = false , kYes = true }
 
enum class  RectsMustMatch : bool { kNo = false , kYes = true }
 
using LazyInstantiateCallback = std::function< LazyCallbackResult(GrResourceProvider *, const LazySurfaceDesc &)>
 
- Protected Member Functions inherited from GrSurfaceProxy
 GrSurfaceProxy (const GrBackendFormat &, SkISize, SkBackingFit, skgpu::Budgeted, GrProtected, GrInternalSurfaceFlags, UseAllocator, std::string_view label)
 
 GrSurfaceProxy (LazyInstantiateCallback &&, const GrBackendFormat &, SkISize, SkBackingFit, skgpu::Budgeted, GrProtected, GrInternalSurfaceFlags, UseAllocator, std::string_view label)
 
 GrSurfaceProxy (sk_sp< GrSurface >, SkBackingFit, UseAllocator)
 
bool ignoredByResourceAllocator () const
 
void setIgnoredByResourceAllocator ()
 
void computeScratchKey (const GrCaps &, skgpu::ScratchKey *) const
 
void assign (sk_sp< GrSurface > surface)
 
sk_sp< GrSurfacecreateSurfaceImpl (GrResourceProvider *, int sampleCnt, GrRenderable, skgpu::Mipmapped) const
 
void setLazyDimensions (SkISize dimensions)
 
bool instantiateImpl (GrResourceProvider *resourceProvider, int sampleCnt, GrRenderable, skgpu::Mipmapped, const skgpu::UniqueKey *)
 
- Protected Attributes inherited from GrSurfaceProxy
sk_sp< GrSurfacefTarget
 
GrInternalSurfaceFlags fSurfaceFlags
 

Detailed Description

Definition at line 34 of file GrTextureProxy.h.

Constructor & Destructor Documentation

◆ GrTextureProxy() [1/3]

GrTextureProxy::GrTextureProxy ( const GrBackendFormat format,
SkISize  dimensions,
skgpu::Mipmapped  mipmapped,
GrMipmapStatus  mipmapStatus,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
skgpu::Protected  isProtected,
GrInternalSurfaceFlags  surfaceFlags,
UseAllocator  useAllocator,
GrDDLProvider  creatingProvider,
std::string_view  label 
)

Definition at line 30 of file GrTextureProxy.cpp.

41 : INHERITED(
42 format, dimensions, fit, budgeted, isProtected, surfaceFlags, useAllocator, label)
43 , fMipmapped(mipmapped)
44 , fMipmapStatus(mipmapStatus) SkDEBUGCODE(, fInitialMipmapStatus(fMipmapStatus))
45 , fCreatingProvider(creatingProvider)
46 , fProxyProvider(nullptr)
47 , fDeferredUploader(nullptr) {
51 }
52}
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
#define INHERITED(method,...)
GrProtected isProtected() const
SkISize dimensions() const
GrInternalSurfaceFlags fSurfaceFlags
GrTextureType textureType() const
skgpu::Mipmapped mipmapped() const
uint32_t uint32_t * format

◆ GrTextureProxy() [2/3]

GrTextureProxy::GrTextureProxy ( LazyInstantiateCallback &&  callback,
const GrBackendFormat format,
SkISize  dimensions,
skgpu::Mipmapped  mipmapped,
GrMipmapStatus  mipmapStatus,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
skgpu::Protected  isProtected,
GrInternalSurfaceFlags  surfaceFlags,
UseAllocator  useAllocator,
GrDDLProvider  creatingProvider,
std::string_view  label 
)

Definition at line 55 of file GrTextureProxy.cpp.

67 : INHERITED(std::move(callback),
68 format,
70 fit,
71 budgeted,
73 surfaceFlags,
74 useAllocator,
75 label)
76 , fMipmapped(mipmapped)
77 , fMipmapStatus(mipmapStatus) SkDEBUGCODE(, fInitialMipmapStatus(fMipmapStatus))
78 , fCreatingProvider(creatingProvider)
79 , fProxyProvider(nullptr)
80 , fDeferredUploader(nullptr) {
84 }
85}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ GrTextureProxy() [3/3]

GrTextureProxy::GrTextureProxy ( sk_sp< GrSurface surf,
UseAllocator  useAllocator,
GrDDLProvider  creatingProvider 
)

Definition at line 88 of file GrTextureProxy.cpp.

91 : INHERITED(std::move(surf), SkBackingFit::kExact, useAllocator)
92 , fMipmapped(fTarget->asTexture()->mipmapped())
93 , fMipmapStatus(fTarget->asTexture()->mipmapStatus())
94 SkDEBUGCODE(, fInitialMipmapStatus(fMipmapStatus))
95 , fCreatingProvider(creatingProvider)
96 , fProxyProvider(nullptr)
97 , fDeferredUploader(nullptr) {
98 if (fTarget->getUniqueKey().isValid()) {
99 fProxyProvider = fTarget->asTexture()->getContext()->priv().proxyProvider();
100 fProxyProvider->adoptUniqueKeyFromSurface(this, fTarget.get());
101 }
102 if (this->textureType() == GrTextureType::kExternal) {
104 }
105}
GrDirectContextPriv priv()
const GrDirectContext * getContext() const
const skgpu::UniqueKey & getUniqueKey() const
void adoptUniqueKeyFromSurface(GrTextureProxy *proxy, const GrSurface *)
GrProxyProvider * proxyProvider()
sk_sp< GrSurface > fTarget
virtual GrTexture * asTexture()
Definition GrSurface.h:59
skgpu::Mipmapped mipmapped() const
Definition GrTexture.h:62
GrMipmapStatus mipmapStatus() const
Definition GrTexture.h:66
T * get() const
Definition SkRefCnt.h:303
bool isValid() const
Definition ResourceKey.h:55

◆ ~GrTextureProxy()

GrTextureProxy::~GrTextureProxy ( )
override

Definition at line 107 of file GrTextureProxy.cpp.

107 {
108 // Due to the order of cleanup the GrSurface this proxy may have wrapped may have gone away
109 // at this point. Zero out the pointer so the cache invalidation code doesn't try to use it.
110 fTarget = nullptr;
111
112 // In DDL-mode, uniquely keyed proxies keep their key even after their originating
113 // proxy provider has gone away. In that case there is noone to send the invalid key
114 // message to (Note: in this case we don't want to remove its cached resource).
115 if (fUniqueKey.isValid() && fProxyProvider) {
116 fProxyProvider->processInvalidUniqueKey(fUniqueKey, this,
118 } else {
119 SkASSERT(!fProxyProvider);
120 }
121}
void processInvalidUniqueKey(const skgpu::UniqueKey &, GrTextureProxy *, InvalidateGPUResource)

Member Function Documentation

◆ asTextureProxy() [1/2]

const GrTextureProxy * GrTextureProxy::asTextureProxy ( ) const
inlineoverridevirtual

Reimplemented from GrSurfaceProxy.

Definition at line 37 of file GrTextureProxy.h.

37{ return this; }

◆ asTextureProxy() [2/2]

GrTextureProxy * GrTextureProxy::asTextureProxy ( )
inlineoverridevirtual
Returns
the texture proxy associated with the surface proxy, may be NULL.

Reimplemented from GrSurfaceProxy.

Definition at line 36 of file GrTextureProxy.h.

36{ return this; }

◆ cacheAccess() [1/2]

GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess ( )
inline

Definition at line 39 of file GrTextureProxyCacheAccess.h.

39{ return CacheAccess(this); }

◆ cacheAccess() [2/2]

const GrTextureProxy::CacheAccess GrTextureProxy::cacheAccess ( ) const
inline

Definition at line 41 of file GrTextureProxyCacheAccess.h.

41 { // NOLINT(readability-const-return-type)
42 return CacheAccess(const_cast<GrTextureProxy*>(this));
43}

◆ callbackDesc()

GrSurfaceProxy::LazySurfaceDesc GrTextureProxy::callbackDesc ( ) const
overrideprivatevirtual

Implements GrSurfaceProxy.

Reimplemented in GrTextureRenderTargetProxy.

Definition at line 209 of file GrTextureProxy.cpp.

209 {
210 SkISize dims;
211 SkBackingFit fit;
212 if (this->isFullyLazy()) {
214 dims = {-1, -1};
215 } else {
217 dims = this->dimensions();
218 }
219 return {
220 dims,
221 fit,
222 GrRenderable::kNo,
223 fMipmapped,
224 1,
225 this->backendFormat(),
226 this->textureType(),
227 this->isProtected(),
228 this->isBudgeted(),
229 this->getLabel(),
230 };
231}
SkBackingFit
const GrBackendFormat & backendFormat() const
std::string_view getLabel() const
bool isFullyLazy() const
skgpu::Budgeted isBudgeted() const
bool isFunctionallyExact() const

◆ createSurface()

sk_sp< GrSurface > GrTextureProxy::createSurface ( GrResourceProvider resourceProvider) const
overridevirtual

Implements GrSurfaceProxy.

Reimplemented in GrTextureRenderTargetProxy.

Definition at line 137 of file GrTextureProxy.cpp.

137 {
138 sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, 1, GrRenderable::kNo,
139 fMipmapped);
140 if (!surface) {
141 return nullptr;
142 }
143
144 SkASSERT(!surface->asRenderTarget());
145 SkASSERT(surface->asTexture());
146 return surface;
147}
sk_sp< GrSurface > createSurfaceImpl(GrResourceProvider *, int sampleCnt, GrRenderable, skgpu::Mipmapped) const
VkSurfaceKHR surface
Definition main.cc:49

◆ getUniqueKey()

const skgpu::UniqueKey & GrTextureProxy::getUniqueKey ( ) const
inlineoverridevirtual

Return the texture proxy's unique key. It will be invalid if the proxy doesn't have one.

Reimplemented from GrSurfaceProxy.

Definition at line 84 of file GrTextureProxy.h.

84 {
85#ifdef SK_DEBUG
86 if (this->isInstantiated() && fUniqueKey.isValid() && fSyncTargetKey &&
87 fCreatingProvider == GrDDLProvider::kNo) {
88 GrSurface* surface = this->peekSurface();
89 SkASSERT(surface);
90
91 SkASSERT(surface->getUniqueKey().isValid());
92 // It is possible for a non-keyed proxy to have a uniquely keyed resource assigned to
93 // it. This just means that a future user of the resource will be filling it with unique
94 // data. However, if the proxy has a unique key its attached resource should also
95 // have that key.
96 SkASSERT(fUniqueKey == surface->getUniqueKey());
97 }
98#endif
99
100 return fUniqueKey;
101 }
GrSurface * peekSurface() const
bool isInstantiated() const

◆ hasRestrictedSampling()

bool GrTextureProxy::hasRestrictedSampling ( ) const
inline

If true then the texture does not support MIP maps and only supports clamp wrap mode.

Definition at line 70 of file GrTextureProxy.h.

70 {
72 }
static bool GrTextureTypeHasRestrictedSampling(GrTextureType type)

◆ instantiate()

bool GrTextureProxy::instantiate ( GrResourceProvider resourceProvider)
overridevirtual

Implements GrSurfaceProxy.

Reimplemented in GrTextureRenderTargetProxy.

Definition at line 123 of file GrTextureProxy.cpp.

123 {
124 if (this->isLazy()) {
125 return false;
126 }
127 if (!this->instantiateImpl(resourceProvider, 1, GrRenderable::kNo, fMipmapped,
128 fUniqueKey.isValid() ? &fUniqueKey : nullptr)) {
129 return false;
130 }
131
132 SkASSERT(!this->peekRenderTarget());
133 SkASSERT(this->peekTexture());
134 return true;
135}
bool instantiateImpl(GrResourceProvider *resourceProvider, int sampleCnt, GrRenderable, skgpu::Mipmapped, const skgpu::UniqueKey *)
bool isLazy() const
GrTexture * peekTexture() const
GrRenderTarget * peekRenderTarget() const

◆ markMipmapsClean()

void GrTextureProxy::markMipmapsClean ( )
inline

Definition at line 58 of file GrTextureProxy.h.

58 {
59 SkASSERT(skgpu::Mipmapped::kYes == fMipmapped);
60 fMipmapStatus = GrMipmapStatus::kValid;
61 }

◆ markMipmapsDirty()

void GrTextureProxy::markMipmapsDirty ( )
inline

Definition at line 54 of file GrTextureProxy.h.

54 {
55 SkASSERT(skgpu::Mipmapped::kYes == fMipmapped);
56 fMipmapStatus = GrMipmapStatus::kDirty;
57 }

◆ mipmapped()

skgpu::Mipmapped GrTextureProxy::mipmapped ( ) const

Definition at line 166 of file GrTextureProxy.cpp.

166 {
167 if (this->isInstantiated()) {
168 return this->peekTexture()->mipmapped();
169 }
170 return fMipmapped;
171}

◆ mipmapsAreDirty()

bool GrTextureProxy::mipmapsAreDirty ( ) const
inline

Definition at line 49 of file GrTextureProxy.h.

49 {
50 SkASSERT((skgpu::Mipmapped::kNo == fMipmapped) ==
51 (GrMipmapStatus::kNotAllocated == fMipmapStatus));
52 return skgpu::Mipmapped::kYes == fMipmapped && GrMipmapStatus::kValid != fMipmapStatus;
53 }

◆ onUninstantiatedGpuMemorySize()

size_t GrTextureProxy::onUninstantiatedGpuMemorySize ( ) const
overrideprivate

Definition at line 175 of file GrTextureProxy.cpp.

175 {
176 return GrSurface::ComputeSize(this->backendFormat(), this->dimensions(),
177 /*colorSamplesPerPixel=*/1, this->proxyMipmapped(),
178 !this->priv().isExact());
179}
GrSurfaceProxyPriv priv()
static size_t ComputeSize(const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
Definition GrSurface.cpp:21
skgpu::Mipmapped proxyMipmapped() const

◆ ProxiesAreCompatibleAsDynamicState()

bool GrTextureProxy::ProxiesAreCompatibleAsDynamicState ( const GrSurfaceProxy first,
const GrSurfaceProxy second 
)
static

Definition at line 181 of file GrTextureProxy.cpp.

182 {
183 // In order to be compatible, the proxies should also have the same texture type. This is
184 // checked explicitly since the GrBackendFormat == operator does not compare texture type
185 return first->backendFormat().textureType() == second->backendFormat().textureType() &&
186 first->backendFormat() == second->backendFormat();
187}
GrTextureType textureType() const

◆ proxyMipmapped()

skgpu::Mipmapped GrTextureProxy::proxyMipmapped ( ) const
inline

Definition at line 65 of file GrTextureProxy.h.

65{ return fMipmapped; }

◆ setTargetKeySync()

void GrTextureProxy::setTargetKeySync ( bool  sync)
inline

Definition at line 171 of file GrTextureProxy.h.

171{ fSyncTargetKey = sync; }

◆ texPriv() [1/2]

GrTextureProxyPriv GrTextureProxy::texPriv ( )
inline

Definition at line 44 of file GrTextureProxyPriv.h.

44{ return GrTextureProxyPriv(this); }
friend class GrTextureProxyPriv

◆ texPriv() [2/2]

const GrTextureProxyPriv GrTextureProxy::texPriv ( ) const
inline

Definition at line 46 of file GrTextureProxyPriv.h.

46 { // NOLINT(readability-const-return-type)
47 return GrTextureProxyPriv(const_cast<GrTextureProxy*>(this));
48}

◆ textureType()

GrTextureType GrTextureProxy::textureType ( ) const

Definition at line 173 of file GrTextureProxy.cpp.

173{ return this->backendFormat().textureType(); }

Friends And Related Symbol Documentation

◆ GrProxyProvider

friend class (GrDDLProvider creatingProvider() const { return fCreatingProvider; }) protected GrProxyProvider
friend

Definition at line 119 of file GrTextureProxy.h.

◆ GrSurfaceProxyPriv

friend class GrSurfaceProxyPriv
friend

Definition at line 121 of file GrTextureProxy.h.

◆ GrTextureProxyPriv

friend class GrTextureProxyPriv
friend

Definition at line 120 of file GrTextureProxy.h.


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