Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
GrGLTexture Class Reference

#include <GrGLTexture.h>

Inheritance diagram for GrGLTexture:
GrTexture GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrGLTextureRenderTarget

Classes

struct  Desc
 

Public Member Functions

 GrGLTexture (GrGLGpu *, skgpu::Budgeted, const Desc &, GrMipmapStatus, std::string_view label)
 
 ~GrGLTexture () override
 
GrBackendTexture getBackendTexture () const override
 
GrBackendFormat backendFormat () const override
 
void textureParamsModified () override
 
GrGLTextureParametersparameters ()
 
GrGLuint textureID () const
 
GrGLenum target () const
 
GrGLFormat format () const
 
bool hasBaseLevelBeenBoundToFBO () const
 
void baseLevelWasBoundToFBO ()
 
void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const override
 
- Public Member Functions inherited from GrTexture
GrTextureasTexture () override
 
const GrTextureasTexture () const override
 
virtual GrBackendTexture getBackendTexture () const =0
 
virtual void textureParamsModified ()=0
 
GrTextureType textureType () const
 
bool hasRestrictedSampling () const
 
void markMipmapsDirty ()
 
void markMipmapsClean ()
 
skgpu::Mipmapped mipmapped () const
 
bool mipmapsAreDirty () const
 
GrMipmapStatus mipmapStatus () const
 
int maxMipmapLevel () const
 
- Public Member Functions inherited from GrSurface
SkISize dimensions () const
 
int width () const
 
int height () const
 
SkRect getBoundsRect () const
 
virtual GrBackendFormat backendFormat () const =0
 
void setRelease (sk_sp< skgpu::RefCntedCallback > releaseHelper)
 
void setRelease (ReleaseProc proc, ReleaseCtx ctx)
 
virtual GrTextureasTexture ()
 
virtual const GrTextureasTexture () const
 
virtual GrRenderTargetasRenderTarget ()
 
virtual const GrRenderTargetasRenderTarget () 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
 
virtual void dumpMemoryStatistics (SkTraceMemoryDump *traceMemoryDump) const
 
virtual const char * getResourceType () const =0
 
- 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 GrTextureType TextureTypeFromTarget (GrGLenum textureTarget)
 
static sk_sp< GrGLTextureMakeWrapped (GrGLGpu *, GrMipmapStatus, const Desc &, sk_sp< GrGLTextureParameters >, GrWrapCacheable, GrIOType, std::string_view label)
 
- Static Public Member Functions inherited from GrTexture
static bool StealBackendTexture (sk_sp< GrTexture >, GrBackendTexture *, SkImages::BackendTextureReleaseProc *)
 
static void ComputeScratchKey (const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, skgpu::ScratchKey *key)
 
- 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

 GrGLTexture (GrGLGpu *, const Desc &, sk_sp< GrGLTextureParameters >, GrMipmapStatus, std::string_view label)
 
 GrGLTexture (GrGLGpu *, const Desc &, GrMipmapStatus, sk_sp< GrGLTextureParameters >, GrWrapCacheable, GrIOType, std::string_view label)
 
void init (const Desc &)
 
void onAbandon () override
 
void onRelease () override
 
bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *) override
 
void onSetLabel () override
 
