Rename some of GrThreadSafeCache's member variables
Cached vertex blobs are coming so the old 'view'-based names weren't helpful. Bug: 1108408 Change-Id: Icf09182c8b71b511dad36e006e0f2129ee56635f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328557 Reviewed-by: Adlai Holler <adlai@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
130eef1c24
commit
74ad27d9ef
@ -25,22 +25,22 @@ GrThreadSafeCache::~GrThreadSafeCache() {
|
|||||||
int GrThreadSafeCache::numEntries() const {
|
int GrThreadSafeCache::numEntries() const {
|
||||||
SkAutoSpinlock lock{fSpinLock};
|
SkAutoSpinlock lock{fSpinLock};
|
||||||
|
|
||||||
return fUniquelyKeyedProxyViewMap.count();
|
return fUniquelyKeyedEntryMap.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GrThreadSafeCache::approxBytesUsedForHash() const {
|
size_t GrThreadSafeCache::approxBytesUsedForHash() const {
|
||||||
SkAutoSpinlock lock{fSpinLock};
|
SkAutoSpinlock lock{fSpinLock};
|
||||||
|
|
||||||
return fUniquelyKeyedProxyViewMap.approxBytesUsed();
|
return fUniquelyKeyedEntryMap.approxBytesUsed();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void GrThreadSafeCache::dropAllRefs() {
|
void GrThreadSafeCache::dropAllRefs() {
|
||||||
SkAutoSpinlock lock{fSpinLock};
|
SkAutoSpinlock lock{fSpinLock};
|
||||||
|
|
||||||
fUniquelyKeyedProxyViewMap.reset();
|
fUniquelyKeyedEntryMap.reset();
|
||||||
while (auto tmp = fUniquelyKeyedProxyViewList.head()) {
|
while (auto tmp = fUniquelyKeyedEntryList.head()) {
|
||||||
fUniquelyKeyedProxyViewList.remove(tmp);
|
fUniquelyKeyedEntryList.remove(tmp);
|
||||||
this->recycleEntry(tmp);
|
this->recycleEntry(tmp);
|
||||||
}
|
}
|
||||||
// TODO: should we empty out the fFreeEntryList and reset fEntryAllocator?
|
// TODO: should we empty out the fFreeEntryList and reset fEntryAllocator?
|
||||||
@ -52,7 +52,7 @@ void GrThreadSafeCache::dropUniqueRefs(GrResourceCache* resourceCache) {
|
|||||||
SkAutoSpinlock lock{fSpinLock};
|
SkAutoSpinlock lock{fSpinLock};
|
||||||
|
|
||||||
// Iterate from LRU to MRU
|
// Iterate from LRU to MRU
|
||||||
Entry* cur = fUniquelyKeyedProxyViewList.tail();
|
Entry* cur = fUniquelyKeyedEntryList.tail();
|
||||||
Entry* prev = cur ? cur->fPrev : nullptr;
|
Entry* prev = cur ? cur->fPrev : nullptr;
|
||||||
|
|
||||||
while (cur) {
|
while (cur) {
|
||||||
@ -61,8 +61,8 @@ void GrThreadSafeCache::dropUniqueRefs(GrResourceCache* resourceCache) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cur->fView.proxy()->unique()) {
|
if (cur->fView.proxy()->unique()) {
|
||||||
fUniquelyKeyedProxyViewMap.remove(cur->fKey);
|
fUniquelyKeyedEntryMap.remove(cur->fKey);
|
||||||
fUniquelyKeyedProxyViewList.remove(cur);
|
fUniquelyKeyedEntryList.remove(cur);
|
||||||
this->recycleEntry(cur);
|
this->recycleEntry(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ void GrThreadSafeCache::dropUniqueRefsOlderThan(GrStdSteadyClock::time_point pur
|
|||||||
SkAutoSpinlock lock{fSpinLock};
|
SkAutoSpinlock lock{fSpinLock};
|
||||||
|
|
||||||
// Iterate from LRU to MRU
|
// Iterate from LRU to MRU
|
||||||
Entry* cur = fUniquelyKeyedProxyViewList.tail();
|
Entry* cur = fUniquelyKeyedEntryList.tail();
|
||||||
Entry* prev = cur ? cur->fPrev : nullptr;
|
Entry* prev = cur ? cur->fPrev : nullptr;
|
||||||
|
|
||||||
while (cur) {
|
while (cur) {
|
||||||
@ -85,8 +85,8 @@ void GrThreadSafeCache::dropUniqueRefsOlderThan(GrStdSteadyClock::time_point pur
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cur->fView.proxy()->unique()) {
|
if (cur->fView.proxy()->unique()) {
|
||||||
fUniquelyKeyedProxyViewMap.remove(cur->fKey);
|
fUniquelyKeyedEntryMap.remove(cur->fKey);
|
||||||
fUniquelyKeyedProxyViewList.remove(cur);
|
fUniquelyKeyedEntryList.remove(cur);
|
||||||
this->recycleEntry(cur);
|
this->recycleEntry(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,13 +97,13 @@ void GrThreadSafeCache::dropUniqueRefsOlderThan(GrStdSteadyClock::time_point pur
|
|||||||
|
|
||||||
std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::internalFind(
|
std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::internalFind(
|
||||||
const GrUniqueKey& key) {
|
const GrUniqueKey& key) {
|
||||||
Entry* tmp = fUniquelyKeyedProxyViewMap.find(key);
|
Entry* tmp = fUniquelyKeyedEntryMap.find(key);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
SkASSERT(fUniquelyKeyedProxyViewList.isInList(tmp));
|
SkASSERT(fUniquelyKeyedEntryList.isInList(tmp));
|
||||||
// make the sought out entry the MRU
|
// make the sought out entry the MRU
|
||||||
tmp->fLastAccess = GrStdSteadyClock::now();
|
tmp->fLastAccess = GrStdSteadyClock::now();
|
||||||
fUniquelyKeyedProxyViewList.remove(tmp);
|
fUniquelyKeyedEntryList.remove(tmp);
|
||||||
fUniquelyKeyedProxyViewList.addToHead(tmp);
|
fUniquelyKeyedEntryList.addToHead(tmp);
|
||||||
return { tmp->fView, tmp->fKey.refCustomData() };
|
return { tmp->fView, tmp->fKey.refCustomData() };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,8 +142,8 @@ GrThreadSafeCache::Entry* GrThreadSafeCache::getEntry(const GrUniqueKey& key,
|
|||||||
|
|
||||||
// make 'entry' the MRU
|
// make 'entry' the MRU
|
||||||
entry->fLastAccess = GrStdSteadyClock::now();
|
entry->fLastAccess = GrStdSteadyClock::now();
|
||||||
fUniquelyKeyedProxyViewList.addToHead(entry);
|
fUniquelyKeyedEntryList.addToHead(entry);
|
||||||
fUniquelyKeyedProxyViewMap.add(entry);
|
fUniquelyKeyedEntryMap.add(entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,11 +160,11 @@ void GrThreadSafeCache::recycleEntry(Entry* dead) {
|
|||||||
std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::internalAdd(
|
std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::internalAdd(
|
||||||
const GrUniqueKey& key,
|
const GrUniqueKey& key,
|
||||||
const GrSurfaceProxyView& view) {
|
const GrSurfaceProxyView& view) {
|
||||||
Entry* tmp = fUniquelyKeyedProxyViewMap.find(key);
|
Entry* tmp = fUniquelyKeyedEntryMap.find(key);
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
tmp = this->getEntry(key, view);
|
tmp = this->getEntry(key, view);
|
||||||
|
|
||||||
SkASSERT(fUniquelyKeyedProxyViewMap.find(key));
|
SkASSERT(fUniquelyKeyedEntryMap.find(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { tmp->fView, tmp->fKey.refCustomData() };
|
return { tmp->fView, tmp->fKey.refCustomData() };
|
||||||
@ -216,10 +216,10 @@ std::tuple<GrSurfaceProxyView, sk_sp<SkData>> GrThreadSafeCache::findOrAddWithDa
|
|||||||
void GrThreadSafeCache::remove(const GrUniqueKey& key) {
|
void GrThreadSafeCache::remove(const GrUniqueKey& key) {
|
||||||
SkAutoSpinlock lock{fSpinLock};
|
SkAutoSpinlock lock{fSpinLock};
|
||||||
|
|
||||||
Entry* tmp = fUniquelyKeyedProxyViewMap.find(key);
|
Entry* tmp = fUniquelyKeyedEntryMap.find(key);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
fUniquelyKeyedProxyViewMap.remove(key);
|
fUniquelyKeyedEntryMap.remove(key);
|
||||||
fUniquelyKeyedProxyViewList.remove(tmp);
|
fUniquelyKeyedEntryList.remove(tmp);
|
||||||
this->recycleEntry(tmp);
|
this->recycleEntry(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,9 +134,9 @@ private:
|
|||||||
|
|
||||||
mutable SkSpinlock fSpinLock;
|
mutable SkSpinlock fSpinLock;
|
||||||
|
|
||||||
SkTDynamicHash<Entry, GrUniqueKey> fUniquelyKeyedProxyViewMap SK_GUARDED_BY(fSpinLock);
|
SkTDynamicHash<Entry, GrUniqueKey> fUniquelyKeyedEntryMap SK_GUARDED_BY(fSpinLock);
|
||||||
// The head of this list is the MRU
|
// The head of this list is the MRU
|
||||||
SkTInternalLList<Entry> fUniquelyKeyedProxyViewList SK_GUARDED_BY(fSpinLock);
|
SkTInternalLList<Entry> fUniquelyKeyedEntryList SK_GUARDED_BY(fSpinLock);
|
||||||
|
|
||||||
// TODO: empirically determine this from the skps
|
// TODO: empirically determine this from the skps
|
||||||
static const int kInitialArenaSize = 64 * sizeof(Entry);
|
static const int kInitialArenaSize = 64 * sizeof(Entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user