Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Static Protected Attributes | Friends | List of all members
skgpu::ResourceKey Class Reference

#include <ResourceKey.h>

Inheritance diagram for skgpu::ResourceKey:
skgpu::ScratchKey skgpu::UniqueKey skgpu::graphite::GraphiteResourceKey

Classes

class  Builder
 

Public Member Functions

uint32_t hash () const
 
size_t size () const
 
void reset ()
 
bool isValid () const
 

Protected Member Functions

 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

static const uint32_t kInvalidDomain = 0
 

Friends

class ::TestResource
 

Detailed Description

Base class for all gpu Resource cache keys. There are two types of cache keys. Refer to the comments for each key type below.

Definition at line 35 of file ResourceKey.h.

Constructor & Destructor Documentation

◆ ResourceKey()

skgpu::ResourceKey::ResourceKey ( )
inlineprotected

Definition at line 97 of file ResourceKey.h.

97{ this->reset(); }

Member Function Documentation

◆ data()

const uint32_t * skgpu::ResourceKey::data ( ) const
inlineprotected

ptr to the key data, excluding meta-data (hash, domain, etc).

Definition at line 127 of file ResourceKey.h.

127 {
128 this->validate();
129 return &fKey[kMetaDataCnt];
130 }

◆ dataSize()

size_t skgpu::ResourceKey::dataSize ( ) const
inlineprotected

size of the key data, excluding meta-data (hash, domain, etc).

Definition at line 124 of file ResourceKey.h.

124{ return this->size() - 4 * kMetaDataCnt; }
size_t size() const
Definition ResourceKey.h:42

◆ domain()

uint32_t skgpu::ResourceKey::domain ( ) const
inlineprotected

Definition at line 121 of file ResourceKey.h.

121{ return fKey[kDomainAndSize_MetaDataIdx] & 0xffff; }

◆ hash()

uint32_t skgpu::ResourceKey::hash ( ) const
inline

Definition at line 37 of file ResourceKey.h.

37 {
38 this->validate();
39 return fKey[kHash_MetaDataIdx];
40 }

◆ isValid()

bool skgpu::ResourceKey::isValid ( ) const
inline

Definition at line 55 of file ResourceKey.h.

55{ return kInvalidDomain != this->domain(); }
static const uint32_t kInvalidDomain
Definition ResourceKey.h:95
uint32_t domain() const

◆ operator=()

ResourceKey & skgpu::ResourceKey::operator= ( const ResourceKey that)
inlineprotected

Definition at line 106 of file ResourceKey.h.

106 {
107 if (this != &that) {
108 if (!that.isValid()) {
109 this->reset();
110 } else {
111 size_t bytes = that.size();
112 SkASSERT(SkIsAlign4(bytes));
113 fKey.reset(bytes / sizeof(uint32_t));
114 memcpy(fKey.get(), that.fKey.get(), bytes);
115 this->validate();
116 }
117 }
118 return *this;
119 }
static constexpr bool SkIsAlign4(T x)
Definition SkAlign.h:20
#define SkASSERT(cond)
Definition SkAssert.h:116
T * reset(size_t count)

◆ operator==()

bool skgpu::ResourceKey::operator== ( const ResourceKey that) const
inlineprotected

Definition at line 99 of file ResourceKey.h.

99 {
100 // Both keys should be sized to at least contain the meta data. The metadata contains each
101 // key's length. So the second memcmp should only run if the keys have the same length.
102 return 0 == memcmp(fKey.get(), that.fKey.get(), kMetaDataCnt*sizeof(uint32_t)) &&
103 0 == memcmp(&fKey[kMetaDataCnt], &that.fKey[kMetaDataCnt], this->dataSize());
104 }

◆ reset()

void skgpu::ResourceKey::reset ( )
inline

Reset to an invalid key.

Definition at line 49 of file ResourceKey.h.

49 {
50 fKey.reset(kMetaDataCnt);
51 fKey[kHash_MetaDataIdx] = 0;
52 fKey[kDomainAndSize_MetaDataIdx] = kInvalidDomain;
53 }

◆ size()

size_t skgpu::ResourceKey::size ( ) const
inline

Definition at line 42 of file ResourceKey.h.

42 {
43 this->validate();
44 SkASSERT(this->isValid());
45 return this->internalSize();
46 }
bool isValid() const
Definition ResourceKey.h:55

Friends And Related Symbol Documentation

◆ ::TestResource

friend class ::TestResource
friend

Definition at line 169 of file ResourceKey.h.

Member Data Documentation

◆ kInvalidDomain

const uint32_t skgpu::ResourceKey::kInvalidDomain = 0
staticprotected

Definition at line 95 of file ResourceKey.h.


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