- Protected Member Functions inherited from GrTexture
 GrTexture (GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
 
virtual bool onStealBackendTexture (GrBackendTexture *, SkImages::BackendTextureReleaseProc *)=0
 
void computeScratchKey (skgpu::ScratchKey *) const 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 onRelease ()
 
virtual void onAbandon ()
 
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
 

Additional Inherited Members

- Public Types inherited from GrSurface
typedef void * ReleaseCtx
 
typedef void(* ReleaseProc) (ReleaseCtx)
 
- Public Types inherited from GrIORef< GrGpuResource >
enum  LastRemovedRef
 

Detailed Description

Definition at line 20 of file GrGLTexture.h.

Constructor & Destructor Documentation

◆ GrGLTexture() [1/3]

GrGLTexture::GrGLTexture ( GrGLGpu gpu,
skgpu::Budgeted  budgeted,
const Desc desc,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)

Definition at line 50 of file GrGLTexture.cpp.

55 : GrSurface(gpu, desc.fSize, desc.fIsProtected, label)
56 , GrTexture(gpu,
57 desc.fSize,
58 desc.fIsProtected,
61 label)
62 , fParameters(sk_make_sp<GrGLTextureParameters>()) {
63 this->init(desc);
64 this->registerWithCache(budgeted);
65 if (GrGLFormatIsCompressed(desc.fFormat)) {
66 this->setReadOnly();
67 }
68}
bool GrGLFormatIsCompressed(GrGLFormat format)
Definition: GrGLUtil.cpp:812
void init(const Desc &)
static GrTextureType TextureTypeFromTarget(GrGLenum textureTarget)
Definition: GrGLTexture.cpp:23
void registerWithCache(skgpu::Budgeted)
GrSurface(GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
Definition: GrSurface.h:140
void setReadOnly()
Definition: GrSurface.h:130
GrMipmapStatus mipmapStatus() const
Definition: GrTexture.h:66
GrTexture(GrGpu *, const SkISize &, GrProtected, GrTextureType, GrMipmapStatus, std::string_view label)
Definition: GrTexture.cpp:42

◆ ~GrGLTexture()

GrGLTexture::~GrGLTexture ( )
inlineoverride

Definition at line 35 of file GrGLTexture.h.

35{}

◆ GrGLTexture() [2/3]

GrGLTexture::GrGLTexture ( GrGLGpu gpu,
const Desc desc,
sk_sp< GrGLTextureParameters parameters,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
protected

Definition at line 89 of file GrGLTexture.cpp.

94 : GrSurface(gpu, desc.fSize, desc.fIsProtected, label)
95 , GrTexture(gpu,
96 desc.fSize,
97 desc.fIsProtected,
100 label) {
102 fParameters = parameters ? std::move(parameters) : sk_make_sp<GrGLTextureParameters>();
103 this->init(desc);
104}
#define SkASSERT(cond)
Definition: SkAssert.h:116
sk_sp< T > sk_make_sp(Args &&... args)
Definition: SkRefCnt.h:371
GrGLTextureParameters * parameters()
Definition: GrGLTexture.h:44

◆ GrGLTexture() [3/3]

GrGLTexture::GrGLTexture ( GrGLGpu gpu,
const Desc desc,
GrMipmapStatus  mipmapStatus,
sk_sp< GrGLTextureParameters parameters,
GrWrapCacheable  cacheable,
GrIOType  ioType,
std::string_view  label 
)
protected

Definition at line 70 of file GrGLTexture.cpp.

73 : GrSurface(gpu, desc.fSize, desc.fIsProtected, label)
74 , GrTexture(gpu,
75 desc.fSize,
76 desc.fIsProtected,
79 label)
80 , fParameters(std::move(parameters)) {
81 SkASSERT(fParameters);
82 this->init(desc);
83 this->registerWithCacheWrapped(cacheable);
84 if (ioType == kRead_GrIOType) {
85 this->setReadOnly();
86 }
87}
@ kRead_GrIOType
Definition: GrTypesPriv.h:403
void registerWithCacheWrapped(GrWrapCacheable)

Member Function Documentation

◆ backendFormat()

GrBackendFormat GrGLTexture::backendFormat ( ) const
overridevirtual

Implements GrSurface.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 145 of file GrGLTexture.cpp.

145 {
148}
static GrGLenum target_from_texture_type(GrTextureType type)
Definition: GrGLTexture.cpp:35
static constexpr GrGLenum GrGLFormatToEnum(GrGLFormat format)
Definition: GrGLUtil.h:445
GrTextureType textureType() const
Definition: GrTexture.h:55
SK_API GrBackendFormat MakeGL(GrGLenum format, GrGLenum target)

◆ baseLevelWasBoundToFBO()

void GrGLTexture::baseLevelWasBoundToFBO ( )
inline

Definition at line 53 of file GrGLTexture.h.

53{ fBaseLevelHasBeenBoundToFBO = true; }

◆ dumpMemoryStatistics()

void GrGLTexture::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 186 of file GrGLTexture.cpp.

186 {
187 // Don't check this->fRefsWrappedObjects, as we might be the base of a GrGLTextureRenderTarget
188 // which is multiply inherited from both ourselves and a texture. In these cases, one part
189 // (texture, rt) may be wrapped, while the other is owned by Skia.
190 bool refsWrappedTextureObjects =
191 this->fTextureIDOwnership == GrBackendObjectOwnership::kBorrowed;
192 if (refsWrappedTextureObjects && !traceMemoryDump->shouldDumpWrappedObjects()) {
193 return;
194 }
195
196 size_t size = GrSurface::ComputeSize(this->backendFormat(), this->dimensions(), 1,
197 this->mipmapped());
198
199 // Dump as skia/gpu_resources/resource_#/texture, to avoid conflicts in the
200 // GrGLTextureRenderTarget case, where multiple things may dump to the same resource. This
201 // has no downside in the normal case.
202 SkString resourceName = this->getResourceName();
203 resourceName.append("/texture");
204
205 // As we are only dumping our texture memory (not any additional memory tracked by classes
206 // which may inherit from us), specifically call GrGLTexture::gpuMemorySize to avoid
207 // hitting an override.
208 this->dumpMemoryStatisticsPriv(traceMemoryDump, resourceName, "Texture", size);
209
211 texture_id.appendU32(this->textureID());
212 traceMemoryDump->setMemoryBacking(resourceName.c_str(), "gl_texture", texture_id.c_str());
213}
GrBackendFormat backendFormat() const override
GrGLuint textureID() const
Definition: GrGLTexture.h:46
void dumpMemoryStatisticsPriv(SkTraceMemoryDump *traceMemoryDump, const SkString &resourceName, const char *type, size_t size) const
SkString getResourceName() const
SkISize dimensions() const
Definition: GrSurface.h:27
static size_t ComputeSize(const GrBackendFormat &, SkISize dimensions, int colorSamplesPerPixel, skgpu::Mipmapped, bool binSize=false)
Definition: GrSurface.cpp:21
skgpu::Mipmapped mipmapped() const
Definition: GrTexture.h:62
void append(const char text[])
Definition: SkString.h:203
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
int64_t texture_id

◆ format()

GrGLFormat GrGLTexture::format ( ) const
inline

Definition at line 50 of file GrGLTexture.h.

50{ return fFormat; }

◆ getBackendTexture()

GrBackendTexture GrGLTexture::getBackendTexture ( ) const
overridevirtual

Implements GrTexture.

Definition at line 134 of file GrGLTexture.cpp.

134 {
136 info.fTarget = target_from_texture_type(this->textureType());
137 info.fID = fID;
138 info.fFormat = GrGLFormatToEnum(fFormat);
139 info.fProtected = skgpu::Protected(this->isProtected());
140
142 this->width(), this->height(), this->mipmapped(), info, fParameters);
143}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
bool isProtected() const
Definition: GrSurface.h:87
int height() const
Definition: GrSurface.h:37
int width() const
Definition: GrSurface.h:32
SK_API GrBackendTexture MakeGL(int width, int height, skgpu::Mipmapped, const GrGLTextureInfo &glInfo, std::string_view label={})
Protected
Definition: GpuTypes.h:61
GrGLuint fID
Definition: GrGLTypes.h:182

◆ hasBaseLevelBeenBoundToFBO()

bool GrGLTexture::hasBaseLevelBeenBoundToFBO ( ) const
inline

Definition at line 52 of file GrGLTexture.h.

52{ return fBaseLevelHasBeenBoundToFBO; }

◆ init()

void GrGLTexture::init ( const Desc desc)
protected

Definition at line 106 of file GrGLTexture.cpp.

106 {
107 SkASSERT(0 != desc.fID);
109 fID = desc.fID;
110 fFormat = desc.fFormat;
111 fTextureIDOwnership = desc.fOwnership;
112}

◆ MakeWrapped()

sk_sp< GrGLTexture > GrGLTexture::MakeWrapped ( GrGLGpu gpu,
GrMipmapStatus  mipmapStatus,
const Desc desc,
sk_sp< GrGLTextureParameters parameters,
GrWrapCacheable  cacheable,
GrIOType  ioType,
std::string_view  label 
)
static

Definition at line 150 of file GrGLTexture.cpp.

156 {
158 gpu, desc, mipmapStatus, std::move(parameters), cacheable, ioType, label));
159}
GrGLTexture(GrGLGpu *, skgpu::Budgeted, const Desc &, GrMipmapStatus, std::string_view label)
Definition: GrGLTexture.cpp:50

