Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
GrSurfaceProxy Class Referenceabstract

#include <GrSurfaceProxy.h>

Inheritance diagram for GrSurfaceProxy:
SkNVRefCnt< GrSurfaceProxy > GrMockSurfaceProxy GrRenderTargetProxy GrTextureProxy GrTextureRenderTargetProxy GrTextureRenderTargetProxy

Classes

struct  LazyCallbackResult
 
struct  LazySurfaceDesc
 
class  UniqueID
 

Public Types

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 &)>
 

Public Member Functions

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
 
virtual bool instantiate (GrResourceProvider *)=0
 
void deinstantiate ()
 
bool canSkipResourceAllocator () const
 
virtual GrTextureProxyasTextureProxy ()
 
virtual const GrTextureProxyasTextureProxy () const
 
virtual GrRenderTargetProxyasRenderTargetProxy ()
 
virtual const GrRenderTargetProxyasRenderTargetProxy () const
 
virtual const skgpu::UniqueKeygetUniqueKey () 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 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)
 

Protected Member Functions

 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
 
virtual sk_sp< GrSurfacecreateSurface (GrResourceProvider *) const =0
 
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

sk_sp< GrSurfacefTarget
 
GrInternalSurfaceFlags fSurfaceFlags
 

Private Member Functions

 SkDEBUGCODE (void validateSurface(const GrSurface *);) SkDEBUGCODE(virtual void onValidateSurface(const GrSurface *)=0
 
 SkDEBUGCODE (size_t getRawGpuMemorySize_debugOnly() const { return fGpuMemorySize;}) virtual size_t onUninstantiatedGpuMemorySize() const =0
 
virtual LazySurfaceDesc callbackDesc () const =0
 

Friends

class GrSurfaceProxyPriv
 

Detailed Description

Definition at line 49 of file GrSurfaceProxy.h.

Member Typedef Documentation

◆ LazyInstantiateCallback

Definition at line 121 of file GrSurfaceProxy.h.

Member Enumeration Documentation

◆ LazyInstantiationKeyMode

Some lazy proxy callbacks want to set their own (or no key) on the GrSurfaces they return. Others want the GrSurface's key to be kept in sync with the proxy's key. This enum controls the key relationship between proxies and their targets.

Enumerator
kUnsynced 

Don't key the GrSurface with the proxy's key. The lazy instantiation callback is free to return a GrSurface that already has a unique key unrelated to the proxy's key.

kSynced 

Keep the GrSurface's unique key in sync with the proxy's unique key. The GrSurface returned from the lazy instantiation callback must not have a unique key or have the same same unique key as the proxy. If the proxy is later assigned a key it is in turn assigned to the GrSurface.

Definition at line 68 of file GrSurfaceProxy.h.

68 {
69 /**
70 * Don't key the GrSurface with the proxy's key. The lazy instantiation callback is free to
71 * return a GrSurface that already has a unique key unrelated to the proxy's key.
72 */
74 /**
75 * Keep the GrSurface's unique key in sync with the proxy's unique key. The GrSurface
76 * returned from the lazy instantiation callback must not have a unique key or have the same
77 * same unique key as the proxy. If the proxy is later assigned a key it is in turn assigned
78 * to the GrSurface.
79 */
81 };

◆ RectsMustMatch

enum class GrSurfaceProxy::RectsMustMatch : bool
strong
Enumerator
kNo 
kYes 

Definition at line 324 of file GrSurfaceProxy.h.

324 : bool {
325 kNo = false,
326 kYes = true
327 };

◆ ResolveFlags

enum class GrSurfaceProxy::ResolveFlags
strong

Indicates "resolutions" that need to be done on a surface before its pixels can be accessed. If both types of resolve are requested, the MSAA resolve will happen first.

Enumerator
kNone 
kMSAA 
kMipMaps 

Definition at line 57 of file GrSurfaceProxy.h.

57 {
58 kNone = 0,
59 kMSAA = 1 << 0, // Blit and resolve an internal MSAA render buffer into the texture.
60 kMipMaps = 1 << 1, // Regenerate all mipmap levels.
61 };

◆ UseAllocator

enum class GrSurfaceProxy::UseAllocator
strong
Enumerator
kNo 

This proxy will be instantiated outside the allocator (e.g. for proxies that are instantiated in on-flush callbacks).

kYes 

GrResourceAllocator should instantiate this proxy.

Definition at line 124 of file GrSurfaceProxy.h.

124 {
125 /**
126 * This proxy will be instantiated outside the allocator (e.g. for proxies that are
127 * instantiated in on-flush callbacks).
128 */
129 kNo = false,
130 /**
131 * GrResourceAllocator should instantiate this proxy.
132 */
133 kYes = true,
134 };

Constructor & Destructor Documentation

◆ ~GrSurfaceProxy()

GrSurfaceProxy::~GrSurfaceProxy ( )
virtual

Definition at line 123 of file GrSurfaceProxy.cpp.

123 {
124}

◆ GrSurfaceProxy() [1/3]

GrSurfaceProxy::GrSurfaceProxy ( const GrBackendFormat format,
SkISize  dimensions,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
GrProtected  isProtected,
GrInternalSurfaceFlags  surfaceFlags,
UseAllocator  useAllocator,
std::string_view  label 
)
protected

Definition at line 60 of file GrSurfaceProxy.cpp.

68 : fSurfaceFlags(surfaceFlags)
69 , fFormat(format)
70 , fDimensions(dimensions)
71 , fFit(fit)
72 , fBudgeted(budgeted)
73 , fUseAllocator(useAllocator)
74 , fIsProtected(isProtected)
75 , fLabel(label) {
76 SkASSERT(fFormat.isValid());
77 SkASSERT(is_valid_non_lazy(dimensions));
78}
#define SkASSERT(cond)
Definition SkAssert.h:116
bool isValid() const
GrProtected isProtected() const
SkISize dimensions() const
GrInternalSurfaceFlags fSurfaceFlags
uint32_t uint32_t * format

◆ GrSurfaceProxy() [2/3]

GrSurfaceProxy::GrSurfaceProxy ( LazyInstantiateCallback &&  callback,
const GrBackendFormat format,
SkISize  dimensions,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
GrProtected  isProtected,
GrInternalSurfaceFlags  surfaceFlags,
UseAllocator  useAllocator,
std::string_view  label 
)
protected

Definition at line 81 of file GrSurfaceProxy.cpp.

90 : fSurfaceFlags(surfaceFlags)
91 , fFormat(format)
92 , fDimensions(dimensions)
93 , fFit(fit)
94 , fBudgeted(budgeted)
95 , fUseAllocator(useAllocator)
96 , fLazyInstantiateCallback(std::move(callback))
97 , fIsProtected(isProtected)
98 , fLabel(label) {
99 SkASSERT(fFormat.isValid());
100 SkASSERT(fLazyInstantiateCallback);
101 SkASSERT(is_valid_lazy(dimensions, fit));
102}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ GrSurfaceProxy() [3/3]

GrSurfaceProxy::GrSurfaceProxy ( sk_sp< GrSurface surface,
SkBackingFit  fit,
UseAllocator  useAllocator 
)
protected

Definition at line 105 of file GrSurfaceProxy.cpp.

108 : fTarget(std::move(surface))
110 , fFormat(fTarget->backendFormat())
111 , fDimensions(fTarget->dimensions())
112 , fFit(fit)
115 : skgpu::Budgeted::kNo)
116 , fUseAllocator(useAllocator)
117 , fUniqueID(fTarget->uniqueID()) // Note: converting from unique resource ID to a proxy ID!
118 , fIsProtected(fTarget->isProtected() ? GrProtected::kYes : GrProtected::kNo)
119 , fLabel(fTarget->getLabel()) {
120 SkASSERT(fFormat.isValid());
121}
GrBudgetedType budgetedType() const
ResourcePriv resourcePriv()
std::string_view getLabel() const
sk_sp< GrSurface > fTarget
UniqueID uniqueID() const
virtual GrBackendFormat backendFormat() const =0
SkISize dimensions() const
Definition GrSurface.h:27
GrInternalSurfaceFlags flags() const
Definition GrSurface.h:68
VkSurfaceKHR surface
Definition main.cc:49
Budgeted
Definition GpuTypes.h:35
Protected
Definition GpuTypes.h:61

