Flutter Engine
The Flutter Engine
Public Member Functions | Protected Types | Protected Member Functions | Friends | List of all members
GrRenderTargetProxy Class Reference

#include <GrRenderTargetProxy.h>

Inheritance diagram for GrRenderTargetProxy:
GrSurfaceProxy SkNVRefCnt< GrSurfaceProxy > GrTextureRenderTargetProxy

Public Member Functions

GrRenderTargetProxyasRenderTargetProxy () override
 
const GrRenderTargetProxyasRenderTargetProxy () const override
 
bool instantiate (GrResourceProvider *) override
 
bool canUseStencil (const GrCaps &caps) const
 
void setNeedsStencil ()
 
int needsStencil () const
 
int numSamples () const
 
int maxWindowRectangles (const GrCaps &caps) const
 
bool glRTFBOIDIs0 () const
 
bool wrapsVkSecondaryCB () const
 
bool supportsVkInputAttachment () const
 
void markMSAADirty (SkIRect dirtyRect)
 
void markMSAAResolved ()
 
bool isMSAADirty () const
 
const SkIRectmsaaDirtyRect () const
 
bool refsWrappedObjects () const
 
sk_sp< GrArenasarenas ()
 
void clearArenas ()
 
- 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
 
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
 

Protected Types

enum class  WrapsVkSecondaryCB : bool { kNo = false , kYes = true }
 

Protected Member Functions

 GrRenderTargetProxy (const GrCaps &, const GrBackendFormat &, SkISize, int sampleCount, SkBackingFit, skgpu::Budgeted, skgpu::Protected, GrInternalSurfaceFlags, UseAllocator, std::string_view label)
 
 GrRenderTargetProxy (LazyInstantiateCallback &&, const GrBackendFormat &, SkISize, int sampleCount, SkBackingFit, skgpu::Budgeted, skgpu::Protected, GrInternalSurfaceFlags, UseAllocator, WrapsVkSecondaryCB, std::string_view label)
 
 GrRenderTargetProxy (sk_sp< GrSurface >, UseAllocator, WrapsVkSecondaryCB=WrapsVkSecondaryCB::kNo)
 
sk_sp< GrSurfacecreateSurface (GrResourceProvider *) const override
 
- 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
 
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 *)
 

Friends

class GrProxyProvider
 
class GrVkSecondaryCBDrawContext
 

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 &)>
 
- 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)
 
- Protected Attributes inherited from GrSurfaceProxy
sk_sp< GrSurfacefTarget
 
GrInternalSurfaceFlags fSurfaceFlags
 

Detailed Description

Definition at line 64 of file GrRenderTargetProxy.h.

Member Enumeration Documentation

◆ WrapsVkSecondaryCB

enum class GrRenderTargetProxy::WrapsVkSecondaryCB : bool
strongprotected
Enumerator
kNo 
kYes 

Definition at line 149 of file GrRenderTargetProxy.h.

149: bool { kNo = false, kYes = true };
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.

Constructor & Destructor Documentation

◆ GrRenderTargetProxy() [1/3]

GrRenderTargetProxy::GrRenderTargetProxy ( const GrCaps caps,
const GrBackendFormat format,
SkISize  dimensions,
int  sampleCount,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
skgpu::Protected  isProtected,
GrInternalSurfaceFlags  surfaceFlags,
UseAllocator  useAllocator,
std::string_view  label 
)
protected

Definition at line 32 of file GrRenderTargetProxy.cpp.

42 : INHERITED(
43 format, dimensions, fit, budgeted, isProtected, surfaceFlags, useAllocator, label)
44 , fSampleCnt(sampleCount)
45 , fWrapsVkSecondaryCB(WrapsVkSecondaryCB::kNo) {}
GrProtected isProtected() const
SkISize dimensions() const
uint32_t uint32_t * format

◆ GrRenderTargetProxy() [2/3]

GrRenderTargetProxy::GrRenderTargetProxy ( LazyInstantiateCallback &&  callback,
const GrBackendFormat format,
SkISize  dimensions,
int  sampleCount,
SkBackingFit  fit,
skgpu::Budgeted  budgeted,
skgpu::Protected  isProtected,
GrInternalSurfaceFlags  surfaceFlags,
UseAllocator  useAllocator,
WrapsVkSecondaryCB  wrapsVkSecondaryCB,
std::string_view  label 
)
protected

Definition at line 48 of file GrRenderTargetProxy.cpp.

59 : INHERITED(std::move(callback),
60 format,
62 fit,
63 budgeted,
65 surfaceFlags,
66 useAllocator,
67 label)
68 , fSampleCnt(sampleCount)
69 , fWrapsVkSecondaryCB(wrapsVkSecondaryCB) {}
bool wrapsVkSecondaryCB() const
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback

◆ GrRenderTargetProxy() [3/3]

