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

#include <GrGLRenderTarget.h>

Inheritance diagram for GrGLRenderTarget:
GrRenderTarget GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrGLTextureRenderTarget

Classes

struct  IDs
 

Public Types

enum  { kUnresolvableFBOID = 0 }
 
enum class  ResolveDirection : bool { kSingleToMSAA , kMSAAToSingle }
 
- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Public Member Functions

bool alwaysClearStencil () const override
 
bool isFBO0 (bool multisample) const
 
bool isMultisampledRenderToTexture () const
 
GrBackendRenderTarget getBackendRenderTarget () const override
 
GrBackendFormat backendFormat () const override
 
bool canAttemptStencilAttachment (bool useMultisampleFBO) const override
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const override
 
GrGLFormat format () const
 
bool hasDynamicMSAAAttachment () const
 
bool ensureDynamicMSAAAttachment ()
 
void bind (bool useMultisampleFBO)
 
bool mustRebind (bool useMultisampleFBO) const
 
void bindForPixelOps (GrGLenum fboTarget)
 
void bindForResolve (ResolveDirection)
 
bool glRTFBOIDis0 () const
 
- Public Member Functions inherited from GrRenderTarget
GrRenderTargetasRenderTarget () override
 
const GrRenderTargetasRenderTarget () const override
 
int numSamples () const
 
GrAttachmentgetStencilAttachment (bool useMSAASurface) const
 
GrAttachmentgetStencilAttachment () const
 
void attachStencilAttachment (sk_sp< GrAttachment > stencil, bool useMSAASurface)
 
int numStencilBits (bool useMSAASurface) const
 
int getSamplePatternKey ()
 
const skia_private::TArray< SkPoint > & getSampleLocations ()
 
void setRequiresManualMSAAResolve ()
 
bool requiresManualMSAAResolve () const
 
- Public Member Functions inherited from GrSurface
SkISize dimensions () const
 
int width () const
 
int height () const
 
SkRect getBoundsRect () const
 
void setRelease (sk_sp< skgpu::RefCntedCallback > releaseHelper)
 
void setRelease (ReleaseProc proc, ReleaseCtx ctx)
 
virtual GrTextureasTexture ()
 
virtual const GrTextureasTexture () const
 
GrInternalSurfaceFlags flags () const
 
bool readOnly () const
 
bool framebufferOnly () const
 
bool isProtected () const
 
void setFramebufferOnly ()
 
- Public Member Functions inherited from GrGpuResource
bool wasDestroyed () const
 
const GrDirectContextgetContext () const
 
GrDirectContextgetContext ()
 
size_t gpuMemorySize () const
 
UniqueID uniqueID () const
 
const skgpu::UniqueKeygetUniqueKey () const
 
std::string getLabel () const
 
void setLabel (std::string_view label)
 
CacheAccess cacheAccess ()
 
const CacheAccess cacheAccess () const
 
ProxyAccess proxyAccess ()
 
ResourcePriv resourcePriv ()
 
const ResourcePriv resourcePriv () const
 
- Public Member Functions inherited from GrIORef< GrGpuResource >
bool unique () const
 
void ref () const
 
void unref () const
 
void refCommandBuffer () const
 
void unrefCommandBuffer () const
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Static Public Member Functions

static sk_sp< GrGLRenderTargetMakeWrapped (GrGLGpu *, const SkISize &, GrGLFormat, int sampleCount, const IDs &, int stencilBits, skgpu::Protected, std::string_view label)
 