Member Function Documentation

◆ asRenderTargetProxy() [1/2]

virtual GrRenderTargetProxy * GrSurfaceProxy::asRenderTargetProxy ( )
inlinevirtual
Returns
the render target proxy associated with the surface proxy, may be NULL.

Reimplemented in GrRenderTargetProxy.

Definition at line 250 of file GrSurfaceProxy.h.

250{ return nullptr; }

◆ asRenderTargetProxy() [2/2]

virtual const GrRenderTargetProxy * GrSurfaceProxy::asRenderTargetProxy ( ) const
inlinevirtual

Reimplemented in GrRenderTargetProxy.

Definition at line 251 of file GrSurfaceProxy.h.

251{ return nullptr; }

◆ assign()

void GrSurfaceProxy::assign ( sk_sp< GrSurface surface)
protected

Definition at line 176 of file GrSurfaceProxy.cpp.

176 {
178
179 SkDEBUGCODE(this->validateSurface(surface.get());)
180
181 fTarget = std::move(surface);
182
183#ifdef SK_DEBUG
184 if (this->asRenderTargetProxy()) {
186 }
187
188 // In order to give DDL users some flexibility in the destination of there DDLs,
189 // a DDL's target proxy can be more conservative (and thus require less memory)
190 // than the actual GrSurface used to fulfill it.
191 if (!this->isDDLTarget() && kInvalidGpuMemorySize != this->getRawGpuMemorySize_debugOnly()) {
192 // TODO(11373): Can this check be exact?
193 SkASSERT(fTarget->gpuMemorySize() <= this->getRawGpuMemorySize_debugOnly());
194 }
195#endif
196}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
size_t gpuMemorySize() const
virtual GrRenderTargetProxy * asRenderTargetProxy()
bool isDDLTarget() const
virtual GrRenderTarget * asRenderTarget()
Definition GrSurface.h:65

