本文整理汇总了C++中entrylist::Iter::prev方法的典型用法代码示例。如果您正苦于以下问题:C++ Iter::prev方法的具体用法?C++ Iter::prev怎么用?C++ Iter::prev使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entrylist::Iter
的用法示例。
在下文中一共展示了Iter::prev方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printStats
void GrResourceCache::printStats() {
int locked = 0;
int scratch = 0;
EntryList::Iter iter;
GrResourceCacheEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart);
for ( ; entry; entry = iter.prev()) {
if (!entry->fResource->isPurgable()) {
++locked;
}
if (entry->fResource->cacheAccess().isScratch()) {
++scratch;
}
}
float countUtilization = (100.f * fEntryCount) / fMaxCount;
float byteUtilization = (100.f * fEntryBytes) / fMaxBytes;
SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
SkDebugf("\t\tEntry Count: current %d (%d locked, %d scratch %.2g%% full), high %d\n",
fEntryCount, locked, scratch, countUtilization, fHighWaterEntryCount);
SkDebugf("\t\tEntry Bytes: current %d (%.2g%% full) high %d\n",
fEntryBytes, byteUtilization, fHighWaterEntryBytes);
}
示例2: purgeAsNeeded
/**
* Destroying a resource may potentially trigger the unlock of additional
* resources which in turn will trigger a nested purge. We block the nested
* purge using the fPurging variable. However, the initial purge will keep
* looping until either all resources in the cache are unlocked or we've met
* the budget. There is an assertion in createAndLock to check against a
* resource's destructor inserting new resources into the cache. If these
* new resources were unlocked before purgeAsNeeded completed it could
* potentially make purgeAsNeeded loop infinitely.
*/
void GrResourceCache::purgeAsNeeded() {
if (!fPurging) {
fPurging = true;
bool withinBudget = false;
bool changed = false;
// The purging process is repeated several times since one pass
// may free up other resources
do {
EntryList::Iter iter;
changed = false;
// Note: the following code relies on the fact that the
// doubly linked list doesn't invalidate its data/pointers
// outside of the specific area where a deletion occurs (e.g.,
// in internalDetach)
GrResourceEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart);
while (NULL != entry) {
GrAutoResourceCacheValidate atcv(this);
if (fEntryCount <= fMaxCount && fEntryBytes <= fMaxBytes) {
withinBudget = true;
break;
}
GrResourceEntry* prev = iter.prev();
if (1 == entry->fResource->getRefCnt()) {
changed = true;
// remove from our cache
fCache.remove(entry->key(), entry);
// remove from our llist
this->internalDetach(entry);
#if GR_DUMP_TEXTURE_UPLOAD
GrPrintf("--- ~resource from cache %p [%d %d]\n",
entry->resource(),
entry->resource()->width(),
entry->resource()->height());
#endif
delete entry;
}
entry = prev;
}
} while (!withinBudget && changed);
fPurging = false;
}
}
示例3: countBytes
size_t GrResourceCache::countBytes(const EntryList& list) {
size_t bytes = 0;
EntryList::Iter iter;
const GrResourceEntry* entry = iter.init(const_cast<EntryList&>(list),
EntryList::Iter::kTail_IterStart);
for ( ; NULL != entry; entry = iter.prev()) {
bytes += entry->resource()->sizeInBytes();
}
return bytes;
}
示例4: printStats
void GrResourceCache::printStats() {
int locked = 0;
EntryList::Iter iter;
GrResourceEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart);
for ( ; NULL != entry; entry = iter.prev()) {
if (entry->fResource->getRefCnt() > 1) {
++locked;
}
}
SkDebugf("Budget: %d items %d bytes\n", fMaxCount, fMaxBytes);
SkDebugf("\t\tEntry Count: current %d (%d locked) high %d\n",
fEntryCount, locked, fHighWaterEntryCount);
SkDebugf("\t\tEntry Bytes: current %d high %d\n",
fEntryBytes, fHighWaterEntryBytes);
SkDebugf("\t\tDetached Entry Count: current %d high %d\n",
fClientDetachedCount, fHighWaterClientDetachedCount);
SkDebugf("\t\tDetached Bytes: current %d high %d\n",
fClientDetachedBytes, fHighWaterClientDetachedBytes);
}
示例5: internalPurge
void GrResourceCache::internalPurge(int extraCount, size_t extraBytes) {
SkASSERT(fPurging);
bool withinBudget = false;
bool changed = false;
// The purging process is repeated several times since one pass
// may free up other resources
do {
EntryList::Iter iter;
changed = false;
// Note: the following code relies on the fact that the
// doubly linked list doesn't invalidate its data/pointers
// outside of the specific area where a deletion occurs (e.g.,
// in internalDetach)
GrResourceCacheEntry* entry = iter.init(fList, EntryList::Iter::kTail_IterStart);
while (entry) {
GrAutoResourceCacheValidate atcv(this);
if ((fEntryCount+extraCount) <= fMaxCount &&
(fEntryBytes+extraBytes) <= fMaxBytes) {
withinBudget = true;
break;
}
GrResourceCacheEntry* prev = iter.prev();
if (entry->fResource->isPurgable()) {
changed = true;
this->deleteResource(entry);
}
entry = prev;
}
} while (!withinBudget && changed);
}