- Static Public Member Functions inherited from GrSurface
static size_t ComputeSize (const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
 
- Static Public Member Functions inherited from GrGpuResource
static uint32_t CreateUniqueID ()
 

Protected Member Functions

 GrGLRenderTarget (GrGLGpu *, const SkISize &, GrGLFormat, int sampleCount, const IDs &, skgpu::Protected, std::string_view label)
 
void init (GrGLFormat, const IDs &)
 
void bindInternal (GrGLenum fboTarget, bool useMultisampleFBO)
 
void onAbandon () override
 
void onRelease () override
 
int totalMemorySamplesPerPixel () const
 
- Protected Member Functions inherited from GrRenderTarget
 GrRenderTarget (GrGpu *, const SkISize &, int sampleCount, GrProtected, std::string_view label, sk_sp< GrAttachment > stenicl=nullptr)
 
 ~GrRenderTarget () override
 
void onAbandon () override
 
void onRelease () override
 
- Protected Member Functions inherited from GrSurface
void setGLRTFBOIDIs0 ()
 
bool glRTFBOIDis0 () const
 
void setRequiresManualMSAAResolve ()
 
bool requiresManualMSAAResolve () const
 
void setReadOnly ()
 
void setVkRTSupportsInputAttachment ()
 
 GrSurface (GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
 
 ~GrSurface () override
 
void onRelease () override
 
void onAbandon () override
 
- Protected Member Functions inherited from GrGpuResource
void registerWithCache (skgpu::Budgeted)
 
void registerWithCacheWrapped (GrWrapCacheable)
 
 GrGpuResource (GrGpu *, std::string_view label)
 
virtual ~GrGpuResource ()
 
GrGpugetGpu () const
 
virtual void setMemoryBacking (SkTraceMemoryDump *, const SkString &) const
 
SkString getResourceName () const
 
void dumpMemoryStatisticsPriv (SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
 
- Protected Member Functions inherited from GrIORef< GrGpuResource >
 GrIORef ()
 
bool internalHasRef () const
 
bool internalHasNoCommandBufferUsages () const
 
void addInitialRef () const
 

Private Member Functions

bool completeStencilAttachment (GrAttachment *stencil, bool useMultisampleFBO) override
 
size_t onGpuMemorySize () const override
 
void onSetLabel () override
 

Detailed Description

Definition at line 23 of file GrGLRenderTarget.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kUnresolvableFBOID 

Definition at line 30 of file GrGLRenderTarget.h.

◆ ResolveDirection

enum class GrGLRenderTarget::ResolveDirection : bool
strong
Enumerator
kSingleToMSAA 
kMSAAToSingle 

Definition at line 90 of file GrGLRenderTarget.h.

90 : bool {
91 kSingleToMSAA, // glCaps.canResolveSingleToMSAA() must be true.
93 };

Constructor & Destructor Documentation

◆ GrGLRenderTarget()

GrGLRenderTarget::GrGLRenderTarget ( GrGLGpu gpu,
const SkISize dimensions,
GrGLFormat  format,
int  sampleCount,
const IDs ids,
skgpu::Protected  isProtected,
std::string_view  label 
)
protected

Definition at line 41 of file GrGLRenderTarget.cpp.

48 : GrSurface(gpu, dimensions, isProtected, label)
49 , GrRenderTarget(gpu, dimensions, sampleCount, isProtected, label) {
50 this->init(format, ids);
51 this->setFlags(gpu->glCaps(), ids);
52}
const GrGLCaps & glCaps() const
Definition GrGLGpu.h:108
GrGLFormat format() const
void init(GrGLFormat, const IDs &)
SkISize dimensions() const
Definition GrSurface.h:27
bool isProtected() const
Definition GrSurface.h:87

Member Function Documentation

◆ alwaysClearStencil()

bool GrGLRenderTarget::alwaysClearStencil ( ) const
inlineoverridevirtual

Reimplemented from GrRenderTarget.

Definition at line 26 of file GrGLRenderTarget.h.

26{ return this->glRTFBOIDis0(); }
bool glRTFBOIDis0() const
Definition GrSurface.h:117

◆ backendFormat()

GrBackendFormat GrGLRenderTarget::backendFormat ( ) const
overridevirtual

Implements GrSurface.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 131 of file GrGLRenderTarget.cpp.

131 {
132 // We should never have a GrGLRenderTarget (even a textureable one with a target that is not
133 // texture 2D.
135}
#define GR_GL_TEXTURE_2D
static constexpr GrGLenum GrGLFormatToEnum(GrGLFormat format)
Definition GrGLUtil.h:445
SK_API GrBackendFormat MakeGL(GrGLenum format, GrGLenum target)

◆ bind()

void GrGLRenderTarget::bind ( bool  useMultisampleFBO)
inline

Definition at line 73 of file GrGLRenderTarget.h.

73 {
74 this->bindInternal(GR_GL_FRAMEBUFFER, useMultisampleFBO);
75 }
#define GR_GL_FRAMEBUFFER
void bindInternal(GrGLenum fboTarget, bool useMultisampleFBO)

◆ bindForPixelOps()

void GrGLRenderTarget::bindForPixelOps ( GrGLenum  fboTarget)
inline

Definition at line 85 of file GrGLRenderTarget.h.

85 {
86 this->bindInternal(fboTarget,
87 this->numSamples() > 1 && !this->isMultisampledRenderToTexture());
88 }
bool isMultisampledRenderToTexture() const
int numSamples() const

◆ bindForResolve()

void GrGLRenderTarget::bindForResolve ( GrGLGpu::ResolveDirection  resolveDirection)

Definition at line 281 of file GrGLRenderTarget.cpp.

281 {
282 // If the multisample FBO is nonzero, it means we always have something to resolve (even if the
283 // single sample buffer is FBO 0). If it's zero, then there's nothing to resolve.
284 SkASSERT(fMultisampleFBOID != 0);
285
286 // In the EXT_multisampled_render_to_texture case, we shouldn't be resolving anything.
288
289 if (resolveDirection == GrGLGpu::ResolveDirection::kMSAAToSingle) {
292 } else {
293 SkASSERT(resolveDirection == GrGLGpu::ResolveDirection::kSingleToMSAA);
294 SkASSERT(this->getGLGpu()->glCaps().canResolveSingleToMSAA());
297 }
298}
#define GR_GL_DRAW_FRAMEBUFFER
#define GR_GL_READ_FRAMEBUFFER
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ bindInternal()

void GrGLRenderTarget::bindInternal ( GrGLenum  fboTarget,
bool  useMultisampleFBO 
)
protected

Definition at line 199 of file GrGLRenderTarget.cpp.

199 {
200 GrGLuint fboId = useMultisampleFBO ? fMultisampleFBOID : fSingleSampleFBOID;
201 this->getGLGpu()->bindFramebuffer(fboTarget, fboId);
202
203 if (fSingleSampleFBOID != 0 &&
204 fSingleSampleFBOID == fMultisampleFBOID &&
205 useMultisampleFBO != fDMSAARenderToTextureFBOIsMultisample) {
206 auto* glTex = static_cast<GrGLTexture*>(this->asTexture());
208 GL_CALL(FramebufferTexture2D(fboTarget,
211 0 /*texture*/,
212 0 /*mipMapLevel*/));
213 }
214 if (useMultisampleFBO) {
215 int sampleCount = this->numSamples() > 1 ?
216 this->numSamples() :
217 this->getGpu()->caps()->internalMultisampleCount(this->backendFormat());
218 GL_CALL(FramebufferTexture2DMultisample(fboTarget,
220 glTex->target(),
221 glTex->textureID(),
222 0 /*mipMapLevel*/,
223 sampleCount));
224 } else {
225 GL_CALL(FramebufferTexture2D(fboTarget,
227 glTex->target(),
228 glTex->textureID(),
229 0 /*mipMapLevel*/));
230 }
231 fDMSAARenderToTextureFBOIsMultisample = useMultisampleFBO;
232 fNeedsStencilAttachmentBind[useMultisampleFBO] = true;
233 }
234
235 // Make sure the stencil attachment is valid. Even though a color buffer op doesn't use stencil,
236 // our FBO still needs to be "framebuffer complete".
237 if (fNeedsStencilAttachmentBind[useMultisampleFBO]) {
238 if (auto stencil = this->getStencilAttachment(useMultisampleFBO)) {
239 const GrGLAttachment* glStencil = static_cast<const GrGLAttachment*>(stencil);
240 GL_CALL(FramebufferRenderbuffer(fboTarget,
243 glStencil->renderbufferID()));
244 if (GrGLFormatIsPackedDepthStencil(glStencil->format())) {
245 GL_CALL(FramebufferRenderbuffer(fboTarget,
248 glStencil->renderbufferID()));
249 } else {
250 GL_CALL(FramebufferRenderbuffer(fboTarget,
253 0));
254 }
255 } else {
256 GL_CALL(FramebufferRenderbuffer(fboTarget,
259 0));
260 GL_CALL(FramebufferRenderbuffer(fboTarget,
263 0));
264 }
265#ifdef SK_DEBUG
266 if (!this->getGLGpu()->glCaps().skipErrorChecks() &&
267 !this->getGLGpu()->glCaps().rebindColorAttachmentAfterCheckFramebufferStatus()) {
268 GrGLenum status;
269 GL_CALL_RET(status, CheckFramebufferStatus(fboTarget));
270 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
271 // This can fail if the context has been asynchronously abandoned (see
272 // skbug.com/5200).
273 SkDebugf("WARNING: failed to attach stencil.\n");
274 }
275 }
276#endif
277 fNeedsStencilAttachmentBind[useMultisampleFBO] = false;
278 }
279}
#define GR_GL_RENDERBUFFER
#define GR_GL_STENCIL_ATTACHMENT
#define GR_GL_DEPTH_ATTACHMENT
#define GR_GL_FRAMEBUFFER_COMPLETE
#define GR_GL_COLOR_ATTACHMENT0
#define GL_CALL(X)
#define GL_CALL_RET(R, X)
unsigned int GrGLuint
Definition GrGLTypes.h:113
unsigned int GrGLenum
Definition GrGLTypes.h:102
static constexpr bool GrGLFormatIsPackedDepthStencil(GrGLFormat format)
Definition GrGLUtil.h:552
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
GrGLuint renderbufferID() const
GrGLFormat format() const
bool bindTexture0WhenChangingTextureFBOMultisampleCount() const
Definition GrGLCaps.h:450
void bindFramebuffer(GrGLenum fboTarget, GrGLuint fboid)
Definition GrGLGpu.cpp:3184
GrBackendFormat backendFormat() const override
GrGpu * getGpu() const
GrAttachment * getStencilAttachment() const
virtual GrTexture * asTexture()
Definition GrSurface.h:59

◆ canAttemptStencilAttachment()

bool GrGLRenderTarget::canAttemptStencilAttachment ( bool  useMultisampleFBO) const
overridevirtual

Implements GrRenderTarget.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 331 of file GrGLRenderTarget.cpp.

331 {
332 // This cap should have been handled at a higher level.
333 SkASSERT(!this->getGpu()->getContext()->priv().caps()->avoidStencilBuffers());
334 // Only modify the FBO's attachments if we have created the FBO. Public APIs do not currently
335 // allow for borrowed FBO ownership, so we can safely assume that if an object is owned,
336 // Skia created it.
337 return this->fRTFBOOwnership == GrBackendObjectOwnership::kOwned ||
338 // The dmsaa attachment is always owned and always supports adding stencil.
339 (this->numSamples() == 1 && useMultisampleFBO);
340}
const GrDirectContext * getContext() const
FlPixelBufferTexturePrivate * priv

◆ completeStencilAttachment()

bool GrGLRenderTarget::completeStencilAttachment ( GrAttachment stencil,
bool  useMultisampleFBO 
)
overrideprivatevirtual

Implements GrRenderTarget.

Definition at line 149 of file GrGLRenderTarget.cpp.

149 {
150 // We defer attaching the new stencil buffer until the next time our framebuffer is bound.
151 if (this->getStencilAttachment(useMultisampleFBO) != stencil) {
152 fNeedsStencilAttachmentBind[useMultisampleFBO] = true;
153 }
154 return true;
155}

◆ dumpMemoryStatistics()

void GrGLRenderTarget::dumpMemoryStatistics ( SkTraceMemoryDump traceMemoryDump) const
overridevirtual

Dumps memory usage information for this GrGpuResource to traceMemoryDump. Typically, subclasses should not need to override this, and should only need to override setMemoryBacking.

Reimplemented from GrGpuResource.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 342 of file GrGLRenderTarget.cpp.

342 {
343 // Don't check this->fRefsWrappedObjects, as we might be the base of a GrGLTextureRenderTarget
344 // which is multiply inherited from both ourselves and a texture. In these cases, one part
345 // (texture, rt) may be wrapped, while the other is owned by Skia.
346 bool refsWrappedRenderTargetObjects =
347 this->fRTFBOOwnership == GrBackendObjectOwnership::kBorrowed;
348 if (refsWrappedRenderTargetObjects && !traceMemoryDump->shouldDumpWrappedObjects()) {
349 return;
350 }
351
352 int numSamplesNotInTexture = fTotalMemorySamplesPerPixel;
353 if (this->asTexture()) {
354 --numSamplesNotInTexture; // GrGLTexture::dumpMemoryStatistics accounts for 1 sample.
355 }
356 if (numSamplesNotInTexture >= 1) {
358 this->dimensions(),
359 numSamplesNotInTexture,
360 skgpu::Mipmapped::kNo);
361
362 // Due to this resource having both a texture and a renderbuffer component, dump as
363 // skia/gpu_resources/resource_#/renderbuffer
364 SkString resourceName = this->getResourceName();
365 resourceName.append("/renderbuffer");
366
367 this->dumpMemoryStatisticsPriv(traceMemoryDump, resourceName, "RenderTarget", size);
368
369 SkString renderbuffer_id;
370 renderbuffer_id.appendU32(fMSColorRenderbufferID);
371 traceMemoryDump->setMemoryBacking(resourceName.c_str(), "gl_renderbuffer",
372 renderbuffer_id.c_str());
373 }
374}
void dumpMemoryStatisticsPriv(SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
SkString getResourceName() const
static size_t ComputeSize(const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
Definition GrSurface.cpp:21
void append(const char text[])
Definition SkString.h:203
void appendU32(uint32_t value)
Definition SkString.h:210
const char * c_str() const
Definition SkString.h:133
virtual void setMemoryBacking(const char *dumpName, const char *backingType, const char *backingObjectId)=0
virtual bool shouldDumpWrappedObjects() const
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259

◆ ensureDynamicMSAAAttachment()

bool GrGLRenderTarget::ensureDynamicMSAAAttachment ( )

Definition at line 157 of file GrGLRenderTarget.cpp.

157 {
158 SkASSERT(this->numSamples() == 1);
159 if (fMultisampleFBOID) {
160 return true;
161 }
162 SkASSERT(!fDynamicMSAAAttachment);
163
164 GrResourceProvider* resourceProvider = this->getContext()->priv().resourceProvider();
165 const GrCaps& caps = *this->getGpu()->caps();
166
167 int internalSampleCount = caps.internalMultisampleCount(this->backendFormat());
168 if (internalSampleCount <= 1) {
169 return false;
170 }
171
172 if (resourceProvider->caps()->msaaResolvesAutomatically() && this->asTexture()) {
173 // We can use EXT_multisampled_render_to_texture for MSAA. We will configure the FBO as MSAA
174 // or not during bindFBO().
175 fMultisampleFBOID = fSingleSampleFBOID;
176 return true;
177 }
178
179 GL_CALL(GenFramebuffers(1, &fMultisampleFBOID));
180 if (!fMultisampleFBOID) {
181 return false;
182 }
183
184 this->getGLGpu()->bindFramebuffer(GR_GL_FRAMEBUFFER, fMultisampleFBOID);
185
186 fDynamicMSAAAttachment.reset(
187 static_cast<GrGLAttachment*>(resourceProvider->getDiscardableMSAAAttachment(
188 this->dimensions(), this->backendFormat(), internalSampleCount,
189 GrProtected(this->isProtected()), GrMemoryless::kNo).release()));
190 if (!fDynamicMSAAAttachment) {
191 return false;
192 }
193
195 fDynamicMSAAAttachment->renderbufferID()));
196 return true;
197}
bool msaaResolvesAutomatically() const
Definition GrCaps.h:100
int internalMultisampleCount(const GrBackendFormat &format) const
Definition GrCaps.h:271
GrResourceProvider * resourceProvider()
GrDirectContextPriv priv()
const GrCaps * caps() const
Definition GrGpu.h:73
sk_sp< GrAttachment > getDiscardableMSAAAttachment(SkISize dimensions, const GrBackendFormat &format, int sampleCnt, skgpu::Protected isProtected, GrMemoryless memoryless)
const GrCaps * caps() const
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310
Protected
Definition GpuTypes.h:61