◆ asTextureProxy() [1/2]

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

Reimplemented in GrTextureProxy.

Definition at line 244 of file GrSurfaceProxy.h.

244{ return nullptr; }

◆ asTextureProxy() [2/2]

virtual const GrTextureProxy * GrSurfaceProxy::asTextureProxy ( ) const
inlinevirtual

Reimplemented in GrTextureProxy.

Definition at line 245 of file GrSurfaceProxy.h.

245{ return nullptr; }

◆ backendFormat()

const GrBackendFormat & GrSurfaceProxy::backendFormat ( ) const
inline

Definition at line 173 of file GrSurfaceProxy.h.

173{ return fFormat; }

◆ backingStoreBoundsIRect()

SkIRect GrSurfaceProxy::backingStoreBoundsIRect ( ) const
inline

Definition at line 169 of file GrSurfaceProxy.h.

169 {
171 }
SkISize backingStoreDimensions() const
static constexpr SkIRect MakeSize(const SkISize &size)
Definition SkRect.h:66

◆ backingStoreBoundsRect()

SkRect GrSurfaceProxy::backingStoreBoundsRect ( ) const
inline

Helper that gets the dimensions the backing GrSurface will have as a bounding rectangle.

Definition at line 165 of file GrSurfaceProxy.h.

165 {
166 return SkRect::Make(this->backingStoreDimensions());
167 }
static SkRect Make(const SkISize &size)
Definition SkRect.h:669

◆ backingStoreDimensions()

SkISize GrSurfaceProxy::backingStoreDimensions ( ) const

Definition at line 252 of file GrSurfaceProxy.cpp.

252 {
253 SkASSERT(!this->isFullyLazy());
254 if (fTarget) {
255 return fTarget->dimensions();
256 }
257
258 if (SkBackingFit::kExact == fFit) {
259 return fDimensions;
260 }
261 return skgpu::GetApproxSize(fDimensions);
262}
bool isFullyLazy() const
SkISize GetApproxSize(SkISize size)