GrRenderTargetProxy::GrRenderTargetProxy ( sk_sp< GrSurface surf,
UseAllocator  useAllocator,
WrapsVkSecondaryCB  wrapsVkSecondaryCB = WrapsVkSecondaryCB::kNo 
)
protected

Definition at line 72 of file GrRenderTargetProxy.cpp.

75 : INHERITED(std::move(surf), SkBackingFit::kExact, useAllocator)
76 , fSampleCnt(fTarget->asRenderTarget()->numSamples())
77 , fWrapsVkSecondaryCB(wrapsVkSecondaryCB) {
78 // The kRequiresManualMSAAResolve flag better not be set if we are not multisampled or if
79 // MSAA resolve should happen automatically.
80 //
81 // From the other side, we don't know enough about the wrapped surface to assert when
82 // kRequiresManualMSAAResolve *should* be set. e.g., The caller might be wrapping a backend
83 // texture as a render target at this point but we wouldn't know it.
84 SkASSERT(!(this->numSamples() <= 1 ||
86 !this->requiresManualMSAAResolve());
87}
#define SkASSERT(cond)
Definition: SkAssert.h:116
const GrCaps * caps() const
bool msaaResolvesAutomatically() const
Definition: GrCaps.h:100
GrDirectContextPriv priv()
const GrDirectContext * getContext() const
int numSamples() const
sk_sp< GrSurface > fTarget
virtual GrRenderTarget * asRenderTarget()
Definition: GrSurface.h:65

Member Function Documentation

◆ arenas()

sk_sp< GrArenas > GrRenderTargetProxy::arenas ( )
inline

Definition at line 120 of file GrRenderTargetProxy.h.

120 {
121 if (fArenas == nullptr) {
122 fArenas = sk_make_sp<GrArenas>();
123 }
124 return fArenas;
125 }

◆ asRenderTargetProxy() [1/2]

const GrRenderTargetProxy * GrRenderTargetProxy::asRenderTargetProxy ( ) const
inlineoverridevirtual

Reimplemented from GrSurfaceProxy.

Definition at line 67 of file GrRenderTargetProxy.h.

67{ return this; }

◆ asRenderTargetProxy() [2/2]

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

Reimplemented from GrSurfaceProxy.

Definition at line 66 of file GrRenderTargetProxy.h.

66{ return this; }

◆ canUseStencil()

bool GrRenderTargetProxy::canUseStencil ( const GrCaps caps) const

Definition at line 107 of file GrRenderTargetProxy.cpp.

107 {
108 if (caps.avoidStencilBuffers() || this->wrapsVkSecondaryCB()) {
109 return false;
110 }
111 if (!this->isInstantiated()) {
112 if (this->isLazy() && this->backendFormat().backend() == GrBackendApi::kOpenGL) {
113 // It's possible for wrapped GL render targets to not have stencil. We don't currently
114 // have an exact way of knowing whether the target will be able to use stencil, so we do
115 // the best we can: if a lazy GL proxy doesn't have a texture, then it might be a
116 // wrapped target without stencil, so we conservatively block stencil.
117 // FIXME: skbug.com/11943: GrSurfaceCharacterization needs a "canUseStencil" flag.
118 return SkToBool(this->asTextureProxy());
119 } else {
120 // Otherwise the target will definitely not be wrapped. Ganesh is free to attach
121 // stencils on internal render targets.
122 return true;
123 }
124 }
125 // Just ask the actual target if we can use stencil.
126 GrRenderTarget* rt = this->peekRenderTarget();
127 // The dmsaa attachment (if any) always supports stencil. The real question is whether the
128 // non-dmsaa attachment supports stencil.
129 bool useMSAASurface = rt->numSamples() > 1;
130 return rt->getStencilAttachment(useMSAASurface) ||
131 rt->canAttemptStencilAttachment(useMSAASurface);
132}
const char * backend
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
bool avoidStencilBuffers() const
Definition: GrCaps.h:139
GrAttachment * getStencilAttachment(bool useMSAASurface) const
virtual bool canAttemptStencilAttachment(bool useMSAASurface) const =0
const GrBackendFormat & backendFormat() const
bool isLazy() const
virtual GrTextureProxy * asTextureProxy()
bool isInstantiated() const
GrRenderTarget * peekRenderTarget() const

◆ clearArenas()

void GrRenderTargetProxy::clearArenas ( )
inline

Definition at line 127 of file GrRenderTargetProxy.h.

127 {
128 if (fArenas != nullptr) {
129 fArenas->flush();
130 }
131 fArenas = nullptr;
132 }

◆ createSurface()

sk_sp< GrSurface > GrRenderTargetProxy::createSurface ( GrResourceProvider resourceProvider) const
overrideprotectedvirtual

Implements GrSurfaceProxy.

Definition at line 134 of file GrRenderTargetProxy.cpp.

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

◆ glRTFBOIDIs0()

bool GrRenderTargetProxy::glRTFBOIDIs0 ( ) const
inline

Definition at line 91 of file GrRenderTargetProxy.h.

◆ instantiate()

bool GrRenderTargetProxy::instantiate ( GrResourceProvider resourceProvider)
overridevirtual

Implements GrSurfaceProxy.

Definition at line 93 of file GrRenderTargetProxy.cpp.

93 {
94 if (this->isLazy()) {
95 return false;
96 }
97 if (!this->instantiateImpl(resourceProvider, fSampleCnt, GrRenderable::kYes,
98 skgpu::Mipmapped::kNo, nullptr)) {
99 return false;
100 }
101
102 SkASSERT(this->peekRenderTarget());
103 SkASSERT(!this->peekTexture());
104 return true;
105}
bool instantiateImpl(GrResourceProvider *resourceProvider, int sampleCnt, GrRenderable, skgpu::Mipmapped, const skgpu::UniqueKey *)
GrTexture * peekTexture() const

◆ isMSAADirty()

bool GrRenderTargetProxy::isMSAADirty ( ) const
inline

Definition at line 108 of file GrRenderTargetProxy.h.

108 {
109 SkASSERT(fMSAADirtyRect.isEmpty() || this->requiresManualMSAAResolve());
110 return this->requiresManualMSAAResolve() && !fMSAADirtyRect.isEmpty();
111 }
bool requiresManualMSAAResolve() const
bool isEmpty() const
Definition: SkRect.h:202

◆ markMSAADirty()

void GrRenderTargetProxy::markMSAADirty ( SkIRect  dirtyRect)
inline

Definition at line 99 of file GrRenderTargetProxy.h.

99 {
102 fMSAADirtyRect.join(dirtyRect);
103 }
SkISize backingStoreDimensions() const
constexpr bool contains(std::string_view str, std::string_view needle)
Definition: SkStringView.h:41
void join(const SkIRect &r)
Definition: SkRect.cpp:31
static constexpr SkIRect MakeSize(const SkISize &size)
Definition: SkRect.h:66

◆ markMSAAResolved()

void GrRenderTargetProxy::markMSAAResolved ( )
inline

Definition at line 104 of file GrRenderTargetProxy.h.

104 {
106 fMSAADirtyRect.setEmpty();
107 }
void setEmpty()
Definition: SkRect.h:242

◆ maxWindowRectangles()

int GrRenderTargetProxy::maxWindowRectangles ( const GrCaps caps) const

Definition at line 89 of file GrRenderTargetProxy.cpp.

89 {
90 return this->glRTFBOIDIs0() ? 0 : caps.maxWindowRectangles();
91}
int maxWindowRectangles() const
Definition: GrCaps.h:231

◆ msaaDirtyRect()

const SkIRect & GrRenderTargetProxy::msaaDirtyRect ( ) const
inline

Definition at line 112 of file GrRenderTargetProxy.h.

112 {
114 return fMSAADirtyRect;
115 }

◆ needsStencil()

int GrRenderTargetProxy::needsStencil ( ) const
inline

Definition at line 82 of file GrRenderTargetProxy.h.

82{ return fNeedsStencil; }

◆ numSamples()

int GrRenderTargetProxy::numSamples ( ) const
inline

Returns the number of samples/pixel in the color buffer (One if non-MSAA).

Definition at line 87 of file GrRenderTargetProxy.h.

87{ return fSampleCnt; }

◆ refsWrappedObjects()

bool GrRenderTargetProxy::refsWrappedObjects ( ) const

Definition at line 158 of file GrRenderTargetProxy.cpp.

158 {
159 if (!this->isInstantiated()) {
160 return false;
161 }
162
163 GrSurface* surface = this->peekSurface();
164 return surface->resourcePriv().refsWrappedObjects();
165}
ResourcePriv resourcePriv()
GrSurface * peekSurface() const

◆ setNeedsStencil()

void GrRenderTargetProxy::setNeedsStencil ( )
inline

Definition at line 80 of file GrRenderTargetProxy.h.

80{ fNeedsStencil = true; }

◆ supportsVkInputAttachment()

bool GrRenderTargetProxy::supportsVkInputAttachment ( ) const
inline

◆ wrapsVkSecondaryCB()

bool GrRenderTargetProxy::wrapsVkSecondaryCB ( ) const
inline

Definition at line 93 of file GrRenderTargetProxy.h.

93{ return fWrapsVkSecondaryCB == WrapsVkSecondaryCB::kYes; }

Friends And Related Function Documentation

◆ GrProxyProvider

friend class GrProxyProvider
friend

Definition at line 135 of file GrRenderTargetProxy.h.

◆ GrVkSecondaryCBDrawContext

friend class GrVkSecondaryCBDrawContext
friend

Definition at line 136 of file GrRenderTargetProxy.h.


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