GrTextBlob: remove unused hash function; add key() api
Change-Id: I20e4f2168713cbd54c0428c60e38a736cf735df3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/381476
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index bcb80a6..9c0742c 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -1405,9 +1405,6 @@
return blob;
}
-const GrTextBlob::Key& GrTextBlob::GetKey(const GrTextBlob& blob) { return blob.fKey; }
-uint32_t GrTextBlob::Hash(const GrTextBlob::Key& key) { return SkOpts::hash(&key, sizeof(Key)); }
-
void GrTextBlob::addKey(const Key& key) {
fKey = key;
}
diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h
index af4b4b9..2e976d2 100644
--- a/src/gpu/text/GrTextBlob.h
+++ b/src/gpu/text/GrTextBlob.h
@@ -411,8 +411,7 @@
const SkPaint& runPaint,
const GrSDFTControl& control);
- static const Key& GetKey(const GrTextBlob& blob);
- static uint32_t Hash(const Key& key);
+ const Key& key() { return fKey; }
void addKey(const Key& key);
bool hasPerspective() const;
diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp
index 3fbe5c5..d11a7f3 100644
--- a/src/gpu/text/GrTextBlobCache.cpp
+++ b/src/gpu/text/GrTextBlobCache.cpp
@@ -50,7 +50,7 @@
}
void GrTextBlobCache::internalRemove(GrTextBlob* blob) {
- auto id = GrTextBlob::GetKey(*blob).fUniqueID;
+ auto id = blob->key().fUniqueID;
auto* idEntry = fBlobIDCache.find(id);
if (idEntry != nullptr) {
@@ -140,13 +140,13 @@
}
sk_sp<GrTextBlob> GrTextBlobCache::internalAdd(sk_sp<GrTextBlob> blob) {
- auto id = GrTextBlob::GetKey(*blob).fUniqueID;
+ auto id = blob->key().fUniqueID;
auto* idEntry = fBlobIDCache.find(id);
if (!idEntry) {
idEntry = fBlobIDCache.set(id, BlobIDCacheEntry(id));
}
- if (sk_sp<GrTextBlob> alreadyIn = idEntry->find(GrTextBlob::GetKey(*blob)); alreadyIn) {
+ if (sk_sp<GrTextBlob> alreadyIn = idEntry->find(blob->key()); alreadyIn) {
blob = std::move(alreadyIn);
} else {
fBlobList.addToHead(blob.get());
@@ -168,17 +168,17 @@
void GrTextBlobCache::BlobIDCacheEntry::addBlob(sk_sp<GrTextBlob> blob) {
SkASSERT(blob);
- SkASSERT(GrTextBlob::GetKey(*blob).fUniqueID == fID);
- SkASSERT(!this->find(GrTextBlob::GetKey(*blob)));
+ SkASSERT(blob->key().fUniqueID == fID);
+ SkASSERT(!this->find(blob->key()));
fBlobs.emplace_back(std::move(blob));
}
void GrTextBlobCache::BlobIDCacheEntry::removeBlob(GrTextBlob* blob) {
SkASSERT(blob);
- SkASSERT(GrTextBlob::GetKey(*blob).fUniqueID == fID);
+ SkASSERT(blob->key().fUniqueID == fID);
- auto index = this->findBlobIndex(GrTextBlob::GetKey(*blob));
+ auto index = this->findBlobIndex(blob->key());
SkASSERT(index >= 0);
fBlobs.removeShuffle(index);
@@ -191,7 +191,7 @@
int GrTextBlobCache::BlobIDCacheEntry::findBlobIndex(const GrTextBlob::Key& key) const {
for (int i = 0; i < fBlobs.count(); ++i) {
- if (GrTextBlob::GetKey(*fBlobs[i]) == key) {
+ if (fBlobs[i]->key() == key) {
return i;
}
}