◆ callbackDesc()

virtual LazySurfaceDesc GrSurfaceProxy::callbackDesc ( ) const
privatepure virtual

◆ canSkipResourceAllocator()

bool GrSurfaceProxy::canSkipResourceAllocator ( ) const

Proxies that are already instantiated and whose backing surface cannot be recycled to instantiate other proxies do not need to be considered by GrResourceAllocator.

Definition at line 161 of file GrSurfaceProxy.cpp.

161 {
162 if (fUseAllocator == UseAllocator::kNo) {
163 // Usually an atlas or onFlush proxy
164 return true;
165 }
166
167 auto peek = this->peekSurface();
168 if (!peek) {
169 return false;
170 }
171 // If this resource is already allocated and not recyclable then the resource allocator does
172 // not need to do anything with it.
173 return !peek->resourcePriv().getScratchKey().isValid();
174}
GrSurface * peekSurface() const

◆ computeScratchKey()

void GrSurfaceProxy::computeScratchKey ( const GrCaps caps,
skgpu::ScratchKey key 
) const
protected

Definition at line 233 of file GrSurfaceProxy.cpp.

233 {
234 SkASSERT(!this->isFullyLazy());
235 GrRenderable renderable = GrRenderable::kNo;
236 int sampleCount = 1;
237 if (const auto* rtp = this->asRenderTargetProxy()) {
238 renderable = GrRenderable::kYes;
239 sampleCount = rtp->numSamples();
240 }
241
242 const GrTextureProxy* tp = this->asTextureProxy();
243 skgpu::Mipmapped mipmapped = skgpu::Mipmapped::kNo;
244 if (tp) {
245 mipmapped = tp->mipmapped();
246 }
247
249 renderable, sampleCount, mipmapped, fIsProtected, key);
250}
const GrBackendFormat & backendFormat() const
virtual GrTextureProxy * asTextureProxy()
skgpu::Mipmapped mipmapped() const
static void ComputeScratchKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, skgpu::ScratchKey *key)
Renderable
Definition GpuTypes.h:69
Mipmapped
Definition GpuTypes.h:53

◆ Copy() [1/2]

sk_sp< GrSurfaceProxy > GrSurfaceProxy::Copy ( GrRecordingContext context,
sk_sp< GrSurfaceProxy src,
GrSurfaceOrigin  origin,
skgpu::Mipmapped  mipmapped,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
std::string_view  label,
sk_sp< GrRenderTask > *  outTask = nullptr 
)
static

Definition at line 359 of file GrSurfaceProxy.cpp.

366 {
367 SkASSERT(!src->isFullyLazy());
368 auto rect = SkIRect::MakeSize(src->dimensions());
369 return Copy(context,
370 std::move(src),
371 origin,
372 mipmapped,
373 rect,
374 fit,
375 budgeted,
376 label,
378 outTask);
379}
static sk_sp< GrSurfaceProxy > Copy(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)
sk_sp< SkBlender > blender SkRect rect
Definition SkRecords.h:350

◆ Copy() [2/2]

sk_sp< GrSurfaceProxy > GrSurfaceProxy::Copy ( GrRecordingContext rContext,
sk_sp< GrSurfaceProxy src,
GrSurfaceOrigin  origin,
skgpu::Mipmapped  mipmapped,
SkIRect  srcRect,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
std::string_view  label,
RectsMustMatch  rectsMustMatch = RectsMustMatch::kNo,
sk_sp< GrRenderTask > *  outTask = nullptr 
)
static

Definition at line 282 of file GrSurfaceProxy.cpp.

