summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturecache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexturecache.cpp')
-rw-r--r--indra/newview/lltexturecache.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index 7a0712f8aa..290ac8dc04 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -742,7 +742,7 @@ LLTextureCache::LLTextureCache(bool threaded)
mHeaderMutex(NULL),
mListMutex(NULL),
mHeaderAPRFile(NULL),
- mReadOnly(FALSE),
+ mReadOnly(TRUE), //do not allow to change the texture cache until setReadOnly() is called.
mTexturesSizeTotal(0),
mDoPurge(FALSE)
{
@@ -929,13 +929,16 @@ U32 LLTextureCache::sCacheMaxEntries = MAX_REASONABLE_FILE_SIZE / TEXTURE_CACHE_
S64 LLTextureCache::sCacheMaxTexturesSize = 0; // no limit
const char* entries_filename = "texture.entries";
const char* cache_filename = "texture.cache";
-const char* textures_dirname = "textures";
+const char* old_textures_dirname = "textures";
+//change the location of the texture cache to prevent from being deleted by old version viewers.
+const char* textures_dirname = "texturecache";
void LLTextureCache::setDirNames(ELLPath location)
{
std::string delem = gDirUtilp->getDirDelimiter();
- mHeaderEntriesFileName = gDirUtilp->getExpandedFilename(location, entries_filename);
- mHeaderDataFileName = gDirUtilp->getExpandedFilename(location, cache_filename);
+
+ mHeaderEntriesFileName = gDirUtilp->getExpandedFilename(location, textures_dirname, entries_filename);
+ mHeaderDataFileName = gDirUtilp->getExpandedFilename(location, textures_dirname, cache_filename);
mTexturesDirName = gDirUtilp->getExpandedFilename(location, textures_dirname);
}
@@ -947,15 +950,37 @@ void LLTextureCache::purgeCache(ELLPath location)
{
setDirNames(location);
llassert_always(mHeaderAPRFile == NULL);
- LLAPRFile::remove(mHeaderEntriesFileName, getLocalAPRFilePool());
- LLAPRFile::remove(mHeaderDataFileName, getLocalAPRFilePool());
+
+ //remove the legacy cache if exists
+ std::string texture_dir = mTexturesDirName ;
+ mTexturesDirName = gDirUtilp->getExpandedFilename(location, old_textures_dirname);
+ if(LLFile::isdir(mTexturesDirName))
+ {
+ std::string file_name = gDirUtilp->getExpandedFilename(location, entries_filename);
+ LLAPRFile::remove(file_name, getLocalAPRFilePool());
+
+ file_name = gDirUtilp->getExpandedFilename(location, cache_filename);
+ LLAPRFile::remove(file_name, getLocalAPRFilePool());
+
+ purgeAllTextures(true);
+ }
+ mTexturesDirName = texture_dir ;
}
+
+ //remove the current texture cache.
purgeAllTextures(true);
}
-S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL read_only)
+//is called in the main thread before initCache(...) is called.
+void LLTextureCache::setReadOnly(BOOL read_only)
{
mReadOnly = read_only;
+}
+
+//called in the main thread.
+S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL disable_texture_cache)
+{
+ llassert_always(getPending() == 0) ; //should not start accessing the texture cache before initialized.
S64 header_size = (max_size * 2) / 10;
S64 max_entries = header_size / TEXTURE_CACHE_ENTRY_SIZE;
@@ -968,6 +993,15 @@ S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL read_only)
sCacheMaxTexturesSize = max_size;
max_size -= sCacheMaxTexturesSize;
+ if(disable_texture_cache) //the texture cache is disabled
+ {
+ llinfos << "The texture cache is disabled!" << llendl ;
+ setReadOnly(TRUE) ;
+ purgeAllTextures(true);
+
+ return max_size ;
+ }
+
LL_INFOS("TextureCache") << "Headers: " << sCacheMaxEntries
<< " Textures size: " << sCacheMaxTexturesSize/(1024*1024) << " MB" << LL_ENDL;
@@ -986,6 +1020,8 @@ S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL read_only)
readHeaderCache();
purgeTextures(true); // calc mTexturesSize and make some room in the texture cache if we need it
+ llassert_always(getPending() == 0) ; //should not start accessing the texture cache before initialized.
+
return max_size; // unused cache space
}