aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2015-02-19 07:24:21 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-19 07:24:21 -0800
commit8718aafec239c93485e45bbe8fed19d9a8def079 (patch)
tree209402fb1f20c023f822b4af7dd4212e44956821 /src
parent2e4414e60b1f98e1736aa1925cbe181ed37d11e8 (diff)
Rename GrContentKey to GrUniqueKey
Diffstat (limited to 'src')
-rw-r--r--src/effects/SkBlurMaskFilter.cpp12
-rw-r--r--src/effects/SkColorCubeFilter.cpp6
-rwxr-xr-xsrc/gpu/GrContext.cpp12
-rw-r--r--src/gpu/GrGpuResource.cpp22
-rw-r--r--src/gpu/GrGpuResourceCacheAccess.h4
-rw-r--r--src/gpu/GrGpuResourcePriv.h24
-rw-r--r--src/gpu/GrPath.cpp6
-rw-r--r--src/gpu/GrPath.h2
-rw-r--r--src/gpu/GrResourceCache.cpp56
-rw-r--r--src/gpu/GrResourceCache.h68
-rw-r--r--src/gpu/GrStencilAndCoverPathRenderer.cpp2
-rw-r--r--src/gpu/GrStencilAndCoverTextContext.cpp6
-rw-r--r--src/gpu/SkGr.cpp50
-rw-r--r--src/gpu/effects/GrTextureStripAtlas.cpp6
14 files changed, 137 insertions, 139 deletions
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index c2c663fafc..c16cc2d54c 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -756,9 +756,9 @@ bool GrRectBlurEffect::CreateBlurProfileTexture(GrContext *context, float sigma,
texDesc.fHeight = 1;
texDesc.fConfig = kAlpha_8_GrPixelConfig;
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey key;
- GrContentKey::Builder builder(&key, kDomain, 1);
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey key;
+ GrUniqueKey::Builder builder(&key, kDomain, 1);
builder[0] = profileSize;
builder.finish();
@@ -917,9 +917,9 @@ GrFragmentProcessor* GrRRectBlurEffect::Create(GrContext* context, float sigma,
return NULL;
}
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey key;
- GrContentKey::Builder builder(&key, kDomain, 2);
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey key;
+ GrUniqueKey::Builder builder(&key, kDomain, 2);
builder[0] = blurRadius;
builder[1] = cornerRadius;
builder.finish();
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index 31876aa1ec..552d000c96 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -338,9 +338,9 @@ void GrColorCubeEffect::GLProcessor::GenKey(const GrProcessor& proc,
}
GrFragmentProcessor* SkColorCubeFilter::asFragmentProcessor(GrContext* context) const {
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey key;
- GrContentKey::Builder builder(&key, kDomain, 2);
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey key;
+ GrUniqueKey::Builder builder(&key, kDomain, 2);
builder[0] = fUniqueID;
builder[1] = fCache.cubeDimension();
builder.finish();
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 5e46bb49e8..ef80b5b290 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -1582,20 +1582,20 @@ void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes)
fResourceCache->setLimits(maxTextures, maxTextureBytes);
}
-bool GrContext::addResourceToCache(const GrContentKey& key, GrGpuResource* resource) {
+bool GrContext::addResourceToCache(const GrUniqueKey& key, GrGpuResource* resource) {
ASSERT_OWNED_RESOURCE(resource);
if (!resource || resource->wasDestroyed()) {
return false;
}
- return resource->resourcePriv().setContentKey(key);
+ return resource->resourcePriv().setUniqueKey(key);
}
-bool GrContext::isResourceInCache(const GrContentKey& key) const {
- return fResourceCache->hasContentKey(key);
+bool GrContext::isResourceInCache(const GrUniqueKey& key) const {
+ return fResourceCache->hasUniqueKey(key);
}
-GrGpuResource* GrContext::findAndRefCachedResource(const GrContentKey& key) {
- return fResourceCache->findAndRefContentResource(key);
+GrGpuResource* GrContext::findAndRefCachedResource(const GrUniqueKey& key) {
+ return fResourceCache->findAndRefUniqueResource(key);
}
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index d86ec7cafd..0c2c9a1849 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -84,30 +84,30 @@ void GrGpuResource::didChangeGpuMemorySize() const {
get_resource_cache(fGpu)->resourceAccess().didChangeGpuMemorySize(this, oldSize);
}
-void GrGpuResource::removeContentKey() {
- SkASSERT(fContentKey.isValid());
- get_resource_cache(fGpu)->resourceAccess().willRemoveContentKey(this);
- fContentKey.reset();
+void GrGpuResource::removeUniqueKey() {
+ SkASSERT(fUniqueKey.isValid());
+ get_resource_cache(fGpu)->resourceAccess().willRemoveUniqueKey(this);
+ fUniqueKey.reset();
}
-bool GrGpuResource::setContentKey(const GrContentKey& key) {
+bool GrGpuResource::setUniqueKey(const GrUniqueKey& key) {
// Currently this can only be called once and can't be called when the resource is scratch.
SkASSERT(this->internalHasRef());
SkASSERT(key.isValid());
- // Wrapped and uncached resources can never have a content key.
+ // Wrapped and uncached resources can never have a unique key.
if (!this->resourcePriv().isBudgeted()) {
return false;
}
- if (fContentKey.isValid() || this->wasDestroyed()) {
+ if (fUniqueKey.isValid() || this->wasDestroyed()) {
return false;
}
- fContentKey = key;
+ fUniqueKey = key;
- if (!get_resource_cache(fGpu)->resourceAccess().didSetContentKey(this)) {
- fContentKey.reset();
+ if (!get_resource_cache(fGpu)->resourceAccess().didSetUniqueKey(this)) {
+ fUniqueKey.reset();
return false;
}
return true;
@@ -148,7 +148,7 @@ void GrGpuResource::makeBudgeted() {
}
void GrGpuResource::makeUnbudgeted() {
- if (GrGpuResource::kCached_LifeCycle == fLifeCycle && !fContentKey.isValid()) {
+ if (GrGpuResource::kCached_LifeCycle == fLifeCycle && !fUniqueKey.isValid()) {
fLifeCycle = kUncached_LifeCycle;
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
}
diff --git a/src/gpu/GrGpuResourceCacheAccess.h b/src/gpu/GrGpuResourceCacheAccess.h
index 52294cef90..df0ca34bca 100644
--- a/src/gpu/GrGpuResourceCacheAccess.h
+++ b/src/gpu/GrGpuResourceCacheAccess.h
@@ -23,10 +23,10 @@ class GrGpuResource::CacheAccess {
private:
/**
* Is the resource currently cached as scratch? This means it is cached, has a valid scratch
- * key, and does not have a content key.
+ * key, and does not have a unique key.
*/
bool isScratch() const {
- return !fResource->getContentKey().isValid() && fResource->fScratchKey.isValid() &&
+ return !fResource->getUniqueKey().isValid() && fResource->fScratchKey.isValid() &&
fResource->resourcePriv().isBudgeted();
}
diff --git a/src/gpu/GrGpuResourcePriv.h b/src/gpu/GrGpuResourcePriv.h
index 520e217e98..92c53daf0e 100644
--- a/src/gpu/GrGpuResourcePriv.h
+++ b/src/gpu/GrGpuResourcePriv.h
@@ -18,18 +18,18 @@
class GrGpuResource::ResourcePriv {
public:
/**
- * Sets a content key for the resource. If the resource was previously cached as scratch it will
- * be converted to a content resource. Currently this may only be called once per resource. It
- * fails if there is already a resource with the same content key. TODO: make this supplant the
- * resource that currently is using the content key, allow resources' content keys to change,
- * and allow removal of a content key to convert a resource back to scratch.
+ * Sets a unique key for the resource. If the resource was previously cached as scratch it will
+ * be converted to a uniquely-keyed resource. Currently this may only be called once per
+ * resource. It fails if there is already a resource with the same unique key. TODO: make this
+ * supplant the resource that currently is using the unique key, allow resources' unique keys
+ * to change, and allow removal of a unique key to convert a resource back to scratch.
*/
- bool setContentKey(const GrContentKey& contentKey) {
- return fResource->setContentKey(contentKey);
+ bool setUniqueKey(const GrUniqueKey& key) {
+ return fResource->setUniqueKey(key);
}
- /** Removes the content key from a resource */
- void removeContentKey() { return fResource->removeContentKey(); }
+ /** Removes the unique key from a resource */
+ void removeUniqueKey() { return fResource->removeUniqueKey(); }
/**
* If the resource is uncached make it cached. Has no effect on resources that are wrapped or
@@ -39,7 +39,7 @@ public:
/**
* If the resource is cached make it uncached. Has no effect on resources that are wrapped or
- * already uncached. Furthermore, resources with content keys cannot be made unbudgeted.
+ * already uncached. Furthermore, resources with unique keys cannot be made unbudgeted.
*/
void makeUnbudgeted() { fResource->makeUnbudgeted(); }
@@ -48,14 +48,14 @@ public:
*/
bool isBudgeted() const {
bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle;
- SkASSERT(ret || !fResource->getContentKey().isValid());
+ SkASSERT(ret || !fResource->getUniqueKey().isValid());
return ret;
}
/**
* If this resource can be used as a scratch resource this returns a valid scratch key.
* Otherwise it returns a key for which isNullScratch is true. The resource may currently be
- * used as a content resource rather than scratch. Check isScratch().
+ * used as a uniquely keyed resource rather than scratch. Check isScratch().
*/
const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; }
diff --git a/src/gpu/GrPath.cpp b/src/gpu/GrPath.cpp
index a069b0ad1e..3a66865c6e 100644
--- a/src/gpu/GrPath.cpp
+++ b/src/gpu/GrPath.cpp
@@ -13,9 +13,9 @@ template<int NumBits> static uint64_t get_top_n_float_bits(float f) {
return floatBits >> (32 - NumBits);
}
-void GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrContentKey* key) {
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey::Builder builder(key, kDomain, 3);
+void GrPath::ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrUniqueKey* key) {
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey::Builder builder(key, kDomain, 3);
*reinterpret_cast<uint64_t*>(&builder[0]) = ComputeStrokeKey(stroke);
builder[2] = path.getGenerationID();
}
diff --git a/src/gpu/GrPath.h b/src/gpu/GrPath.h
index 56e26b3374..27bbdc0439 100644
--- a/src/gpu/GrPath.h
+++ b/src/gpu/GrPath.h
@@ -27,7 +27,7 @@ public:
fBounds(skPath.getBounds()) {
}
- static void ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrContentKey* key);
+ static void ComputeKey(const SkPath& path, const SkStrokeRec& stroke, GrUniqueKey* key);
static uint64_t ComputeStrokeKey(const SkStrokeRec&);
bool isEqualTo(const SkPath& path, const SkStrokeRec& stroke) {
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 04b7ec5777..8658744d9a 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -13,7 +13,7 @@
#include "SkGr.h"
#include "SkMessageBus.h"
-DECLARE_SKMESSAGEBUS_MESSAGE(GrContentKeyInvalidatedMessage);
+DECLARE_SKMESSAGEBUS_MESSAGE(GrUniqueKeyInvalidatedMessage);
//////////////////////////////////////////////////////////////////////////////
@@ -28,12 +28,12 @@ GrScratchKey::ResourceType GrScratchKey::GenerateResourceType() {
return static_cast<ResourceType>(type);
}
-GrContentKey::Domain GrContentKey::GenerateDomain() {
+GrUniqueKey::Domain GrUniqueKey::GenerateDomain() {
static int32_t gDomain = INHERITED::kInvalidDomain + 1;
int32_t domain = sk_atomic_inc(&gDomain);
if (domain > SK_MaxU16) {
- SkFAIL("Too many Content Key Domains");
+ SkFAIL("Too many GrUniqueKey Domains");
}
return static_cast<Domain>(domain);
@@ -138,8 +138,8 @@ void GrResourceCache::removeResource(GrGpuResource* resource) {
if (resource->resourcePriv().getScratchKey().isValid()) {
fScratchMap.remove(resource->resourcePriv().getScratchKey(), resource);
}
- if (resource->getContentKey().isValid()) {
- fContentHash.remove(resource->getContentKey());
+ if (resource->getUniqueKey().isValid()) {
+ fUniqueHash.remove(resource->getUniqueKey());
}
this->validate();
}
@@ -160,7 +160,7 @@ void GrResourceCache::abandonAll() {
}
SkASSERT(!fScratchMap.count());
- SkASSERT(!fContentHash.count());
+ SkASSERT(!fUniqueHash.count());
SkASSERT(!fCount);
SkASSERT(!this->getResourceCount());
SkASSERT(!fBytes);
@@ -184,7 +184,7 @@ void GrResourceCache::releaseAll() {
}
SkASSERT(!fScratchMap.count());
- SkASSERT(!fContentHash.count());
+ SkASSERT(!fUniqueHash.count());
SkASSERT(!fCount);
SkASSERT(!this->getResourceCount());
SkASSERT(!fBytes);
@@ -237,24 +237,24 @@ void GrResourceCache::willRemoveScratchKey(const GrGpuResource* resource) {
fScratchMap.remove(resource->resourcePriv().getScratchKey(), resource);
}
-void GrResourceCache::willRemoveContentKey(const GrGpuResource* resource) {
+void GrResourceCache::willRemoveUniqueKey(const GrGpuResource* resource) {
// Someone has a ref to this resource in order to invalidate it. When the ref count reaches
// zero we will get a notifyPurgable() and figure out what to do with it.
- SkASSERT(resource->getContentKey().isValid());
- fContentHash.remove(resource->getContentKey());
+ SkASSERT(resource->getUniqueKey().isValid());
+ fUniqueHash.remove(resource->getUniqueKey());
}
-bool GrResourceCache::didSetContentKey(GrGpuResource* resource) {
+bool GrResourceCache::didSetUniqueKey(GrGpuResource* resource) {
SkASSERT(resource);
SkASSERT(this->isInCache(resource));
- SkASSERT(resource->getContentKey().isValid());
+ SkASSERT(resource->getUniqueKey().isValid());
- GrGpuResource* res = fContentHash.find(resource->getContentKey());
+ GrGpuResource* res = fUniqueHash.find(resource->getUniqueKey());
if (NULL != res) {
return false;
}
- fContentHash.add(resource);
+ fUniqueHash.add(resource);
this->validate();
return true;
}
@@ -293,9 +293,9 @@ void GrResourceCache::notifyPurgeable(GrGpuResource* resource) {
}
} else {
// Purge the resource immediately if we're over budget
- // Also purge if the resource has neither a valid scratch key nor a content key.
+ // Also purge if the resource has neither a valid scratch key nor a unique key.
bool noKey = !resource->resourcePriv().getScratchKey().isValid() &&
- !resource->getContentKey().isValid();
+ !resource->getUniqueKey().isValid();
if (!this->overBudget() && !noKey) {
return;
}
@@ -388,12 +388,12 @@ void GrResourceCache::purgeAllUnlocked() {
this->validate();
}
-void GrResourceCache::processInvalidContentKeys(
- const SkTArray<GrContentKeyInvalidatedMessage>& msgs) {
+void GrResourceCache::processInvalidUniqueKeys(
+ const SkTArray<GrUniqueKeyInvalidatedMessage>& msgs) {
for (int i = 0; i < msgs.count(); ++i) {
- GrGpuResource* resource = this->findAndRefContentResource(msgs[i].key());
+ GrGpuResource* resource = this->findAndRefUniqueResource(msgs[i].key());
if (resource) {
- resource->resourcePriv().removeContentKey();
+ resource->resourcePriv().removeUniqueKey();
resource->unref(); // will call notifyPurgeable, if it is indeed now purgeable.
}
}
@@ -435,12 +435,12 @@ void GrResourceCache::validate() const {
int fCouldBeScratch;
int fContent;
const ScratchMap* fScratchMap;
- const ContentHash* fContentHash;
+ const UniqueHash* fUniqueHash;
Stats(const GrResourceCache* cache) {
memset(this, 0, sizeof(*this));
fScratchMap = &cache->fScratchMap;
- fContentHash = &cache->fContentHash;
+ fUniqueHash = &cache->fUniqueHash;
}
void update(GrGpuResource* resource) {
@@ -451,21 +451,21 @@ void GrResourceCache::validate() const {
}
if (resource->cacheAccess().isScratch()) {
- SkASSERT(!resource->getContentKey().isValid());
+ SkASSERT(!resource->getUniqueKey().isValid());
++fScratch;
SkASSERT(fScratchMap->countForKey(resource->resourcePriv().getScratchKey()));
SkASSERT(!resource->cacheAccess().isWrapped());
} else if (resource->resourcePriv().getScratchKey().isValid()) {
SkASSERT(!resource->resourcePriv().isBudgeted() ||
- resource->getContentKey().isValid());
+ resource->getUniqueKey().isValid());
++fCouldBeScratch;
SkASSERT(fScratchMap->countForKey(resource->resourcePriv().getScratchKey()));
SkASSERT(!resource->cacheAccess().isWrapped());
}
- const GrContentKey& contentKey = resource->getContentKey();
- if (contentKey.isValid()) {
+ const GrUniqueKey& uniqueKey = resource->getUniqueKey();
+ if (uniqueKey.isValid()) {
++fContent;
- SkASSERT(fContentHash->find(contentKey) == resource);
+ SkASSERT(fUniqueHash->find(uniqueKey) == resource);
SkASSERT(!resource->cacheAccess().isWrapped());
SkASSERT(resource->resourcePriv().isBudgeted());
}
@@ -506,7 +506,7 @@ void GrResourceCache::validate() const {
SkASSERT(fBudgetedBytes <= fBudgetedHighWaterBytes);
SkASSERT(fBudgetedCount <= fBudgetedHighWaterCount);
#endif
- SkASSERT(stats.fContent == fContentHash.count());
+ SkASSERT(stats.fContent == fUniqueHash.count());
SkASSERT(stats.fScratch + stats.fCouldBeScratch == fScratchMap.count());
// This assertion is not currently valid because we can be in recursive notifyIsPurgeable()
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 0f19b98ece..a908140aaf 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -29,14 +29,15 @@ class SkString;
* 1) A scratch key. This is for resources whose allocations are cached but not their contents.
* Multiple resources can share the same scratch key. This is so a caller can have two
* resource instances with the same properties (e.g. multipass rendering that ping-pongs
- * between two temporary surfaces. The scratch key is set at resource creation time and
+ * between two temporary surfaces). The scratch key is set at resource creation time and
* should never change. Resources need not have a scratch key.
- * 2) A content key. This key represents the contents of the resource rather than just its
- * allocation properties. They may not collide. The content key can be set after resource
+ * 2) A unique key. This key's meaning is specific to the domain that created the key. Only one
+ * resource may have a given unique key. The unique key can be set after resource creation
* creation. Currently it may only be set once and cannot be cleared. This restriction will
* be removed.
+ * A unique key always takes precedence over a scratch key when a resource has both types of keys.
* If a resource has neither key type then it will be deleted as soon as the last reference to it
- * is dropped. If a key has both keys the content key takes precedence.
+ * is dropped.
*/
class GrResourceCache {
public:
@@ -116,10 +117,10 @@ public:
#endif
/**
- * Find a resource that matches a content key.
+ * Find a resource that matches a unique key.
*/
- GrGpuResource* findAndRefContentResource(const GrContentKey& contentKey) {
- GrGpuResource* resource = fContentHash.find(contentKey);
+ GrGpuResource* findAndRefUniqueResource(const GrUniqueKey& key) {
+ GrGpuResource* resource = fUniqueHash.find(key);
if (resource) {
this->refAndMakeResourceMRU(resource);
}
@@ -127,19 +128,19 @@ public:
}
/**
- * Query whether a content key exists in the cache.
+ * Query whether a unique key exists in the cache.
*/
- bool hasContentKey(const GrContentKey& contentKey) const {
- return SkToBool(fContentHash.find(contentKey));
+ bool hasUniqueKey(const GrUniqueKey& key) const {
+ return SkToBool(fUniqueHash.find(key));
}
- /** Purges resources to become under budget and processes resources with invalidated content
+ /** Purges resources to become under budget and processes resources with invalidated unique
keys. */
void purgeAsNeeded() {
- SkTArray<GrContentKeyInvalidatedMessage> invalidKeyMsgs;
- fInvalidContentKeyInbox.poll(&invalidKeyMsgs);
+ SkTArray<GrUniqueKeyInvalidatedMessage> invalidKeyMsgs;
+ fInvalidUniqueKeyInbox.poll(&invalidKeyMsgs);
if (invalidKeyMsgs.count()) {
- this->processInvalidContentKeys(invalidKeyMsgs);
+ this->processInvalidUniqueKeys(invalidKeyMsgs);
}
if (fBudgetedCount <= fMaxCount && fBudgetedBytes <= fMaxBytes) {
return;
@@ -178,15 +179,15 @@ private:
void removeResource(GrGpuResource*);
void notifyPurgeable(GrGpuResource*);
void didChangeGpuMemorySize(const GrGpuResource*, size_t oldSize);
- bool didSetContentKey(GrGpuResource*);
+ bool didSetUniqueKey(GrGpuResource*);
void willRemoveScratchKey(const GrGpuResource*);
- void willRemoveContentKey(const GrGpuResource*);
+ void willRemoveUniqueKey(const GrGpuResource*);
void didChangeBudgetStatus(GrGpuResource*);
void refAndMakeResourceMRU(GrGpuResource*);
/// @}
void internalPurgeAsNeeded();
- void processInvalidContentKeys(const SkTArray<GrContentKeyInvalidatedMessage>&);
+ void processInvalidUniqueKeys(const SkTArray<GrUniqueKeyInvalidatedMessage>&);
void addToNonpurgeableArray(GrGpuResource*);
void removeFromNonpurgeableArray(GrGpuResource*);
bool overBudget() const { return fBudgetedBytes > fMaxBytes || fBudgetedCount > fMaxCount; }
@@ -211,14 +212,12 @@ private:
};
typedef SkTMultiMap<GrGpuResource, GrScratchKey, ScratchMapTraits> ScratchMap;
- struct ContentHashTraits {
- static const GrContentKey& GetKey(const GrGpuResource& r) {
- return r.getContentKey();
- }
+ struct UniqueHashTraits {
+ static const GrUniqueKey& GetKey(const GrGpuResource& r) { return r.getUniqueKey(); }
- static uint32_t Hash(const GrContentKey& key) { return key.hash(); }
+ static uint32_t Hash(const GrUniqueKey& key) { return key.hash(); }
};
- typedef SkTDynamicHash<GrGpuResource, GrContentKey, ContentHashTraits> ContentHash;
+ typedef SkTDynamicHash<GrGpuResource, GrUniqueKey, UniqueHashTraits> UniqueHash;
static bool CompareTimestamp(GrGpuResource* const& a, GrGpuResource* const& b) {
return a->cacheAccess().timestamp() < b->cacheAccess().timestamp();
@@ -228,7 +227,7 @@ private:
return res->cacheAccess().accessCacheIndex();
}
- typedef SkMessageBus<GrContentKeyInvalidatedMessage>::Inbox InvalidContentKeyInbox;
+ typedef SkMessageBus<GrUniqueKeyInvalidatedMessage>::Inbox InvalidUniqueKeyInbox;
typedef SkTDPQueue<GrGpuResource*, CompareTimestamp, AccessResourceIndex> PurgeableQueue;
typedef SkTDArray<GrGpuResource*> ResourceArray;
@@ -241,8 +240,8 @@ private:
// This map holds all resources that can be used as scratch resources.
ScratchMap fScratchMap;
- // This holds all resources that have content keys.
- ContentHash fContentHash;
+ // This holds all resources that have unique keys.
+ UniqueHash fUniqueHash;
// our budget, used in purgeAsNeeded()
int fMaxCount;
@@ -266,7 +265,7 @@ private:
PFOverBudgetCB fOverBudgetCB;
void* fOverBudgetData;
- InvalidContentKeyInbox fInvalidContentKeyInbox;
+ InvalidUniqueKeyInbox fInvalidUniqueKeyInbox;
};
class GrResourceCache::ResourceAccess {
@@ -298,20 +297,19 @@ private:
}
/**
- * Called by GrGpuResources when their content keys change.
+ * Called by GrGpuResources when their unique keys change.
*
* This currently returns a bool and fails when an existing resource has a key that collides
- * with the new content key. In the future it will null out the content key for the existing
- * resource. The failure is a temporary measure taken because duties are split between two
- * cache objects currently.
+ * with the new key. In the future it will null out the unique key for the existing resource.
+ * The failure is a temporary measure which will be fixed soon.
*/
- bool didSetContentKey(GrGpuResource* resource) { return fCache->didSetContentKey(resource); }
+ bool didSetUniqueKey(GrGpuResource* resource) { return fCache->didSetUniqueKey(resource); }
/**
- * Called by a GrGpuResource when it removes its content key.
+ * Called by a GrGpuResource when it removes its unique key.
*/
- void willRemoveContentKey(GrGpuResource* resource) {
- return fCache->willRemoveContentKey(resource);
+ void willRemoveUniqueKey(GrGpuResource* resource) {
+ return fCache->willRemoveUniqueKey(resource);
}
/**
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index 1b6a2f7c7e..0cef788355 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -72,7 +72,7 @@ GrStencilAndCoverPathRenderer::onGetStencilSupport(const GrDrawTarget*,
static GrPath* get_gr_path(GrGpu* gpu, const SkPath& skPath, const SkStrokeRec& stroke) {
GrContext* ctx = gpu->getContext();
- GrContentKey key;
+ GrUniqueKey key;
GrPath::ComputeKey(skPath, stroke, &key);
SkAutoTUnref<GrPath> path(static_cast<GrPath*>(ctx->findAndRefCachedResource(key)));
if (NULL == path || !path->isEqualTo(skPath, stroke)) {
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp
index 3061ec6b10..9c3ba6af8a 100644
--- a/src/gpu/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp
@@ -207,9 +207,9 @@ static GrPathRange* get_gr_glyphs(GrContext* ctx,
const SkTypeface* typeface,
const SkDescriptor* desc,
const SkStrokeRec& stroke) {
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey key;
- GrContentKey::Builder builder(&key, kDomain, 4);
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey key;
+ GrUniqueKey::Builder builder(&key, kDomain, 4);
struct GlyphKey {
uint32_t fChecksum;
uint32_t fTypeface;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 5f162cad9a..e353d41b06 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -106,11 +106,11 @@ static Stretch get_stretch_type(const GrContext* ctx, int width, int height,
return kNo_Stretch;
}
-static bool make_stretched_key(const GrContentKey& origKey, Stretch stretch,
- GrContentKey* stretchedKey) {
+static bool make_stretched_key(const GrUniqueKey& origKey, Stretch stretch,
+ GrUniqueKey* stretchedKey) {
if (origKey.isValid() && kNo_Stretch != stretch) {
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey::Builder builder(stretchedKey, origKey, kDomain, 1);
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey::Builder builder(stretchedKey, origKey, kDomain, 1);
builder[0] = stretch;
builder.finish();
return true;
@@ -119,7 +119,7 @@ static bool make_stretched_key(const GrContentKey& origKey, Stretch stretch,
return false;
}
-static void make_unstretched_key(const SkBitmap& bitmap, GrContentKey* key) {
+static void make_unstretched_key(const SkBitmap& bitmap, GrUniqueKey* key) {
// Our id includes the offset, width, and height so that bitmaps created by extractSubset()
// are unique.
uint32_t genID = bitmap.getGenerationID();
@@ -127,8 +127,8 @@ static void make_unstretched_key(const SkBitmap& bitmap, GrContentKey* key) {
uint32_t width = SkToU16(bitmap.width());
uint32_t height = SkToU16(bitmap.height());
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey::Builder builder(key, kDomain, 4);
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey::Builder builder(key, kDomain, 4);
builder[0] = genID;
builder[1] = origin.fX;
builder[2] = origin.fY;
@@ -137,8 +137,8 @@ static void make_unstretched_key(const SkBitmap& bitmap, GrContentKey* key) {
static void make_bitmap_keys(const SkBitmap& bitmap,
Stretch stretch,
- GrContentKey* key,
- GrContentKey* stretchedKey) {
+ GrUniqueKey* key,
+ GrUniqueKey* stretchedKey) {
make_unstretched_key(bitmap, key);
if (kNo_Stretch != stretch) {
make_stretched_key(*key, stretch, stretchedKey);
@@ -158,12 +158,12 @@ namespace {
// When the SkPixelRef genID changes, invalidate a corresponding GrResource described by key.
class BitmapInvalidator : public SkPixelRef::GenIDChangeListener {
public:
- explicit BitmapInvalidator(const GrContentKey& key) : fMsg(key) {}
+ explicit BitmapInvalidator(const GrUniqueKey& key) : fMsg(key) {}
private:
- GrContentKeyInvalidatedMessage fMsg;
+ GrUniqueKeyInvalidatedMessage fMsg;
void onChange() SK_OVERRIDE {
- SkMessageBus<GrContentKeyInvalidatedMessage>::Post(fMsg);
+ SkMessageBus<GrUniqueKeyInvalidatedMessage>::Post(fMsg);
}
};
@@ -171,7 +171,7 @@ private:
static GrTexture* create_texture_for_bmp(GrContext* ctx,
- const GrContentKey& optionalKey,
+ const GrUniqueKey& optionalKey,
GrSurfaceDesc desc,
SkPixelRef* pixelRefForInvalidationNotification,
const void* pixels,
@@ -190,7 +190,7 @@ static GrTexture* create_texture_for_bmp(GrContext* ctx,
// controls whether the scaling is done using nearest or bilerp filtering.
GrTexture* stretch_texture_to_next_pot(GrTexture* inputTexture, Stretch stretch,
SkPixelRef* pixelRef,
- const GrContentKey& optionalKey) {
+ const GrUniqueKey& optionalKey) {
SkASSERT(kNo_Stretch != stretch);
GrContext* context = inputTexture->getContext();
@@ -253,7 +253,7 @@ GrTexture* stretch_texture_to_next_pot(GrTexture* inputTexture, Stretch stretch,
}
#ifndef SK_IGNORE_ETC1_SUPPORT
-static GrTexture *load_etc1_texture(GrContext* ctx, const GrContentKey& optionalKey,
+static GrTexture *load_etc1_texture(GrContext* ctx, const GrUniqueKey& optionalKey,
const SkBitmap &bm, GrSurfaceDesc desc) {
SkAutoTUnref<SkData> data(bm.pixelRef()->refEncodedData());
@@ -302,7 +302,7 @@ static GrTexture *load_etc1_texture(GrContext* ctx, const GrContentKey& optional
}
#endif // SK_IGNORE_ETC1_SUPPORT
-static GrTexture* load_yuv_texture(GrContext* ctx, const GrContentKey& optionalKey,
+static GrTexture* load_yuv_texture(GrContext* ctx, const GrUniqueKey& optionalKey,
const SkBitmap& bm, const GrSurfaceDesc& desc) {
// Subsets are not supported, the whole pixelRef is loaded when using YUV decoding
SkPixelRef* pixelRef = bm.pixelRef();
@@ -404,7 +404,7 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrContentKey& optionalK
static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx,
const SkBitmap& origBitmap,
- const GrContentKey& optionalKey) {
+ const GrUniqueKey& optionalKey) {
SkBitmap tmpBitmap;
const SkBitmap* bitmap = &origBitmap;
@@ -465,8 +465,8 @@ static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx,
static GrTexture* create_bitmap_texture(GrContext* ctx,
const SkBitmap& bmp,
Stretch stretch,
- const GrContentKey& unstretchedKey,
- const GrContentKey& stretchedKey) {
+ const GrUniqueKey& unstretchedKey,
+ const GrUniqueKey& stretchedKey) {
if (kNo_Stretch != stretch) {
SkAutoTUnref<GrTexture> unstretched;
// Check if we have the unstretched version in the cache, if not create it.
@@ -503,11 +503,11 @@ bool GrIsBitmapInCache(const GrContext* ctx,
if (bitmap.isVolatile()) {
return false;
}
- const GrContentKey& key = texture->getContentKey();
+ const GrUniqueKey& key = texture->getUniqueKey();
if (!key.isValid()) {
return false;
}
- GrContentKey stretchedKey;
+ GrUniqueKey stretchedKey;
make_stretched_key(key, stretch, &stretchedKey);
return ctx->isResourceInCache(stretchedKey);
}
@@ -517,7 +517,7 @@ bool GrIsBitmapInCache(const GrContext* ctx,
return false;
}
- GrContentKey key, stretchedKey;
+ GrUniqueKey key, stretchedKey;
make_bitmap_keys(bitmap, stretch, &key, &stretchedKey);
return ctx->isResourceInCache((kNo_Stretch == stretch) ? key : stretchedKey);
}
@@ -533,10 +533,10 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
if (kNo_Stretch == stretch) {
return SkRef(result);
}
- GrContentKey stretchedKey;
+ GrUniqueKey stretchedKey;
// Don't create a key for the resized version if the bmp is volatile.
if (!bitmap.isVolatile()) {
- const GrContentKey& key = result->getContentKey();
+ const GrUniqueKey& key = result->getUniqueKey();
if (key.isValid()) {
make_stretched_key(key, stretch, &stretchedKey);
GrTexture* stretched = ctx->findAndRefCachedTexture(stretchedKey);
@@ -548,7 +548,7 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx,
return stretch_texture_to_next_pot(result, stretch, bitmap.pixelRef(), stretchedKey);
}
- GrContentKey key, resizedKey;
+ GrUniqueKey key, resizedKey;
if (!bitmap.isVolatile()) {
// If the bitmap isn't changing try to find a cached copy first.
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index dfee607c0c..73764199c5 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -195,9 +195,9 @@ void GrTextureStripAtlas::lockTexture() {
texDesc.fHeight = fDesc.fHeight;
texDesc.fConfig = fDesc.fConfig;
- static const GrContentKey::Domain kDomain = GrContentKey::GenerateDomain();
- GrContentKey key;
- GrContentKey::Builder builder(&key, kDomain, 1);
+ static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
+ GrUniqueKey key;
+ GrUniqueKey::Builder builder(&key, kDomain, 1);
builder[0] = static_cast<uint32_t>(fCacheKey);
builder.finish();