291 {
292 SkASSERT(!src->isFullyLazy());
293 int width;
294 int height;
295
296 SkIPoint dstPoint;
297 if (rectsMustMatch == RectsMustMatch::kYes) {
298 width = src->width();
299 height = src->height();
300 dstPoint = {srcRect.fLeft, srcRect.fTop};
301 } else {
302 width = srcRect.width();
303 height = srcRect.height();
304 dstPoint = {0, 0};
305 }
306
307 if (!srcRect.intersect(SkIRect::MakeSize(src->dimensions()))) {
308 return {};
309 }
310 auto format = src->backendFormat().makeTexture2D();
311 SkASSERT(format.isValid());
312
313 if (src->backendFormat().textureType() != GrTextureType::kExternal) {
315 auto dstContext = rContext->priv().makeSC(info,
316 format,
317 label,
318 fit,
319 origin,
320 GrRenderable::kNo,
321 1,
322 mipmapped,
323 src->isProtected(),
324 budgeted);
325 sk_sp<GrRenderTask> copyTask;
326 if (dstContext && (copyTask = dstContext->copy(src, srcRect, dstPoint))) {
327 if (outTask) {
328 *outTask = std::move(copyTask);
329 }
330 return dstContext->asSurfaceProxyRef();
331 }
332 }
333 if (src->asTextureProxy()) {
334 auto dstContext = rContext->priv().makeSFC(kUnknown_SkAlphaType,
335 nullptr,
336 {width, height},
337 fit,
338 format,
339 1,
340 mipmapped,
341 src->isProtected(),
344 origin,
345 budgeted,
346 label);
347 GrSurfaceProxyView view(std::move(src), origin, skgpu::Swizzle::RGBA());
348 if (dstContext && dstContext->blitTexture(std::move(view), srcRect, dstPoint)) {
349 if (outTask) {
350 *outTask = dstContext->refRenderTask();
351 }
352 return dstContext->asSurfaceProxyRef();
353 }
354 }
355 // Can't use backend copies or draws.
356 return nullptr;
357}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
std::unique_ptr< skgpu::ganesh::SurfaceContext > makeSC(GrSurfaceProxyView readView, const GrColorInfo &)
std::unique_ptr< skgpu::ganesh::SurfaceFillContext > makeSFC(GrImageInfo, std::string_view label, SkBackingFit=SkBackingFit::kExact, int sampleCount=1, skgpu::Mipmapped=skgpu::Mipmapped::kNo, skgpu::Protected=skgpu::Protected::kNo, GrSurfaceOrigin=kTopLeft_GrSurfaceOrigin, skgpu::Budgeted=skgpu::Budgeted::kYes)
GrRecordingContextPriv priv()
int width() const
int height() const
static constexpr Swizzle RGBA()
Definition Swizzle.h:66
bool intersect(const SkIRect &r)
Definition SkRect.h:513
constexpr int32_t height() const
Definition SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
constexpr int32_t width() const
Definition SkRect.h:158
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33

◆ createSurface()

virtual sk_sp< GrSurface > GrSurfaceProxy::createSurface ( GrResourceProvider ) const
protectedpure virtual

◆ createSurfaceImpl()

sk_sp< GrSurface > GrSurfaceProxy::createSurfaceImpl ( GrResourceProvider resourceProvider,
int  sampleCnt,
GrRenderable  renderable,
skgpu::Mipmapped  mipmapped 
) const
protected

Definition at line 126 of file GrSurfaceProxy.cpp.

129 {
130 SkASSERT(mipmapped == skgpu::Mipmapped::kNo || fFit == SkBackingFit::kExact);
131 SkASSERT(!this->isLazy());
133
135 if (SkBackingFit::kApprox == fFit) {
136 surface = resourceProvider->createApproxTexture(fDimensions,
137 fFormat,
138 fFormat.textureType(),
139 renderable,
140 sampleCnt,
141 fIsProtected,
142 fLabel);
143 } else {
144 surface = resourceProvider->createTexture(fDimensions,
145 fFormat,
146 fFormat.textureType(),
147 renderable,
148 sampleCnt,
149 mipmapped,
150 fBudgeted,
151 fIsProtected,
152 fLabel);
153 }
154 if (!surface) {
155 return nullptr;
156 }
157
158 return surface;
159}
GrTextureType textureType() const
sk_sp< GrTexture > createApproxTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Protected isProtected, std::string_view label)
sk_sp< GrTexture > createTexture(SkISize dimensions, const GrBackendFormat &format, GrTextureType textureType, skgpu::Renderable renderable, int renderTargetSampleCnt, skgpu::Mipmapped mipmapped, skgpu::Budgeted budgeted, skgpu::Protected isProtected, std::string_view label)
bool isLazy() const

