Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
skgpu::UniqueKey Class Reference

#include <ResourceKey.h>

Inheritance diagram for skgpu::UniqueKey:
skgpu::ResourceKey

Classes

class  Builder
 

Public Types

typedef uint32_t Domain
 

Public Member Functions

 UniqueKey ()
 
 UniqueKey (const UniqueKey &that)
 
UniqueKeyoperator= (const UniqueKey &that)
 
bool operator== (const UniqueKey &that) const
 
bool operator!= (const UniqueKey &that) const
 
void setCustomData (sk_sp< SkData > data)
 
SkDatagetCustomData () const
 
sk_sp< SkDatarefCustomData () const
 
const char * tag () const
 
const uint32_t * data () 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 Domain GenerateDomain ()
 

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 that allows for exclusive use of a resource for a use case (AKA "domain"). There are three rules governing the use of unique keys:

Unique keys preempt scratch keys. While a resource has a unique key it is inaccessible via its scratch key. It can become scratch again if the unique key is removed.

Definition at line 241 of file ResourceKey.h.

Member Typedef Documentation

◆ Domain

typedef uint32_t skgpu::UniqueKey::Domain

Definition at line 243 of file ResourceKey.h.

Constructor & Destructor Documentation

◆ UniqueKey() [1/2]

skgpu::UniqueKey::UniqueKey ( )
inline

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

Definition at line 248 of file ResourceKey.h.

248: fTag(nullptr) {}

◆ UniqueKey() [2/2]

skgpu::UniqueKey::UniqueKey ( const UniqueKey that)
inline

Definition at line 250 of file ResourceKey.h.

250{ *this = that; }

Member Function Documentation

◆ data()

const uint32_t * skgpu::UniqueKey::data ( ) const
inline

Definition at line 268 of file ResourceKey.h.

268{ return this->ResourceKey::data(); }
const uint32_t * data() const
Definition: ResourceKey.h:127

◆ GenerateDomain()

UniqueKey::Domain skgpu::UniqueKey::GenerateDomain ( )
static

Generate a Domain for unique keys.

Definition at line 27 of file ResourceKey.cpp.

27 {
28 static std::atomic<int32_t> nextDomain{ResourceKey::kInvalidDomain + 1};
29
30 int32_t domain = nextDomain.fetch_add(1, std::memory_order_relaxed);
31 if (domain > SkTo<int32_t>(UINT16_MAX)) {
32 SK_ABORT("Too many skgpu::UniqueKey Domains");
33 }
34
35 return static_cast<Domain>(domain);
36}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
static const uint32_t kInvalidDomain
Definition: ResourceKey.h:95
uint32_t domain() const
Definition: ResourceKey.h:121

◆ getCustomData()

SkData * skgpu::UniqueKey::getCustomData ( ) const
inline

Definition at line 263 of file ResourceKey.h.

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

◆ operator!=()

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

Definition at line 260 of file ResourceKey.h.

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

◆ operator=()

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

Definition at line 252 of file ResourceKey.h.

252 {
253 this->ResourceKey::operator=(that);
254 this->setCustomData(sk_ref_sp(that.getCustomData()));
255 fTag = that.fTag;
256 return *this;
257 }
sk_sp< T > sk_ref_sp(T *obj)
Definition: SkRefCnt.h:381
ResourceKey & operator=(const ResourceKey &that)
Definition: ResourceKey.h:106
void setCustomData(sk_sp< SkData > data)
Definition: ResourceKey.h:262

◆ operator==()

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

Definition at line 259 of file ResourceKey.h.

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

◆ refCustomData()

sk_sp< SkData > skgpu::UniqueKey::refCustomData ( ) const
inline

Definition at line 264 of file ResourceKey.h.

264{ return fData; }

◆ setCustomData()

void skgpu::UniqueKey::setCustomData ( sk_sp< SkData data)
inline

Definition at line 262 of file ResourceKey.h.

262{ fData = std::move(data); }
const uint32_t * data() const
Definition: ResourceKey.h:268

◆ tag()

const char * skgpu::UniqueKey::tag ( ) const
inline

Definition at line 266 of file ResourceKey.h.

266{ return fTag; }

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