Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrUniqueKey Class Reference

A key that allows for exclusive use of a resource for a use case (AKA "domain"). More...

#include <GrResourceKey.h>

Inheritance diagram for GrUniqueKey:
GrResourceKey

Public Types

typedef uint32_t Domain
 

Public Member Functions

 GrUniqueKey ()
 Creates an invalid unique key. More...
 
 GrUniqueKey (const GrUniqueKey &that)
 
GrUniqueKeyoperator= (const GrUniqueKey &that)
 
bool operator== (const GrUniqueKey &that) const
 
bool operator!= (const GrUniqueKey &that) const
 
void setCustomData (sk_sp< SkData > data)
 
SkDatagetCustomData () const
 
 SkDEBUGCODE (const char *tag() const {return fTag.c_str();}) class Builder
 
 Builder (GrUniqueKey *key, const GrUniqueKey &innerKey, Domain domain, int extraData32Cnt, const char *tag=nullptr)
 Used to build a key that wraps another key and adds additional data. More...
 
- Public Member Functions inherited from GrResourceKey
uint32_t hash () const
 
size_t size () const
 

Static Public Member Functions

static Domain GenerateDomain ()
 Generate a Domain for unique keys. More...
 

Private Types

typedef GrResourceKey INHERITED
 

Static Private Member Functions

static int Data32CntForInnerKey (const GrUniqueKey &innerKey)
 

Private Attributes

sk_sp< SkDatafData
 

Additional Inherited Members

- Protected Member Functions inherited from GrResourceKey
void reset ()
 Reset to an invalid key. More...
 
bool operator== (const GrResourceKey &that) const
 
GrResourceKeyoperator= (const GrResourceKey &that)
 
bool isValid () const
 
uint32_t domain () const
 
size_t dataSize () const
 size of the key data, excluding meta-data (hash, domain, etc). More...
 
const uint32_t * data () const
 ptr to the key data, excluding meta-data (hash, domain, etc). More...
 
- Static Protected Attributes inherited from GrResourceKey
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:

  • Only one resource can have a given unique key at a time. Hence, "unique".
  • A resource can have at most one unique key at a time.
  • Unlike scratch keys, multiple requests for a unique key will return the same resource even if the resource already has refs. This key type allows a code path to create cached resources for which it is the exclusive user. The code path creates a domain which it sets on its keys. This guarantees that there are no cross-domain collisions.

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.

Constructor & Destructor Documentation

GrUniqueKey::GrUniqueKey ( )
inline

Creates an invalid unique key.

It must be initialized using a Builder object before use.

Member Function Documentation

GrUniqueKey::Builder ( GrUniqueKey key,
const GrUniqueKey innerKey,
Domain  domain,
int  extraData32Cnt,
const char *  tag = nullptr 
)
inline

Used to build a key that wraps another key and adds additional data.

static Domain GrUniqueKey::GenerateDomain ( )
static

Generate a Domain for unique keys.


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