◆ deinstantiate()

void GrSurfaceProxy::deinstantiate ( )

Definition at line 228 of file GrSurfaceProxy.cpp.

228 {
229 SkASSERT(this->isInstantiated());
230 fTarget = nullptr;
231}
bool isInstantiated() const

◆ dimensions()

SkISize GrSurfaceProxy::dimensions ( ) const
inline

Definition at line 145 of file GrSurfaceProxy.h.

145 {
146 SkASSERT(!this->isFullyLazy());
147 return fDimensions;
148 }

◆ framebufferOnly()

bool GrSurfaceProxy::framebufferOnly ( ) const
inline

Definition at line 292 of file GrSurfaceProxy.h.

◆ getBoundsRect()

SkRect GrSurfaceProxy::getBoundsRect ( ) const
inline

Helper that gets the width and height of the proxy as a bounding rectangle.

Definition at line 157 of file GrSurfaceProxy.h.

157{ return SkRect::Make(this->dimensions()); }

◆ getLabel()

std::string_view GrSurfaceProxy::getLabel ( ) const
inline

Definition at line 322 of file GrSurfaceProxy.h.

322{ return fLabel; }

◆ getTaskTargetCount()

int GrSurfaceProxy::getTaskTargetCount ( ) const
inline

How many render tasks has this proxy been the target of?

Definition at line 266 of file GrSurfaceProxy.h.

266{ return fTaskTargetCount; }

◆ getUniqueKey()

virtual const skgpu::UniqueKey & GrSurfaceProxy::getUniqueKey ( ) const
inlinevirtual
Returns
The unique key for this proxy. May be invalid.

Reimplemented in GrTextureProxy.

Definition at line 254 of file GrSurfaceProxy.h.

254 {
255 // Base class never has a valid unique key.
256 static const skgpu::UniqueKey kInvalidKey;
257 return kInvalidKey;
258 }

◆ gpuMemorySize()

size_t GrSurfaceProxy::gpuMemorySize ( ) const
inline

Retrieves the amount of GPU memory that will be or currently is used by this resource in bytes. It is approximate since we aren't aware of additional padding or copies made by the driver.

Returns
the amount of GPU memory used in bytes

Definition at line 313 of file GrSurfaceProxy.h.

313 {
314 SkASSERT(!this->isFullyLazy());
315 if (kInvalidGpuMemorySize == fGpuMemorySize) {
316 fGpuMemorySize = this->onUninstantiatedGpuMemorySize();
317 SkASSERT(kInvalidGpuMemorySize != fGpuMemorySize);
318 }
319 return fGpuMemorySize;
320 }

◆ height()

int GrSurfaceProxy::height ( ) const
inline

Definition at line 150 of file GrSurfaceProxy.h.

150{ return this->dimensions().height(); }
constexpr int32_t height() const
Definition SkSize.h:37

◆ ignoredByResourceAllocator()

bool GrSurfaceProxy::ignoredByResourceAllocator ( ) const
inlineprotected

Definition at line 415 of file GrSurfaceProxy.h.

415{ return fIgnoredByResourceAllocator; }

◆ instantiate()

virtual bool GrSurfaceProxy::instantiate ( GrResourceProvider )
pure virtual

◆ instantiateImpl()

bool GrSurfaceProxy::instantiateImpl ( GrResourceProvider resourceProvider,
int  sampleCnt,
GrRenderable  renderable,
skgpu::Mipmapped  mipmapped,
const skgpu::UniqueKey uniqueKey 
)
protected

Definition at line 198 of file GrSurfaceProxy.cpp.