◆ onAbandon()

void GrGLTexture::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 129 of file GrGLTexture.cpp.

129 {
130 fID = 0;
132}
void onAbandon() override
Definition: GrSurface.cpp:86

◆ onRelease()

void GrGLTexture::onRelease ( )
overrideprotectedvirtual

Overridden to free GPU resources in the backend API.

Reimplemented from GrGpuResource.

Reimplemented in GrGLTextureRenderTarget.

Definition at line 116 of file GrGLTexture.cpp.

116 {
117 TRACE_EVENT0("skia.gpu", TRACE_FUNC);
118 ATRACE_ANDROID_FRAMEWORK_ALWAYS("Texture release(%u)", this->uniqueID().asUInt());
119
120 if (fID) {
121 if (GrBackendObjectOwnership::kBorrowed != fTextureIDOwnership) {
122 GL_CALL(DeleteTextures(1, &fID));
123 }
124 fID = 0;
125 }
127}
#define GL_CALL(X)
Definition: GrGLTexture.cpp:21
#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt,...)
#define TRACE_FUNC
Definition: SkTraceEvent.h:30
UniqueID uniqueID() const
void onRelease() override
Definition: GrSurface.cpp:81
#define TRACE_EVENT0(category_group, name)
Definition: trace_event.h:131