◆ format()

GrGLFormat GrGLRenderTarget::format ( ) const
inline

Definition at line 67 of file GrGLRenderTarget.h.

67{ return fRTFormat; }

◆ getBackendRenderTarget()

GrBackendRenderTarget GrGLRenderTarget::getBackendRenderTarget ( ) const
overridevirtual

Implements GrRenderTarget.

Definition at line 116 of file GrGLRenderTarget.cpp.

116 {
117 bool useMultisampleFBO = (this->numSamples() > 1);
119 fbi.fFBOID = (useMultisampleFBO) ? fMultisampleFBOID : fSingleSampleFBOID;
120 fbi.fFormat = GrGLFormatToEnum(this->format());
122 int numStencilBits = 0;
123 if (GrAttachment* stencil = this->getStencilAttachment(useMultisampleFBO)) {
124 numStencilBits = GrBackendFormatStencilBits(stencil->backendFormat());
125 }
126
128 this->width(), this->height(), this->numSamples(), numStencilBits, fbi);
129}
int GrBackendFormatStencilBits(const GrBackendFormat &format)
int numStencilBits(bool useMSAASurface) const
int height() const
Definition GrSurface.h:37
int width() const
Definition GrSurface.h:32
SK_API GrBackendRenderTarget MakeGL(int width, int height, int sampleCnt, int stencilBits, const GrGLFramebufferInfo &glInfo)
skgpu::Protected fProtected
Definition GrGLTypes.h:199