202 {
203 SkASSERT(!this->isLazy());
204 if (fTarget) {
205 if (uniqueKey && uniqueKey->isValid()) {
206 SkASSERT(fTarget->getUniqueKey().isValid() && fTarget->getUniqueKey() == *uniqueKey);
207 }
208 return true;
209 }
210
211 sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, sampleCnt, renderable,
212 mipmapped);
213 if (!surface) {
214 return false;
215 }
216
217 // If there was an invalidation message pending for this key, we might have just processed it,
218 // causing the key (stored on this proxy) to become invalid.
219 if (uniqueKey && uniqueKey->isValid()) {
220 resourceProvider->assignUniqueKeyToResource(*uniqueKey, surface.get());
221 }
222
223 this->assign(std::move(surface));
224
225 return true;
226}
const skgpu::UniqueKey & getUniqueKey() const
void assignUniqueKeyToResource(const skgpu::UniqueKey &, GrGpuResource *)
void assign(sk_sp< GrSurface > surface)
sk_sp< GrSurface > createSurfaceImpl(GrResourceProvider *, int sampleCnt, GrRenderable, skgpu::Mipmapped) const
bool isValid() const
Definition ResourceKey.h:55

◆ isBudgeted()

skgpu::Budgeted GrSurfaceProxy::isBudgeted ( ) const
inline

Does the resource count against the resource budget?

Definition at line 284 of file GrSurfaceProxy.h.

284{ return fBudgeted; }

◆ isDDLTarget()

bool GrSurfaceProxy::isDDLTarget ( ) const
inline

Definition at line 379 of file GrSurfaceProxy.h.

379{ return fIsDDLTarget; }

◆ isFormatCompressed()

bool GrSurfaceProxy::isFormatCompressed ( const GrCaps caps) const

Definition at line 270 of file GrSurfaceProxy.cpp.

270 {
271 return caps->isFormatCompressed(this->backendFormat());
272}
bool isFormatCompressed(const GrBackendFormat &format) const
Definition GrCaps.cpp:457

◆ isFullyLazy()

bool GrSurfaceProxy::isFullyLazy ( ) const
inline

Definition at line 138 of file GrSurfaceProxy.h.

138 {
139 bool result = fDimensions.width() < 0;
140 SkASSERT(result == (fDimensions.height() < 0));
141 SkASSERT(!result || this->isLazy());
142 return result;
143 }
GAsyncResult * result
constexpr int32_t width() const
Definition SkSize.h:36

◆ isFunctionallyExact()

bool GrSurfaceProxy::isFunctionallyExact ( ) const

Definition at line 264 of file GrSurfaceProxy.cpp.

264 {
265 SkASSERT(!this->isFullyLazy());
266 return fFit == SkBackingFit::kExact ||
267 fDimensions == skgpu::GetApproxSize(fDimensions);
268}

◆ isInstantiated()

bool GrSurfaceProxy::isInstantiated ( ) const
inline

Definition at line 260 of file GrSurfaceProxy.h.

260{ return SkToBool(fTarget); }
static constexpr bool SkToBool(const T &x)
Definition SkTo.h:35

◆ isLazy()

bool GrSurfaceProxy::isLazy ( ) const
inline

Definition at line 136 of file GrSurfaceProxy.h.

136{ return !this->isInstantiated() && SkToBool(fLazyInstantiateCallback); }

◆ isPromiseProxy()

bool GrSurfaceProxy::isPromiseProxy ( )
inline

Definition at line 383 of file GrSurfaceProxy.h.

383{ return fIsPromiseProxy; }

◆ isProtected()

GrProtected GrSurfaceProxy::isProtected ( ) const
inline

Definition at line 381 of file GrSurfaceProxy.h.

381{ return fIsProtected; }

◆ isUsedAsTaskTarget()

void GrSurfaceProxy::isUsedAsTaskTarget ( )
inline

Called when this task becomes a target of a GrRenderTask.

Definition at line 263 of file GrSurfaceProxy.h.

263{ ++fTaskTargetCount; }

◆ peekRenderTarget()

GrRenderTarget * GrSurfaceProxy::peekRenderTarget ( ) const
inline

Definition at line 277 of file GrSurfaceProxy.h.

277 {
278 return fTarget ? fTarget->asRenderTarget() : nullptr;
279 }

◆ peekSurface()

GrSurface * GrSurfaceProxy::peekSurface ( ) const
inline

Definition at line 269 of file GrSurfaceProxy.h.

