void SkImageRefPool::setRAMUsed(size_t limit) { SkImageRef* ref = fTail; while (NULL != ref && fRAMUsed > limit) { // only purge it if its pixels are unlocked if (0 == ref->getLockCount() && ref->fBitmap.getPixels()) { size_t size = ref->ramUsed(); SkASSERT(size <= fRAMUsed); fRAMUsed -= size; #ifdef DUMP_IMAGEREF_LIFECYCLE SkDebugf("=== ImagePool: purge %s [%d %d %d] bytes=%d heap=%d\n", ref->getURI(), ref->fBitmap.width(), ref->fBitmap.height(), ref->fBitmap.bytesPerPixel(), (int)size, (int)fRAMUsed); #endif // remember the bitmap config (don't call reset), // just clear the pixel memory ref->fBitmap.setPixels(NULL); SkASSERT(NULL == ref->fBitmap.getPixels()); } ref = ref->fPrev; } }
void SkImageRefPool::dump() const { #if defined(SK_DEBUG) || defined(DUMP_IMAGEREF_LIFECYCLE) SkDebugf("ImagePool dump: bugdet: %d used: %d count: %d\n", (int)fRAMBudget, (int)fRAMUsed, fCount); SkImageRef* ref = fHead; while (ref != NULL) { SkDebugf(" [%3d %3d %d] ram=%d data=%d locks=%d %s\n", ref->fBitmap.width(), ref->fBitmap.height(), ref->fBitmap.config(), ref->ramUsed(), (int)ref->fStream->getLength(), ref->getLockCount(), ref->getURI()); ref = ref->fNext; } #endif }