2014-08-28 16:54:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrResourceKey_DEFINED
|
|
|
|
#define GrResourceKey_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkData.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/gpu/GrTypes.h"
|
|
|
|
#include "include/private/SkOnce.h"
|
|
|
|
#include "include/private/SkTemplates.h"
|
|
|
|
#include "include/private/SkTo.h"
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2018-09-19 14:28:59 +00:00
|
|
|
#include <new>
|
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
uint32_t GrResourceKeyHash(const uint32_t* data, size_t size);
|
|
|
|
|
2015-02-19 15:24:21 +00:00
|
|
|
/**
|
|
|
|
* Base class for all GrGpuResource cache keys. There are two types of cache keys. Refer to the
|
|
|
|
* comments for each key type below.
|
|
|
|
*/
|
2015-01-23 12:24:04 +00:00
|
|
|
class GrResourceKey {
|
2014-08-28 16:54:34 +00:00
|
|
|
public:
|
2015-01-23 12:24:04 +00:00
|
|
|
uint32_t hash() const {
|
|
|
|
this->validate();
|
|
|
|
return fKey[kHash_MetaDataIdx];
|
|
|
|
}
|
2014-12-30 20:50:52 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
size_t size() const {
|
|
|
|
this->validate();
|
2015-01-28 19:39:48 +00:00
|
|
|
SkASSERT(this->isValid());
|
2015-01-23 12:24:04 +00:00
|
|
|
return this->internalSize();
|
|
|
|
}
|
|
|
|
|
2020-10-12 20:05:21 +00:00
|
|
|
/** Used to initialize a key. */
|
|
|
|
class Builder {
|
|
|
|
public:
|
|
|
|
~Builder() { this->finish(); }
|
|
|
|
|
|
|
|
void finish() {
|
|
|
|
if (nullptr == fKey) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
uint32_t* hash = &fKey->fKey[kHash_MetaDataIdx];
|
|
|
|
*hash = GrResourceKeyHash(hash + 1, fKey->internalSize() - sizeof(uint32_t));
|
|
|
|
fKey->validate();
|
|
|
|
fKey = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t& operator[](int dataIdx) {
|
|
|
|
SkASSERT(fKey);
|
|
|
|
SkDEBUGCODE(size_t dataCount = fKey->internalSize() / sizeof(uint32_t) - kMetaDataCnt;)
|
|
|
|
SkASSERT(SkToU32(dataIdx) < dataCount);
|
|
|
|
return fKey->fKey[(int)kMetaDataCnt + dataIdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Builder(GrResourceKey* key, uint32_t domain, int data32Count) : fKey(key) {
|
|
|
|
size_t count = SkToSizeT(data32Count);
|
|
|
|
SkASSERT(domain != kInvalidDomain);
|
|
|
|
key->fKey.reset(kMetaDataCnt + count);
|
|
|
|
size_t size = (count + kMetaDataCnt) * sizeof(uint32_t);
|
|
|
|
SkASSERT(SkToU16(size) == size);
|
|
|
|
SkASSERT(SkToU16(domain) == domain);
|
|
|
|
key->fKey[kDomainAndSize_MetaDataIdx] = domain | (size << 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
GrResourceKey* fKey;
|
|
|
|
};
|
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
protected:
|
|
|
|
static const uint32_t kInvalidDomain = 0;
|
|
|
|
|
|
|
|
GrResourceKey() { this->reset(); }
|
2014-12-30 20:50:52 +00:00
|
|
|
|
|
|
|
/** Reset to an invalid key. */
|
|
|
|
void reset() {
|
|
|
|
fKey.reset(kMetaDataCnt);
|
|
|
|
fKey[kHash_MetaDataIdx] = 0;
|
2015-01-23 12:24:04 +00:00
|
|
|
fKey[kDomainAndSize_MetaDataIdx] = kInvalidDomain;
|
2014-12-30 20:50:52 +00:00
|
|
|
}
|
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
bool operator==(const GrResourceKey& that) const {
|
2020-03-30 15:11:46 +00:00
|
|
|
// Both keys should be sized to at least contain the meta data. The metadata contains each
|
|
|
|
// key's length. So the second memcmp should only run if the keys have the same length.
|
|
|
|
return 0 == memcmp(fKey.get(), that.fKey.get(), kMetaDataCnt*sizeof(uint32_t)) &&
|
|
|
|
0 == memcmp(&fKey[kMetaDataCnt], &that.fKey[kMetaDataCnt], this->dataSize());
|
2015-01-23 12:24:04 +00:00
|
|
|
}
|
2014-12-30 20:50:52 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
GrResourceKey& operator=(const GrResourceKey& that) {
|
2015-01-23 15:17:55 +00:00
|
|
|
if (this != &that) {
|
2019-01-10 17:09:52 +00:00
|
|
|
if (!that.isValid()) {
|
|
|
|
this->reset();
|
|
|
|
} else {
|
|
|
|
size_t bytes = that.size();
|
|
|
|
SkASSERT(SkIsAlign4(bytes));
|
2020-06-01 20:50:19 +00:00
|
|
|
fKey.reset(bytes / sizeof(uint32_t));
|
2019-01-10 17:09:52 +00:00
|
|
|
memcpy(fKey.get(), that.fKey.get(), bytes);
|
|
|
|
this->validate();
|
|
|
|
}
|
2015-01-23 15:17:55 +00:00
|
|
|
}
|
2014-12-30 20:50:52 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
bool isValid() const { return kInvalidDomain != this->domain(); }
|
2014-12-30 20:50:52 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
uint32_t domain() const { return fKey[kDomainAndSize_MetaDataIdx] & 0xffff; }
|
|
|
|
|
2015-01-28 19:39:48 +00:00
|
|
|
/** size of the key data, excluding meta-data (hash, domain, etc). */
|
|
|
|
size_t dataSize() const { return this->size() - 4 * kMetaDataCnt; }
|
2016-04-18 15:09:11 +00:00
|
|
|
|
2015-01-28 19:39:48 +00:00
|
|
|
/** ptr to the key data, excluding meta-data (hash, domain, etc). */
|
|
|
|
const uint32_t* data() const {
|
|
|
|
this->validate();
|
|
|
|
return &fKey[kMetaDataCnt];
|
|
|
|
}
|
|
|
|
|
2018-09-18 17:11:03 +00:00
|
|
|
#ifdef SK_DEBUG
|
|
|
|
void dump() const {
|
|
|
|
if (!this->isValid()) {
|
|
|
|
SkDebugf("Invalid Key\n");
|
|
|
|
} else {
|
|
|
|
SkDebugf("hash: %d ", this->hash());
|
|
|
|
SkDebugf("domain: %d ", this->domain());
|
|
|
|
SkDebugf("size: %dB ", this->internalSize());
|
2020-09-16 16:31:34 +00:00
|
|
|
size_t dataCount = this->internalSize() / sizeof(uint32_t) - kMetaDataCnt;
|
|
|
|
for (size_t i = 0; i < dataCount; ++i) {
|
|
|
|
SkDebugf("%d ", fKey[SkTo<int>(kMetaDataCnt+i)]);
|
2018-09-18 17:11:03 +00:00
|
|
|
}
|
|
|
|
SkDebugf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-30 20:50:52 +00:00
|
|
|
private:
|
2015-01-28 19:39:48 +00:00
|
|
|
enum MetaDataIdx {
|
|
|
|
kHash_MetaDataIdx,
|
|
|
|
// The key domain and size are packed into a single uint32_t.
|
|
|
|
kDomainAndSize_MetaDataIdx,
|
|
|
|
|
|
|
|
kLastMetaDataIdx = kDomainAndSize_MetaDataIdx
|
|
|
|
};
|
|
|
|
static const uint32_t kMetaDataCnt = kLastMetaDataIdx + 1;
|
|
|
|
|
2018-12-21 01:37:55 +00:00
|
|
|
size_t internalSize() const { return fKey[kDomainAndSize_MetaDataIdx] >> 16; }
|
2015-01-23 12:24:04 +00:00
|
|
|
|
|
|
|
void validate() const {
|
2019-01-10 17:09:52 +00:00
|
|
|
SkASSERT(this->isValid());
|
2015-01-23 12:24:04 +00:00
|
|
|
SkASSERT(fKey[kHash_MetaDataIdx] ==
|
|
|
|
GrResourceKeyHash(&fKey[kHash_MetaDataIdx] + 1,
|
|
|
|
this->internalSize() - sizeof(uint32_t)));
|
2015-01-28 19:39:48 +00:00
|
|
|
SkASSERT(SkIsAlign4(this->internalSize()));
|
2015-01-23 12:24:04 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 01:37:55 +00:00
|
|
|
friend class TestResource; // For unit test to access kMetaDataCnt.
|
2015-01-21 17:32:40 +00:00
|
|
|
|
2018-09-10 20:26:51 +00:00
|
|
|
// bmp textures require 5 uint32_t values.
|
|
|
|
SkAutoSTMalloc<kMetaDataCnt + 5, uint32_t> fKey;
|
2014-12-30 20:50:52 +00:00
|
|
|
};
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
/**
|
2015-02-19 15:24:21 +00:00
|
|
|
* A key used for scratch resources. There are three important rules about scratch keys:
|
|
|
|
* * Multiple resources can share the same scratch key. Therefore resources assigned the same
|
|
|
|
* scratch key should be interchangeable with respect to the code that uses them.
|
|
|
|
* * A resource can have at most one scratch key and it is set at resource creation by the
|
|
|
|
* resource itself.
|
|
|
|
* * When a scratch resource is ref'ed it will not be returned from the
|
|
|
|
* cache for a subsequent cache request until all refs are released. This facilitates using
|
|
|
|
* a scratch key for multiple render-to-texture scenarios. An example is a separable blur:
|
|
|
|
*
|
|
|
|
* 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
|
2015-01-23 12:24:04 +00:00
|
|
|
*/
|
|
|
|
class GrScratchKey : public GrResourceKey {
|
|
|
|
private:
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GrResourceKey;
|
2015-01-23 12:24:04 +00:00
|
|
|
|
2014-12-30 20:50:52 +00:00
|
|
|
public:
|
2015-01-23 12:24:04 +00:00
|
|
|
/** Uniquely identifies the type of resource that is cached as scratch. */
|
|
|
|
typedef uint32_t ResourceType;
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
/** Generate a unique ResourceType. */
|
|
|
|
static ResourceType GenerateResourceType();
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
/** Creates an invalid scratch key. It must be initialized using a Builder object before use. */
|
|
|
|
GrScratchKey() {}
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
GrScratchKey(const GrScratchKey& that) { *this = that; }
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
/** reset() returns the key to the invalid state. */
|
|
|
|
using INHERITED::reset;
|
|
|
|
|
|
|
|
using INHERITED::isValid;
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
ResourceType resourceType() const { return this->domain(); }
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
GrScratchKey& operator=(const GrScratchKey& that) {
|
|
|
|
this->INHERITED::operator=(that);
|
|
|
|
return *this;
|
2014-08-28 16:54:34 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 01:37:55 +00:00
|
|
|
bool operator==(const GrScratchKey& that) const { return this->INHERITED::operator==(that); }
|
2015-01-23 12:24:04 +00:00
|
|
|
bool operator!=(const GrScratchKey& that) const { return !(*this == that); }
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
class Builder : public INHERITED::Builder {
|
|
|
|
public:
|
|
|
|
Builder(GrScratchKey* key, ResourceType type, int data32Count)
|
2018-12-21 01:37:55 +00:00
|
|
|
: INHERITED::Builder(key, type, data32Count) {}
|
2015-01-23 12:24:04 +00:00
|
|
|
};
|
|
|
|
};
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
/**
|
2015-02-19 15:24:21 +00:00
|
|
|
* 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.
|
2015-01-23 12:24:04 +00:00
|
|
|
*/
|
2015-02-19 15:24:21 +00:00
|
|
|
class GrUniqueKey : public GrResourceKey {
|
2014-08-28 16:54:34 +00:00
|
|
|
private:
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = GrResourceKey;
|
2015-01-23 12:24:04 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
typedef uint32_t Domain;
|
2015-02-19 15:24:21 +00:00
|
|
|
/** Generate a Domain for unique keys. */
|
2015-01-23 12:24:04 +00:00
|
|
|
static Domain GenerateDomain();
|
|
|
|
|
2015-02-19 15:24:21 +00:00
|
|
|
/** Creates an invalid unique key. It must be initialized using a Builder object before use. */
|
2018-09-18 17:11:03 +00:00
|
|
|
GrUniqueKey() : fTag(nullptr) {}
|
2015-01-23 12:24:04 +00:00
|
|
|
|
2015-02-19 15:24:21 +00:00
|
|
|
GrUniqueKey(const GrUniqueKey& that) { *this = that; }
|
2014-08-28 16:54:34 +00:00
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
/** reset() returns the key to the invalid state. */
|
|
|
|
using INHERITED::reset;
|
|
|
|
|
|
|
|
using INHERITED::isValid;
|
|
|
|
|
2015-02-19 15:24:21 +00:00
|
|
|
GrUniqueKey& operator=(const GrUniqueKey& that) {
|
2015-01-23 12:24:04 +00:00
|
|
|
this->INHERITED::operator=(that);
|
2016-08-02 21:40:46 +00:00
|
|
|
this->setCustomData(sk_ref_sp(that.getCustomData()));
|
2018-03-29 17:40:02 +00:00
|
|
|
fTag = that.fTag;
|
2015-01-23 12:24:04 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-12-21 01:37:55 +00:00
|
|
|
bool operator==(const GrUniqueKey& that) const { return this->INHERITED::operator==(that); }
|
2015-02-19 15:24:21 +00:00
|
|
|
bool operator!=(const GrUniqueKey& that) const { return !(*this == that); }
|
2015-01-23 12:24:04 +00:00
|
|
|
|
2018-12-21 01:37:55 +00:00
|
|
|
void setCustomData(sk_sp<SkData> data) { fData = std::move(data); }
|
|
|
|
SkData* getCustomData() const { return fData.get(); }
|
2020-10-06 18:52:11 +00:00
|
|
|
sk_sp<SkData> refCustomData() const { return fData; }
|
2015-08-04 17:01:58 +00:00
|
|
|
|
2018-03-29 17:40:02 +00:00
|
|
|
const char* tag() const { return fTag; }
|
2017-01-06 17:04:19 +00:00
|
|
|
|
2018-09-18 17:11:03 +00:00
|
|
|
#ifdef SK_DEBUG
|
|
|
|
void dump(const char* label) const {
|
|
|
|
SkDebugf("%s tag: %s\n", label, fTag ? fTag : "None");
|
|
|
|
this->INHERITED::dump();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-23 12:24:04 +00:00
|
|
|
class Builder : public INHERITED::Builder {
|
|
|
|
public:
|
2017-01-06 17:04:19 +00:00
|
|
|
Builder(GrUniqueKey* key, Domain type, int data32Count, const char* tag = nullptr)
|
|
|
|
: INHERITED::Builder(key, type, data32Count) {
|
2018-03-29 17:40:02 +00:00
|
|
|
key->fTag = tag;
|
2017-01-06 17:04:19 +00:00
|
|
|
}
|
2015-01-23 12:24:04 +00:00
|
|
|
|
|
|
|
/** Used to build a key that wraps another key and adds additional data. */
|
2017-01-06 17:04:19 +00:00
|
|
|
Builder(GrUniqueKey* key, const GrUniqueKey& innerKey, Domain domain, int extraData32Cnt,
|
|
|
|
const char* tag = nullptr)
|
|
|
|
: INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + extraData32Cnt) {
|
2015-02-02 21:00:10 +00:00
|
|
|
SkASSERT(&innerKey != key);
|
2015-01-23 12:24:04 +00:00
|
|
|
// add the inner key to the end of the key so that op[] can be indexed normally.
|
2015-01-28 19:39:48 +00:00
|
|
|
uint32_t* innerKeyData = &this->operator[](extraData32Cnt);
|
|
|
|
const uint32_t* srcData = innerKey.data();
|
|
|
|
(*innerKeyData++) = innerKey.domain();
|
|
|
|
memcpy(innerKeyData, srcData, innerKey.dataSize());
|
2018-03-29 17:40:02 +00:00
|
|
|
key->fTag = tag;
|
2015-01-28 19:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-02-19 15:24:21 +00:00
|
|
|
static int Data32CntForInnerKey(const GrUniqueKey& innerKey) {
|
2015-01-28 19:39:48 +00:00
|
|
|
// key data + domain
|
|
|
|
return SkToInt((innerKey.dataSize() >> 2) + 1);
|
2015-01-23 12:24:04 +00:00
|
|
|
}
|
|
|
|
};
|
2015-08-04 17:01:58 +00:00
|
|
|
|
|
|
|
private:
|
2016-08-02 21:40:46 +00:00
|
|
|
sk_sp<SkData> fData;
|
2018-03-29 17:40:02 +00:00
|
|
|
const char* fTag;
|
2014-08-28 16:54:34 +00:00
|
|
|
};
|
|
|
|
|
2015-05-04 17:36:42 +00:00
|
|
|
/**
|
|
|
|
* It is common to need a frequently reused GrUniqueKey where the only requirement is that the key
|
|
|
|
* is unique. These macros create such a key in a thread safe manner so the key can be truly global
|
|
|
|
* and only constructed once.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Place outside of function/class definitions. */
|
2016-04-18 15:09:11 +00:00
|
|
|
#define GR_DECLARE_STATIC_UNIQUE_KEY(name) static SkOnce name##_once
|
2015-05-04 17:36:42 +00:00
|
|
|
|
|
|
|
/** Place inside function where the key is used. */
|
2018-11-30 20:33:19 +00:00
|
|
|
#define GR_DEFINE_STATIC_UNIQUE_KEY(name) \
|
|
|
|
static SkAlignedSTStorage<1, GrUniqueKey> name##_storage; \
|
|
|
|
name##_once(gr_init_static_unique_key_once, &name##_storage); \
|
|
|
|
static const GrUniqueKey& name = *reinterpret_cast<GrUniqueKey*>(name##_storage.get())
|
2015-05-04 17:36:42 +00:00
|
|
|
|
2018-12-21 01:37:55 +00:00
|
|
|
static inline void gr_init_static_unique_key_once(SkAlignedSTStorage<1, GrUniqueKey>* keyStorage) {
|
2015-12-17 16:15:47 +00:00
|
|
|
GrUniqueKey* key = new (keyStorage->get()) GrUniqueKey;
|
2015-05-04 17:36:42 +00:00
|
|
|
GrUniqueKey::Builder builder(key, GrUniqueKey::GenerateDomain(), 0);
|
|
|
|
}
|
|
|
|
|
2015-02-06 19:54:28 +00:00
|
|
|
// The cache listens for these messages to purge junk resources proactively.
|
2015-02-19 15:24:21 +00:00
|
|
|
class GrUniqueKeyInvalidatedMessage {
|
2015-02-06 19:54:28 +00:00
|
|
|
public:
|
2019-01-10 17:09:52 +00:00
|
|
|
GrUniqueKeyInvalidatedMessage() = default;
|
2020-10-28 18:57:53 +00:00
|
|
|
GrUniqueKeyInvalidatedMessage(const GrUniqueKey& key, uint32_t contextUniqueID,
|
|
|
|
bool inThreadSafeCache = false)
|
|
|
|
: fKey(key), fContextID(contextUniqueID), fInThreadSafeCache(inThreadSafeCache) {
|
2018-07-11 19:58:57 +00:00
|
|
|
SkASSERT(SK_InvalidUniqueID != contextUniqueID);
|
|
|
|
}
|
2015-02-19 15:24:21 +00:00
|
|
|
|
2018-07-11 19:58:57 +00:00
|
|
|
GrUniqueKeyInvalidatedMessage(const GrUniqueKeyInvalidatedMessage&) = default;
|
2015-02-19 15:24:21 +00:00
|
|
|
|
2018-07-11 19:58:57 +00:00
|
|
|
GrUniqueKeyInvalidatedMessage& operator=(const GrUniqueKeyInvalidatedMessage&) = default;
|
2015-02-19 15:24:21 +00:00
|
|
|
|
|
|
|
const GrUniqueKey& key() const { return fKey; }
|
2018-10-18 21:27:59 +00:00
|
|
|
uint32_t contextID() const { return fContextID; }
|
2020-10-28 18:57:53 +00:00
|
|
|
bool inThreadSafeCache() const { return fInThreadSafeCache; }
|
2018-07-11 19:58:57 +00:00
|
|
|
|
2015-02-06 19:54:28 +00:00
|
|
|
private:
|
2015-02-19 15:24:21 +00:00
|
|
|
GrUniqueKey fKey;
|
2019-01-10 17:09:52 +00:00
|
|
|
uint32_t fContextID = SK_InvalidUniqueID;
|
2020-10-28 18:57:53 +00:00
|
|
|
bool fInThreadSafeCache = false;
|
2015-02-06 19:54:28 +00:00
|
|
|
};
|
2018-07-11 19:58:57 +00:00
|
|
|
|
2018-12-21 01:37:55 +00:00
|
|
|
static inline bool SkShouldPostMessageToBus(const GrUniqueKeyInvalidatedMessage& msg,
|
|
|
|
uint32_t msgBusUniqueID) {
|
2018-10-18 21:27:59 +00:00
|
|
|
return msg.contextID() == msgBusUniqueID;
|
|
|
|
}
|
|
|
|
|
2014-08-28 16:54:34 +00:00
|
|
|
#endif
|