S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL read_only) { mReadOnly = read_only; S64 header_size = (max_size * 2) / 10; S64 max_entries = header_size / TEXTURE_CACHE_ENTRY_SIZE; sCacheMaxEntries = (S32)(llmin((S64)sCacheMaxEntries, max_entries)); header_size = sCacheMaxEntries * TEXTURE_CACHE_ENTRY_SIZE; max_size -= header_size; if (sCacheMaxTexturesSize > 0) sCacheMaxTexturesSize = llmin(sCacheMaxTexturesSize, max_size); else sCacheMaxTexturesSize = max_size; max_size -= sCacheMaxTexturesSize; LL_INFOS("TextureCache") << "Headers: " << sCacheMaxEntries << " Textures size: " << sCacheMaxTexturesSize/(1024*1024) << " MB" << LL_ENDL; setDirNames(location); if (!mReadOnly) { LLFile::mkdir(mTexturesDirName); const char* subdirs = "0123456789abcdef"; for (S32 i=0; i<16; i++) { std::string dirname = mTexturesDirName + gDirUtilp->getDirDelimiter() + subdirs[i]; LLFile::mkdir(dirname); } } readHeaderCache(); purgeTextures(true); // calc mTexturesSize and make some room in the texture cache if we need it return max_size; // unused cache space }
void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) { if(mInitialized) { return ; } setDirNames(location); if (!mReadOnly) { LLFile::mkdir(mObjectCacheDirName); } mCacheSize = llclamp(size, MAX_NUM_OBJECT_ENTRIES, NUM_ENTRIES_TO_PURGE); mMetaInfo.mVersion = cache_version; readCacheHeader(); mInitialized = TRUE ; if(mMetaInfo.mVersion != cache_version) { mMetaInfo.mVersion = cache_version ; if(mReadOnly) //disable cache { clearCacheInMemory(); } else //delete the current cache if the format does not match. { removeCache(); } } }
void LLTextureCache::purgeCache(ELLPath location) { if (!mReadOnly) { setDirNames(location); ll_apr_file_remove(mHeaderEntriesFileName, NULL); ll_apr_file_remove(mHeaderDataFileName, NULL); } purgeAllTextures(true); }
void LLTextureCache::purgeCache(ELLPath location) { LLMutexLock lock(&mHeaderMutex); if (!mReadOnly) { setDirNames(location); llassert_always(mHeaderAPRFile == NULL); LLAPRFile::remove(mHeaderEntriesFileName); LLAPRFile::remove(mHeaderDataFileName); } purgeAllTextures(true); }
void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) { if(!mEnabled) { llwarns << "Not initializing cache: Cache is currently disabled." << llendl; return ; } if(mInitialized) { llwarns << "Cache already initialized." << llendl; return ; } mInitialized = TRUE ; setDirNames(location); if (!mReadOnly) { LLFile::mkdir(mObjectCacheDirName); } mCacheSize = llclamp(size, MIN_ENTRIES_TO_PURGE, MAX_NUM_OBJECT_ENTRIES); mMetaInfo.mVersion = cache_version; readCacheHeader(); if(mMetaInfo.mVersion != cache_version) { mMetaInfo.mVersion = cache_version ; if(mReadOnly) //disable cache { clearCacheInMemory(); } else //delete the current cache if the format does not match. { removeCache(); } } }