Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
GrTexture Class Referenceabstract

#include <GrTexture.h>

Inheritance diagram for GrTexture:
GrSurface GrGpuResource GrIORef< GrGpuResource > SkNoncopyable GrD3DTexture GrGLTexture GrMockTexture GrMtlTexture GrVkTexture GrD3DTextureRenderTarget GrGLTextureRenderTarget GrMockTextureRenderTarget GrMtlTextureRenderTarget GrVkTextureRenderTarget

Public Member Functions

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

 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
 

Friends

class GrTextureResource
 

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 31 of file GrTexture.h.

Constructor & Destructor Documentation

◆ GrTexture()

GrTexture::GrTexture ( GrGpu gpu,
const SkISize dimensions,
GrProtected  isProtected,
GrTextureType  textureType,
GrMipmapStatus  mipmapStatus,
std::string_view  label 
)
protected

Definition at line 42 of file GrTexture.cpp.

48 : GrSurface(gpu, dimensions, isProtected, label)
49 , fTextureType(textureType)
50 , fMipmapStatus(mipmapStatus) {
51 if (fMipmapStatus == GrMipmapStatus::kNotAllocated) {
52 fMaxMipmapLevel = 0;
53 } else {
54 fMaxMipmapLevel = SkMipmap::ComputeLevelCount(this->width(), this->height());
55 }
57 this->setReadOnly();
58 }
59}
SkISize dimensions() const
Definition: GrSurface.h:27
bool isProtected() const
Definition: GrSurface.h:87
int height() const
Definition: GrSurface.h:37
GrSurface(GrGpu *gpu, const SkISize &dimensions, skgpu::Protected isProtected, std::string_view label)
Definition: GrSurface.h:140
void setReadOnly()
Definition: GrSurface.h:130
int width() const
Definition: GrSurface.h:32
GrMipmapStatus mipmapStatus() const
Definition: GrTexture.h:66
GrTextureType textureType() const
Definition: GrTexture.h:55
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition: SkMipmap.cpp:134

Member Function Documentation

◆ asTexture() [1/2]

const GrTexture * GrTexture::asTexture ( ) const
inlineoverridevirtual

Reimplemented from GrSurface.

Reimplemented in GrMockTextureRenderTarget.

Definition at line 34 of file GrTexture.h.

34{ return this; }

◆ asTexture() [2/2]

GrTexture * GrTexture::asTexture ( )
inlineoverridevirtual
Returns
the texture associated with the surface, may be null.

Reimplemented from GrSurface.

Reimplemented in GrMockTextureRenderTarget.

Definition at line 33 of file GrTexture.h.

33{ return this; }

◆ ComputeScratchKey()

void GrTexture::ComputeScratchKey ( const GrCaps caps,
const GrBackendFormat format,
SkISize  dimensions,
GrRenderable  renderable,
int  sampleCnt,
skgpu::Mipmapped  mipmapped,
GrProtected  isProtected,
skgpu::ScratchKey key 
)
static

Definition at line 105 of file GrTexture.cpp.

112 {
115 SkASSERT(sampleCnt > 0);
116 SkASSERT(1 == sampleCnt || renderable == GrRenderable::kYes);
117
118 SkASSERT(static_cast<uint32_t>(mipmapped) <= 1);
119 SkASSERT(static_cast<uint32_t>(isProtected) <= 1);
120 SkASSERT(static_cast<uint32_t>(renderable) <= 1);
121 SkASSERT(static_cast<uint32_t>(sampleCnt) < (1 << (32 - 3)));
122
123 uint64_t formatKey = caps.computeFormatKey(format);
124
126 builder[0] = dimensions.width();
128 builder[2] = formatKey & 0xFFFFFFFF;
129 builder[3] = (formatKey >> 32) & 0xFFFFFFFF;
130 builder[4] = (static_cast<uint32_t>(mipmapped) << 0)
131 | (static_cast<uint32_t>(isProtected) << 1)
132 | (static_cast<uint32_t>(renderable) << 2)
133 | (static_cast<uint32_t>(sampleCnt) << 3);
134}
#define SkASSERT(cond)
Definition: SkAssert.h:116
virtual uint64_t computeFormatKey(const GrBackendFormat &) const =0
skgpu::Mipmapped mipmapped() const
Definition: GrTexture.h:62
static ResourceType GenerateResourceType()
Definition: ResourceKey.cpp:16
uint32_t ResourceType
Definition: ResourceKey.h:200
uint32_t uint32_t * format
bool isEmpty() const
Definition: SkSize.h:31
constexpr int32_t width() const
Definition: SkSize.h:36
constexpr int32_t height() const
Definition: SkSize.h:37

◆ computeScratchKey()

void GrTexture::computeScratchKey ( skgpu::ScratchKey ) const
overrideprotectedvirtual

Called by the registerWithCache if the resource is available to be used as scratch. Resource subclasses should override this if the instances should be recycled as scratch resources and populate the scratchKey with the key. By default resources are not recycled as scratch.

Reimplemented from GrGpuResource.

