Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
skgpu::ScratchKey Class Reference

#include <ResourceKey.h>

Inheritance diagram for skgpu::ScratchKey:
skgpu::ResourceKey

Classes

class  Builder
 

Public Types

typedef uint32_t ResourceType
 

Public Member Functions

 ScratchKey ()
 
 ScratchKey (const ScratchKey &that)
 
ResourceType resourceType () const
 
ScratchKeyoperator= (const ScratchKey &that)
 
bool operator== (const ScratchKey &that) const
 
bool operator!= (const ScratchKey &that) const
 
- Public Member Functions inherited from skgpu::ResourceKey
uint32_t hash () const
 
size_t size () const
 
void reset ()
 
bool isValid () const
 

Static Public Member Functions

static ResourceType GenerateResourceType ()
 

Additional Inherited Members

- Protected Member Functions inherited from skgpu::ResourceKey
 ResourceKey ()
 
bool operator== (const ResourceKey &that) const
 
ResourceKeyoperator= (const ResourceKey &that)
 
uint32_t domain () const
 
size_t dataSize () const
 
const uint32_t * data () const
 
- Static Protected Attributes inherited from skgpu::ResourceKey
static const uint32_t kInvalidDomain = 0
 

Detailed Description

A key used for scratch resources. There are three important rules about scratch keys:

GrTexture* texture[2]; texture[0] = get_scratch_texture(scratchKey); texture[1] = get_scratch_texture(scratchKey); // texture[0] is already owned so we will get a // different one for texture[1] draw_mask(texture[0], path); // draws path mask to texture[0] blur_x(texture[0], texture[1]); // blurs texture[0] in y and stores result in texture[1] blur_y(texture[1], texture[0]); // blurs texture[1] in y and stores result in texture[0] texture[1]->unref(); // texture 1 can now be recycled for the next request with scratchKey consume_blur(texture[0]); texture[0]->unref(); // texture 0 can now be recycled for the next request with scratchKey

Definition at line 197 of file ResourceKey.h.

Member Typedef Documentation

◆ ResourceType

Uniquely identifies the type of resource that is cached as scratch.

Definition at line 200 of file ResourceKey.h.

Constructor & Destructor Documentation

◆ ScratchKey() [1/2]

skgpu::ScratchKey::ScratchKey ( )
inline

Creates an invalid scratch key. It must be initialized using a Builder object before use.

Definition at line 206 of file ResourceKey.h.

206{}

◆ ScratchKey() [2/2]

skgpu::ScratchKey::ScratchKey ( const ScratchKey that)
inline

Definition at line 208 of file ResourceKey.h.

208{ *this = that; }

Member Function Documentation

◆ GenerateResourceType()

ScratchKey::ResourceType skgpu::ScratchKey::GenerateResourceType ( )
static

Generate a unique ResourceType.

Definition at line 16 of file ResourceKey.cpp.

16 {
17 static std::atomic<int32_t> nextType{ResourceKey::kInvalidDomain + 1};
18
19 int32_t type = nextType.fetch_add(1, std::memory_order_relaxed);
20 if (type > SkTo<int32_t>(UINT16_MAX)) {
21 SK_ABORT("Too many Resource Types");
22 }
23
24 return static_cast<ResourceType>(type);
25}
#define SK_ABORT(message,...)
Definition SkAssert.h:70
static const uint32_t kInvalidDomain
Definition ResourceKey.h:95
uint32_t ResourceType

◆ operator!=()

bool skgpu::ScratchKey::operator!= ( const ScratchKey that) const
inline

Definition at line 218 of file ResourceKey.h.

218{ return !(*this == that); }

◆ operator=()

ScratchKey & skgpu::ScratchKey::operator= ( const ScratchKey that)
inline

Definition at line 212 of file ResourceKey.h.

212 {
213 this->ResourceKey::operator=(that);
214 return *this;
215 }
ResourceKey & operator=(const ResourceKey &that)

◆ operator==()

bool skgpu::ScratchKey::operator== ( const ScratchKey that) const
inline

Definition at line 217 of file ResourceKey.h.

217{ return this->ResourceKey::operator==(that); }
bool operator==(const ResourceKey &that) const
Definition ResourceKey.h:99

◆ resourceType()

ResourceType skgpu::ScratchKey::resourceType ( ) const
inline

Definition at line 210 of file ResourceKey.h.

210{ return this->domain(); }
uint32_t domain() const

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