◆ glRTFBOIDis0()

bool GrSurface::glRTFBOIDis0 ( ) const
inline

Definition at line 117 of file GrSurface.h.

117 {
118 return fSurfaceFlags & GrInternalSurfaceFlags::kGLRTFBOIDIs0;
119 }

◆ hasDynamicMSAAAttachment()

bool GrGLRenderTarget::hasDynamicMSAAAttachment ( ) const
inline

Definition at line 69 of file GrGLRenderTarget.h.

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

◆ init()

void GrGLRenderTarget::init ( GrGLFormat  format,
const IDs idDesc 
)
protected

Definition at line 60 of file GrGLRenderTarget.cpp.

60 {
61 fMultisampleFBOID = idDesc.fMultisampleFBOID;
62 fSingleSampleFBOID = idDesc.fSingleSampleFBOID;
63 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
64 fRTFBOOwnership = idDesc.fRTFBOOwnership;
65 fRTFormat = format;
66 fTotalMemorySamplesPerPixel = idDesc.fTotalMemorySamplesPerPixel;
67}

◆ isFBO0()

bool GrGLRenderTarget::isFBO0 ( bool  multisample) const
inline

Definition at line 49 of file GrGLRenderTarget.h.

49 {
50 return (multisample ? fMultisampleFBOID : fSingleSampleFBOID) == 0;
51 }