◆ onSetLabel()

void GrGLTexture::onSetLabel ( )
overrideprotectedvirtual

Implements GrGpuResource.

Definition at line 174 of file GrGLTexture.cpp.

174 {
175 SkASSERT(fID);
176 SkASSERT(fTextureIDOwnership == GrBackendObjectOwnership::kOwned);
177 if (!this->getLabel().empty()) {
178 const std::string label = "_Skia_" + this->getLabel();
179 GrGLGpu* glGpu = static_cast<GrGLGpu*>(this->getGpu());
180 if (glGpu->glCaps().debugSupport()) {
181 GR_GL_CALL(glGpu->glInterface(), ObjectLabel(GR_GL_TEXTURE, fID, -1, label.c_str()));
182 }
183 }
184}
#define GR_GL_TEXTURE
Definition: GrGLDefines.h:639
#define GR_GL_CALL(IFACE, X)
Definition: GrGLUtil.h:381
bool debugSupport() const
Is there support for GL_KHR_debug?
Definition: GrGLCaps.h:359
const GrGLCaps & glCaps() const
Definition: GrGLGpu.h:108
const GrGLInterface * glInterface() const
Definition: GrGLGpu.h:103
std::string getLabel() const
GrGpu * getGpu() const
EMSCRIPTEN_KEEPALIVE void empty()

◆ onStealBackendTexture()

bool GrGLTexture::onStealBackendTexture ( GrBackendTexture backendTexture,
SkImages::BackendTextureReleaseProc releaseProc 
)
overrideprotectedvirtual

Implements GrTexture.

Definition at line 161 of file GrGLTexture.cpp.

162 {
163 *backendTexture = this->getBackendTexture();
164 // Set the release proc to a no-op function. GL doesn't require any special cleanup.
166
167 // It's important that we only abandon this texture's objects, not subclass objects such as
168 // those held by GrGLTextureRenderTarget. Those objects are not being stolen and need to be
169 // cleaned up by us.
171 return true;
172}
static void releaseProc(const void *ptr, void *context)
GrBackendTexture getBackendTexture() const override
void onAbandon() override

◆ parameters()

GrGLTextureParameters * GrGLTexture::parameters ( )
inline

Definition at line 44 of file GrGLTexture.h.

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

◆ target()

GrGLenum GrGLTexture::target ( ) const

Definition at line 114 of file GrGLTexture.cpp.

114{ return target_from_texture_type(this->textureType()); }

◆ textureID()

GrGLuint GrGLTexture::textureID ( ) const
inline

Definition at line 46 of file GrGLTexture.h.

46{ return fID; }

◆ textureParamsModified()

void GrGLTexture::textureParamsModified ( )
inlineoverridevirtual

This function indicates that the texture parameters (wrap mode, filtering, ...) have been changed externally to Skia.

Implements GrTexture.

Definition at line 42 of file GrGLTexture.h.

42{ fParameters->invalidate(); }

◆ TextureTypeFromTarget()

GrTextureType GrGLTexture::TextureTypeFromTarget ( GrGLenum  textureTarget)
static

Definition at line 23 of file GrGLTexture.cpp.

23 {
24 switch (target) {
26 return GrTextureType::k2D;
31 }
32 SK_ABORT("Unexpected texture target");
33}
#define GR_GL_TEXTURE_2D
Definition: GrGLDefines.h:152
#define GR_GL_TEXTURE_RECTANGLE
Definition: GrGLDefines.h:1056
#define GR_GL_TEXTURE_EXTERNAL
Definition: GrGLDefines.h:1052
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
GrGLenum target() const

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