Definition at line 91 of file GrTexture.cpp.

91 {
92 if (!this->getGpu()->caps()->isFormatCompressed(this->backendFormat())) {
93 int sampleCount = 1;
95 if (const auto* rt = this->asRenderTarget()) {
96 sampleCount = rt->numSamples();
97 renderable = GrRenderable::kYes;
98 }
100 ComputeScratchKey(*this->getGpu()->caps(), this->backendFormat(), this->dimensions(),
101 renderable, sampleCount, this->mipmapped(), isProtected, key);
102 }
103}
GrGpu * getGpu() const
virtual GrBackendFormat backendFormat() const =0
virtual GrRenderTarget * asRenderTarget()
Definition: GrSurface.h:65
static void ComputeScratchKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, skgpu::ScratchKey *key)
Definition: GrTexture.cpp:105
Renderable
Definition: GpuTypes.h:69

◆ getBackendTexture()

virtual GrBackendTexture GrTexture::getBackendTexture ( ) const
pure virtual

◆ hasRestrictedSampling()

bool GrTexture::hasRestrictedSampling ( ) const
inline

Definition at line 56 of file GrTexture.h.

56 {
58 }
static bool GrTextureTypeHasRestrictedSampling(GrTextureType type)
Definition: GrTypesPriv.h:294

◆ markMipmapsClean()

void GrTexture::markMipmapsClean ( )

Definition at line 31 of file GrTexture.cpp.

31 {
33 fMipmapStatus = GrMipmapStatus::kValid;
34}

◆ markMipmapsDirty()

void GrTexture::markMipmapsDirty ( )

Definition at line 25 of file GrTexture.cpp.

25 {
26 if (GrMipmapStatus::kValid == fMipmapStatus) {
27 fMipmapStatus = GrMipmapStatus::kDirty;
28 }
29}

◆ maxMipmapLevel()

int GrTexture::maxMipmapLevel ( ) const
inline

Definition at line 67 of file GrTexture.h.

67{ return fMaxMipmapLevel; }

◆ mipmapped()

skgpu::Mipmapped GrTexture::mipmapped ( ) const
inline

Definition at line 62 of file GrTexture.h.

62 {
63 return skgpu::Mipmapped(fMipmapStatus != GrMipmapStatus::kNotAllocated);
64 }
Mipmapped
Definition: GpuTypes.h:53

◆ mipmapsAreDirty()

bool GrTexture::mipmapsAreDirty ( ) const
inline

Definition at line 65 of file GrTexture.h.

65{ return fMipmapStatus != GrMipmapStatus::kValid; }

◆ mipmapStatus()

GrMipmapStatus GrTexture::mipmapStatus ( ) const
inline

Definition at line 66 of file GrTexture.h.

66{ return fMipmapStatus; }

◆ onStealBackendTexture()

virtual bool GrTexture::onStealBackendTexture ( GrBackendTexture ,
SkImages::BackendTextureReleaseProc  
)
protectedpure virtual

◆ StealBackendTexture()

bool GrTexture::StealBackendTexture ( sk_sp< GrTexture texture,
GrBackendTexture backendTexture,
SkImages::BackendTextureReleaseProc releaseProc 
)
static

This function steals the backend texture from a uniquely owned GrTexture with no pending IO, passing it out to the caller. The GrTexture is deleted in the process.

Note that if the GrTexture is not uniquely owned (no other refs), or has pending IO, this function will fail.

Definition at line 61 of file GrTexture.cpp.

63 {
64 if (!texture->unique()) {
65 return false;
66 }
67
68 if (!texture->onStealBackendTexture(backendTexture, releaseProc)) {
69 return false;
70 }
71#ifdef SK_DEBUG
72 GrResourceCache* cache = texture->getContext()->priv().getResourceCache();
73 int preCount = cache->getResourceCount();
74#endif
75 // Ensure that the texture will be released by the cache when we drop the last ref.
76 // A texture that has no refs and no keys should be immediately removed.
77 if (texture->getUniqueKey().isValid()) {
78 texture->resourcePriv().removeUniqueKey();
79 }
80 if (texture->resourcePriv().getScratchKey().isValid()) {
81 texture->resourcePriv().removeScratchKey();
82 }
83#ifdef SK_DEBUG
84 texture.reset();
85 int postCount = cache->getResourceCount();
86 SkASSERT(postCount < preCount);
87#endif
88 return true;
89}
static void releaseProc(const void *ptr, void *context)
FlTexture * texture
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191

◆ textureParamsModified()

virtual void GrTexture::textureParamsModified ( )
pure virtual

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

Implemented in GrD3DTexture, GrGLTexture, GrMockTexture, GrMtlTexture, and GrVkTexture.

◆ textureType()

GrTextureType GrTexture::textureType ( ) const
inline

Definition at line 55 of file GrTexture.h.

55{ return fTextureType; }

Friends And Related Function Documentation

◆ GrTextureResource

friend class GrTextureResource
friend

Definition at line 96 of file GrTexture.h.


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