◆ isMultisampledRenderToTexture()

bool GrGLRenderTarget::isMultisampledRenderToTexture ( ) const
inline

Definition at line 53 of file GrGLRenderTarget.h.

53 {
54 return fMultisampleFBOID != 0 && fMultisampleFBOID == fSingleSampleFBOID;
55 }

◆ MakeWrapped()

sk_sp< GrGLRenderTarget > GrGLRenderTarget::MakeWrapped ( GrGLGpu gpu,
const SkISize dimensions,
GrGLFormat  format,
int  sampleCount,
const IDs idDesc,
int  stencilBits,
skgpu::Protected  isProtected,
std::string_view  label 
)
static

Definition at line 85 of file GrGLRenderTarget.cpp.

92 {
94 if (stencilBits) {
95 // We pick a "fake" actual format that matches the number of stencil bits. When wrapping
96 // an FBO with some number of stencil bits all we care about in the future is that we have
97 // a format with the same number of stencil bits. We don't even directly use the format or
98 // any other properties. Thus it is fine for us to just assign an arbitrary format that
99 // matches the stencil bit count.
100 GrGLFormat sFmt = stencil_bits_to_format(stencilBits);
101
102 // We don't have the actual renderbufferID but we need to make an attachment for the stencil
103 // so we just set it to an invalid value of 0 to make sure we don't explicitly use it or try
104 // and delete it.
106 /*renderbufferID=*/0,
109 sampleCount,
110 sFmt);
111 }
113 gpu, dimensions, format, sampleCount, idDesc, std::move(sb), isProtected, label));
114}
GrGLFormat stencil_bits_to_format(int stencilBits)
GrGLFormat
Definition GrGLTypes.h:59
static sk_sp< GrGLAttachment > MakeWrappedRenderBuffer(GrGpu *gpu, GrGLuint renderbufferID, SkISize dimensions, UsageFlags supportedUsages, int sampleCnt, GrGLFormat format)