269{ return fTarget.get(); }
T * get() const
Definition SkRefCnt.h:303

◆ peekTexture()

GrTexture * GrSurfaceProxy::peekTexture ( ) const
inline

Definition at line 273 of file GrSurfaceProxy.h.

273{ return fTarget ? fTarget->asTexture() : nullptr; }
virtual GrTexture * asTexture()
Definition GrSurface.h:59

◆ priv() [1/2]

GrSurfaceProxyPriv GrSurfaceProxy::priv ( )
inline

Definition at line 62 of file GrSurfaceProxyPriv.h.

62{ return GrSurfaceProxyPriv(this); }
friend class GrSurfaceProxyPriv

◆ priv() [2/2]

const GrSurfaceProxyPriv GrSurfaceProxy::priv ( ) const
inline

Definition at line 64 of file GrSurfaceProxyPriv.h.

64 { // NOLINT(readability-const-return-type)
65 return GrSurfaceProxyPriv(const_cast<GrSurfaceProxy*>(this));
66}

◆ readOnly()

bool GrSurfaceProxy::readOnly ( ) const
inline

The pixel values of this proxy's surface cannot be modified (e.g. doesn't support write pixels or MIP map level regen). Read-only proxies also bypass interval tracking and assignment in GrResourceAllocator.

Definition at line 291 of file GrSurfaceProxy.h.

◆ requiresManualMSAAResolve()

bool GrSurfaceProxy::requiresManualMSAAResolve ( ) const
inline

This means surface is a multisampled render target, and internally holds a non-msaa texture for resolving into. The render target resolves itself by blitting into this internal texture. (asTexture() might or might not return the internal texture, but if it does, we always resolve the render target before accessing this texture's data.)

Definition at line 302 of file GrSurfaceProxy.h.

◆ setIgnoredByResourceAllocator()

void GrSurfaceProxy::setIgnoredByResourceAllocator ( )
inlineprotected

Definition at line 416 of file GrSurfaceProxy.h.

416{ fIgnoredByResourceAllocator = true; }

◆ setLazyDimensions()

void GrSurfaceProxy::setLazyDimensions ( SkISize  dimensions)
inlineprotected

Definition at line 432 of file GrSurfaceProxy.h.

432 {
433 SkASSERT(this->isFullyLazy());
434 SkASSERT(!dimensions.isEmpty());
435 fDimensions = dimensions;
436 }
bool isEmpty() const
Definition SkSize.h:31

◆ SkDEBUGCODE() [1/2]

GrSurfaceProxy::SkDEBUGCODE ( size_t getRawGpuMemorySize_debugOnly() const { return fGpuMemorySize;}  ) const
privatepure virtual

◆ SkDEBUGCODE() [2/2]

GrSurfaceProxy::SkDEBUGCODE ( void validateSurface(const GrSurface *);  ) const
privatepure virtual

◆ underlyingUniqueID()

UniqueID GrSurfaceProxy::underlyingUniqueID ( ) const
inline

Definition at line 223 of file GrSurfaceProxy.h.

223 {
224 if (fTarget) {
225 return UniqueID(fTarget->uniqueID());
226 }
227
228 return fUniqueID;
229 }
UniqueID uniqueID() const

◆ uniqueID()

UniqueID GrSurfaceProxy::uniqueID ( ) const
inline

Definition at line 221 of file GrSurfaceProxy.h.

221{ return fUniqueID; }

◆ width()

int GrSurfaceProxy::width ( ) const
inline

Definition at line 149 of file GrSurfaceProxy.h.

149{ return this->dimensions().width(); }

Friends And Related Symbol Documentation

◆ GrSurfaceProxyPriv

friend class GrSurfaceProxyPriv
friend

Definition at line 412 of file GrSurfaceProxy.h.

Member Data Documentation

◆ fSurfaceFlags

GrInternalSurfaceFlags GrSurfaceProxy::fSurfaceFlags
protected

Definition at line 454 of file GrSurfaceProxy.h.

◆ fTarget

sk_sp<GrSurface> GrSurfaceProxy::fTarget
protected

Definition at line 446 of file GrSurfaceProxy.h.


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