Flutter Engine
The Flutter Engine
Public Member Functions | Friends | List of all members
GrSurfaceProxyPriv Class Reference

#include <GrSurfaceProxyPriv.h>

Public Member Functions

void computeScratchKey (const GrCaps &caps, skgpu::ScratchKey *key) const
 
sk_sp< GrSurfacecreateSurface (GrResourceProvider *resourceProvider) const
 
void assign (sk_sp< GrSurface > surface)
 
bool isExact () const
 
void exactify ()
 
void setLazyDimensions (SkISize dimensions)
 
bool doLazyInstantiation (GrResourceProvider *)
 
void setIsDDLTarget ()
 
void setIsPromiseProxy ()
 

Friends

class GrSurfaceProxy
 

Detailed Description

Class that adds methods to GrSurfaceProxy that are only intended for use internal to Skia. This class is purely a privileged window into GrSurfaceProxy. It should never have additional data members or virtual methods.

Definition at line 20 of file GrSurfaceProxyPriv.h.

Member Function Documentation

◆ assign()

void GrSurfaceProxyPriv::assign ( sk_sp< GrSurface surface)
inline

Definition at line 33 of file GrSurfaceProxyPriv.h.

33{ fProxy->assign(std::move(surface)); }
void assign(sk_sp< GrSurface > surface)
VkSurfaceKHR surface
Definition: main.cc:49

◆ computeScratchKey()

void GrSurfaceProxyPriv::computeScratchKey ( const GrCaps caps,
skgpu::ScratchKey key 
) const
inline

Definition at line 22 of file GrSurfaceProxyPriv.h.

22 {
23 return fProxy->computeScratchKey(caps, key);
24 }
void computeScratchKey(const GrCaps &, skgpu::ScratchKey *) const

◆ createSurface()

sk_sp< GrSurface > GrSurfaceProxyPriv::createSurface ( GrResourceProvider resourceProvider) const
inline

Definition at line 28 of file GrSurfaceProxyPriv.h.

28 {
29 return fProxy->createSurface(resourceProvider);
30 }
virtual sk_sp< GrSurface > createSurface(GrResourceProvider *) const =0

◆ doLazyInstantiation()

bool GrSurfaceProxyPriv::doLazyInstantiation ( GrResourceProvider resourceProvider)

Definition at line 424 of file GrSurfaceProxy.cpp.

424 {
425 SkASSERT(fProxy->isLazy());
426
428 if (const auto& uniqueKey = fProxy->getUniqueKey(); uniqueKey.isValid()) {
429 // First try to reattach to a cached version if the proxy is uniquely keyed
430 surface = resourceProvider->findByUniqueKey<GrSurface>(uniqueKey);
431 }
432
433 bool syncKey = true;
434 bool releaseCallback = false;
435 if (!surface) {
436 auto result = fProxy->fLazyInstantiateCallback(resourceProvider, fProxy->callbackDesc());
437 surface = std::move(result.fSurface);
439 releaseCallback = surface && result.fReleaseCallback;
440 }
441 if (!surface) {
442 fProxy->fDimensions.setEmpty();
443 return false;
444 }
445
446 if (fProxy->isFullyLazy()) {
447 // This was a fully lazy proxy. We need to fill in the width & height. For partially
448 // lazy proxies we must preserve the original width & height since that indicates
449 // the content area.
450 fProxy->fDimensions = surface->dimensions();
451 }
452
453 SkASSERT(fProxy->width() <= surface->width());
454 SkASSERT(fProxy->height() <= surface->height());
455
456 if (GrTextureProxy* texProxy = fProxy->asTextureProxy()) {
457 texProxy->setTargetKeySync(syncKey);
458 if (syncKey) {
459 const skgpu::UniqueKey& key = texProxy->getUniqueKey();
460 if (key.isValid()) {
461 if (!surface->asTexture()->getUniqueKey().isValid()) {
462 // If 'surface' is newly created, attach the unique key
463 resourceProvider->assignUniqueKeyToResource(key, surface.get());
464 } else {
465 // otherwise we had better have reattached to a cached version
466 SkASSERT(surface->asTexture()->getUniqueKey() == key);
467 }
468 } else {
469 SkASSERT(!surface->getUniqueKey().isValid());
470 }
471 }
472 }
473
474 this->assign(std::move(surface));
475 if (releaseCallback) {
476 fProxy->fLazyInstantiateCallback = nullptr;
477 }
478
479 return true;
480}
#define SkASSERT(cond)
Definition: SkAssert.h:116
std::enable_if< std::is_base_of< GrGpuResource, T >::value, sk_sp< T > >::type findByUniqueKey(const skgpu::UniqueKey &key)
void assignUniqueKeyToResource(const skgpu::UniqueKey &, GrGpuResource *)
void assign(sk_sp< GrSurface > surface)
virtual const skgpu::UniqueKey & getUniqueKey() const
bool isLazy() const
bool isFullyLazy() const
int width() const
virtual LazySurfaceDesc callbackDesc() const =0
virtual GrTextureProxy * asTextureProxy()
int height() const
bool isValid() const
Definition: ResourceKey.h:55
GAsyncResult * result
void setEmpty()
Definition: SkSize.h:34

◆ exactify()

void GrSurfaceProxyPriv::exactify ( )

Definition at line 406 of file GrSurfaceProxy.cpp.

406 {
407 SkASSERT(!fProxy->isFullyLazy());
408 if (this->isExact()) {
409 return;
410 }
411
412 // The kApprox case. Setting the proxy's width & height to the backing-store width & height
413 // could have side-effects going forward, since we're obliterating the area of interest
414 // information. This is only used by SkSpecialImage when it's determined that sampling will
415 // not access beyond the safe known region (the current value of fProxy->fDimensions). If
416 // the proxy is instantiated, update the proxy's dimensions to match. Otherwise update them
417 // to the backing-store dimensions.
418 SkASSERT(SkBackingFit::kApprox == fProxy->fFit);
419 fProxy->fDimensions = fProxy->fTarget ? fProxy->fTarget->dimensions()
420 : fProxy->backingStoreDimensions();
421 fProxy->fFit = SkBackingFit::kExact;
422}
SkISize backingStoreDimensions() const
sk_sp< GrSurface > fTarget
SkISize dimensions() const
Definition: GrSurface.h:27

◆ isExact()

bool GrSurfaceProxyPriv::isExact ( ) const
inline

Definition at line 36 of file GrSurfaceProxyPriv.h.

36{ return SkBackingFit::kExact == fProxy->fFit; }

◆ setIsDDLTarget()

void GrSurfaceProxyPriv::setIsDDLTarget ( )
inline

Definition at line 45 of file GrSurfaceProxyPriv.h.

45{ fProxy->fIsDDLTarget = true; }

◆ setIsPromiseProxy()

void GrSurfaceProxyPriv::setIsPromiseProxy ( )
inline

Definition at line 47 of file GrSurfaceProxyPriv.h.

47{ fProxy->fIsPromiseProxy = true; }

◆ setLazyDimensions()

void GrSurfaceProxyPriv::setLazyDimensions ( SkISize  dimensions)
inline

Definition at line 41 of file GrSurfaceProxyPriv.h.

41{ fProxy->setLazyDimensions(dimensions); }
void setLazyDimensions(SkISize dimensions)

Friends And Related Function Documentation

◆ GrSurfaceProxy

friend class GrSurfaceProxy
friend

Definition at line 59 of file GrSurfaceProxyPriv.h.


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