◆ mustRebind()

bool GrGLRenderTarget::mustRebind ( bool  useMultisampleFBO) const
inline

Definition at line 78 of file GrGLRenderTarget.h.

78 {
79 return fNeedsStencilAttachmentBind[useMultisampleFBO];
80 }

◆ onAbandon()

void GrGLRenderTarget::onAbandon ( )
overrideprotectedvirtual

Overridden to abandon any internal handles, ptrs, etc to backend API resources. This may be called when the underlying 3D context is no longer valid and so no backend API calls should be made.

Reimplemented from GrGpuResource.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 319 of file GrGLRenderTarget.cpp.

319 {
320 fMultisampleFBOID = 0;
321 fSingleSampleFBOID = 0;
322 fMSColorRenderbufferID = 0;
324}
void onAbandon() override

◆ onGpuMemorySize()

size_t GrGLRenderTarget::onGpuMemorySize ( ) const
overrideprivatevirtual

Implements GrGpuResource.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 137 of file GrGLRenderTarget.cpp.

137 {
139 this->dimensions(),
140 fTotalMemorySamplesPerPixel,
141 skgpu::Mipmapped::kNo);
142}

◆ onRelease()

void GrGLRenderTarget::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 300 of file GrGLRenderTarget.cpp.

300 {
301 if (GrBackendObjectOwnership::kBorrowed != fRTFBOOwnership) {
302 GrGLGpu* gpu = this->getGLGpu();
303 if (fSingleSampleFBOID) {
304 gpu->deleteFramebuffer(fSingleSampleFBOID);
305 }
306 if (fMultisampleFBOID && fMultisampleFBOID != fSingleSampleFBOID) {
307 gpu->deleteFramebuffer(fMultisampleFBOID);
308 }
309 if (fMSColorRenderbufferID) {
310 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
311 }
312 }
313 fMultisampleFBOID = 0;
314 fSingleSampleFBOID = 0;
315 fMSColorRenderbufferID = 0;
317}
void deleteFramebuffer(GrGLuint fboid)
Definition GrGLGpu.cpp:3192
void onRelease() override

◆ onSetLabel()

void GrGLRenderTarget::onSetLabel ( )
overrideprivatevirtual

Implements GrGpuResource.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 144 of file GrGLRenderTarget.cpp.

144 {
145 SkASSERT(fMSColorRenderbufferID);
146 SkASSERT(fRTFBOOwnership == GrBackendObjectOwnership::kOwned);
147}

◆ totalMemorySamplesPerPixel()

int GrGLRenderTarget::totalMemorySamplesPerPixel ( ) const
inlineprotected

Definition at line 117 of file GrGLRenderTarget.h.

117{ return fTotalMemorySamplesPerPixel; }

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