LLTextureCache Class Reference

#include <lltexturecache.h>

Inheritance diagram for LLTextureCache:

Inheritance graph
[legend]
Collaboration diagram for LLTextureCache:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 LLTextureCache (bool threaded)
 ~LLTextureCache ()
S32 update (U32 max_time_ms)
void purgeCache (ELLPath location)
S64 initCache (ELLPath location, S64 maxsize, BOOL read_only)
handle_t readFromCache (const LLUUID &id, U32 priority, S32 offset, S32 size, ReadResponder *responder)
bool readComplete (handle_t handle, bool abort)
handle_t writeToCache (const LLUUID &id, U32 priority, U8 *data, S32 datasize, S32 imagesize, WriteResponder *responder)
bool writeComplete (handle_t handle, bool abort=false)
void prioritizeWrite (handle_t handle)
void removeFromCache (const LLUUID &id)
LLTextureCacheWorkergetReader (handle_t handle)
LLTextureCacheWorkergetWriter (handle_t handle)
void lockWorkers ()
void unlockWorkers ()
S32 getNumReads ()
S32 getNumWrites ()

Protected Member Functions

apr_pool_tgetFileAPRPool ()
bool appendToTextureEntryList (const LLUUID &id, S32 size)
std::string getLocalFileName (const LLUUID &id)
std::string getTextureFileName (const LLUUID &id)
void addCompleted (Responder *responder, bool success)

Private Types

typedef std::map< handle_t,
LLTextureCacheWorker * > 
handle_map_t
typedef std::vector< handle_thandle_list_t
typedef std::vector< std::pair<
LLPointer< Responder >, bool > > 
responder_list_t
typedef std::map< S32, LLUUIDindex_map_t
typedef std::map< LLUUID,
S32
id_map_t
typedef std::map< LLUUID,
S32
size_map_t

Private Member Functions

void setDirNames (ELLPath location)
void readHeaderCache (apr_pool_t *poolp=NULL)
void purgeAllTextures (bool purge_directories)
void purgeTextures (bool validate)
S32 getHeaderCacheEntry (const LLUUID &id, bool touch, S32 *imagesize=NULL)
bool removeHeaderCacheEntry (const LLUUID &id)
void lockHeaders ()
void unlockHeaders ()

Private Attributes

LLMutex mWorkersMutex
LLMutex mHeaderMutex
LLMutex mListMutex
apr_pool_tmFileAPRPool
handle_map_t mReaders
handle_map_t mWriters
handle_list_t mPrioritizeWriteList
responder_list_t mCompletedList
BOOL mReadOnly
std::string mHeaderEntriesFileName
std::string mHeaderDataFileName
EntriesInfo mHeaderEntriesInfo
index_map_t mLRU
id_map_t mHeaderIDMap
std::string mTexturesDirName
std::string mTexturesDirEntriesFileName
size_map_t mTexturesSizeMap
S64 mTexturesSizeTotal
LLAtomic32< BOOLmDoPurge

Static Private Attributes

static F32 sHeaderCacheVersion = 1.0f
static U32 sCacheMaxEntries = MAX_REASONABLE_FILE_SIZE / TEXTURE_CACHE_ENTRY_SIZE
static S64 sCacheMaxTexturesSize = 0

Friends

class LLTextureCacheWorker

Classes

struct  EntriesInfo
struct  Entry
class  ReadResponder
class  Responder
class  WriteResponder

Detailed Description

Definition at line 44 of file lltexturecache.h.


Member Typedef Documentation

typedef std::vector<handle_t> LLTextureCache::handle_list_t [private]

Definition at line 133 of file lltexturecache.h.

typedef std::map<handle_t, LLTextureCacheWorker*> LLTextureCache::handle_map_t [private]

Definition at line 129 of file lltexturecache.h.

typedef std::map<LLUUID,S32> LLTextureCache::id_map_t [private]

Definition at line 162 of file lltexturecache.h.

typedef std::map<S32,LLUUID> LLTextureCache::index_map_t [private]

Definition at line 160 of file lltexturecache.h.

typedef std::vector<std::pair<LLPointer<Responder>, bool> > LLTextureCache::responder_list_t [private]

Definition at line 136 of file lltexturecache.h.

typedef std::map<LLUUID,S32> LLTextureCache::size_map_t [private]

Definition at line 168 of file lltexturecache.h.


Constructor & Destructor Documentation

LLTextureCache::LLTextureCache ( bool  threaded  ) 

Definition at line 727 of file lltexturecache.cpp.

References mFileAPRPool, and NULL.

LLTextureCache::~LLTextureCache (  ) 

Definition at line 740 of file lltexturecache.cpp.

References mFileAPRPool.


Member Function Documentation

void LLTextureCache::addCompleted ( Responder responder,
bool  success 
) [protected]

Definition at line 1344 of file lltexturecache.cpp.

References mCompletedList, and mListMutex.

Referenced by LLTextureCacheWorker::finishWork().

bool LLTextureCache::appendToTextureEntryList ( const LLUUID id,
S32  size 
) [protected]

Definition at line 805 of file lltexturecache.cpp.

References getFileAPRPool(), ll_apr_file_write_ex(), llassert_always, mDoPurge, mHeaderMutex, mTexturesDirEntriesFileName, mTexturesSizeMap, mTexturesSizeTotal, NULL, sCacheMaxTexturesSize, and TRUE.

Referenced by LLTextureCacheWorker::doWrite().

apr_pool_t* LLTextureCache::getFileAPRPool (  )  [inline, protected]

Definition at line 106 of file lltexturecache.h.

References mFileAPRPool.

Referenced by appendToTextureEntryList(), LLTextureCacheWorker::doRead(), LLTextureCacheWorker::doWrite(), and getHeaderCacheEntry().

S32 LLTextureCache::getHeaderCacheEntry ( const LLUUID id,
bool  touch,
S32 imagesize = NULL 
) [private]

Definition at line 1175 of file lltexturecache.cpp.

References getFileAPRPool(), ll_apr_file_read_ex(), ll_apr_file_write_ex(), llassert_always, LLTextureCache::EntriesInfo::mEntries, mHeaderEntriesFileName, mHeaderEntriesInfo, mHeaderIDMap, mHeaderMutex, mLRU, mReadOnly, mTexturesSizeMap, NULL, readHeaderCache(), S32, and sCacheMaxEntries.

Referenced by LLTextureCacheWorker::doRead(), and LLTextureCacheWorker::doWrite().

std::string LLTextureCache::getLocalFileName ( const LLUUID id  )  [protected]

Definition at line 789 of file lltexturecache.cpp.

References gDirUtilp, LLDir::getExpandedFilename(), and LL_PATH_SKINS.

Referenced by LLTextureCacheWorker::doRead().

S32 LLTextureCache::getNumReads (  )  [inline]

Definition at line 101 of file lltexturecache.h.

References mReaders.

Referenced by LLGLTexMemBar::draw().

S32 LLTextureCache::getNumWrites (  )  [inline]

Definition at line 102 of file lltexturecache.h.

References mWriters.

Referenced by LLGLTexMemBar::draw().

LLTextureCacheWorker * LLTextureCache::getReader ( handle_t  handle  ) 

Definition at line 1150 of file lltexturecache.cpp.

References mReaders, and NULL.

Referenced by LLTextureCacheWorker::ReadResponder::completed().

std::string LLTextureCache::getTextureFileName ( const LLUUID id  )  [protected]

Definition at line 797 of file lltexturecache.cpp.

References gDirUtilp, LLDir::getDirDelimiter(), and mTexturesDirName.

Referenced by LLTextureCacheWorker::doRead(), LLTextureCacheWorker::doWrite(), purgeTextures(), and removeFromCache().

LLTextureCacheWorker * LLTextureCache::getWriter ( handle_t  handle  ) 

Definition at line 1161 of file lltexturecache.cpp.

References mWriters, and NULL.

Referenced by LLTextureCacheWorker::WriteResponder::completed().

S64 LLTextureCache::initCache ( ELLPath  location,
S64  maxsize,
BOOL  read_only 
)

Definition at line 872 of file lltexturecache.cpp.

References gDirUtilp, LLDir::getDirDelimiter(), i, llendl, llinfos, llmin(), LLFile::mkdir(), mReadOnly, mTexturesDirName, purgeTextures(), readHeaderCache(), S32, sCacheMaxEntries, sCacheMaxTexturesSize, setDirNames(), and TEXTURE_CACHE_ENTRY_SIZE.

Referenced by init_cache().

void LLTextureCache::lockHeaders (  )  [inline, private]

Definition at line 119 of file lltexturecache.h.

References LLMutex::lock(), and mHeaderMutex.

void LLTextureCache::lockWorkers (  )  [inline]

Definition at line 97 of file lltexturecache.h.

References LLMutex::lock(), and mWorkersMutex.

Referenced by LLTextureCacheWorker::WriteResponder::completed(), LLTextureCacheWorker::ReadResponder::completed(), readComplete(), update(), and writeComplete().

void LLTextureCache::prioritizeWrite ( handle_t  handle  ) 

Definition at line 1336 of file lltexturecache.cpp.

References mListMutex, and mPrioritizeWriteList.

Referenced by LLTextureFetchWorker::doWork().

void LLTextureCache::purgeAllTextures ( bool  purge_directories  )  [private]

Definition at line 987 of file lltexturecache.cpp.

References LLDir::deleteFilesInDir(), gDirUtilp, LLDir::getDirDelimiter(), i, ll_apr_file_remove(), mask, mReadOnly, mTexturesDirEntriesFileName, mTexturesDirName, mTexturesSizeMap, NULL, LLFile::rmdir(), and S32.

Referenced by purgeCache(), and purgeTextures().

void LLTextureCache::purgeCache ( ELLPath  location  ) 

Definition at line 860 of file lltexturecache.cpp.

References ll_apr_file_remove(), mHeaderDataFileName, mHeaderEntriesFileName, mReadOnly, NULL, purgeAllTextures(), and setDirNames().

Referenced by purge_cache().

void LLTextureCache::purgeTextures ( bool  validate  )  [private]

Definition at line 1012 of file lltexturecache.cpp.

References getTextureFileName(), LLControlGroup::getU32(), gSavedSettings, ll_apr_file_read_ex(), ll_apr_file_remove(), ll_apr_file_size(), ll_apr_file_write_ex(), llassert, llendl, llinfos, llwarns, mHeaderMutex, mReadOnly, mSize, mTexturesDirEntriesFileName, mTexturesSizeMap, mTexturesSizeTotal, NULL, purgeAllTextures(), S32, sCacheMaxTexturesSize, and LLControlGroup::setU32().

Referenced by initCache(), and writeToCache().

bool LLTextureCache::readComplete ( handle_t  handle,
bool  abort 
)

Definition at line 1263 of file lltexturecache.cpp.

References llassert_always, lockWorkers(), mReaders, and unlockWorkers().

Referenced by LLTextureFetchWorker::deleteOK(), LLTextureFetchWorker::doWork(), LLTextureFetchWorker::finishWork(), and LLTextureFetchWorker::~LLTextureFetchWorker().

LLTextureCache::handle_t LLTextureCache::readFromCache ( const LLUUID id,
U32  priority,
S32  offset,
S32  size,
ReadResponder responder 
)

Definition at line 1249 of file lltexturecache.cpp.

References LLTextureCacheWorker, mReaders, mWorkersMutex, NULL, and LLTextureCacheWorker::read().

Referenced by LLTextureFetchWorker::doWork().

void LLTextureCache::readHeaderCache ( apr_pool_t poolp = NULL  )  [private]

Definition at line 931 of file lltexturecache.cpp.

References i, ll_apr_file_exists(), ll_apr_file_read_ex(), ll_apr_file_write_ex(), LLTextureCache::EntriesInfo::mEntries, mHeaderEntriesFileName, mHeaderEntriesInfo, mHeaderIDMap, mHeaderMutex, mLRU, mReadOnly, mSize, LLTextureCache::EntriesInfo::mVersion, S32, sCacheMaxEntries, and sHeaderCacheVersion.

Referenced by getHeaderCacheEntry(), and initCache().

void LLTextureCache::removeFromCache ( const LLUUID id  ) 

Definition at line 1381 of file lltexturecache.cpp.

References getTextureFileName(), ll_apr_file_remove(), llendl, llwarns, mReadOnly, NULL, and removeHeaderCacheEntry().

Referenced by LLTextureCacheWorker::endWork(), and LLTextureFetchWorker::removeFromCache().

bool LLTextureCache::removeHeaderCacheEntry ( const LLUUID id  )  [private]

Definition at line 1354 of file lltexturecache.cpp.

References ll_apr_file_write_ex(), mHeaderEntriesFileName, mHeaderIDMap, mHeaderMutex, mLRU, mReadOnly, mTexturesSizeMap, NULL, and S32.

Referenced by removeFromCache().

void LLTextureCache::setDirNames ( ELLPath  location  )  [private]

Definition at line 851 of file lltexturecache.cpp.

References cache_filename, entries_filename, gDirUtilp, LLDir::getDirDelimiter(), LLDir::getExpandedFilename(), mHeaderDataFileName, mHeaderEntriesFileName, mTexturesDirEntriesFileName, mTexturesDirName, and textures_dirname.

Referenced by initCache(), and purgeCache().

void LLTextureCache::unlockHeaders (  )  [inline, private]

Definition at line 120 of file lltexturecache.h.

References mHeaderMutex, and LLMutex::unlock().

void LLTextureCache::unlockWorkers (  )  [inline]

Definition at line 98 of file lltexturecache.h.

References mWorkersMutex, and LLMutex::unlock().

Referenced by LLTextureCacheWorker::WriteResponder::completed(), LLTextureCacheWorker::ReadResponder::completed(), readComplete(), update(), and writeComplete().

S32 LLTextureCache::update ( U32  max_time_ms  )  [virtual]

Reimplemented from LLWorkerThread.

Definition at line 748 of file lltexturecache.cpp.

References LLMutex::lock(), lockWorkers(), mCompletedList, mListMutex, mPrioritizeWriteList, mWriters, LLQueuedThread::PRIORITY_HIGH, S32, LLMutex::unlock(), unlockWorkers(), and LLWorkerThread::update().

Referenced by cleanup_app(), LLViewerImageList::decodeAllImages(), main_loop(), and update_texture_fetch().

bool LLTextureCache::writeComplete ( handle_t  handle,
bool  abort = false 
)

Definition at line 1316 of file lltexturecache.cpp.

References llassert_always, lockWorkers(), mWriters, and unlockWorkers().

Referenced by LLTextureFetchWorker::deleteOK(), LLTextureFetchWorker::finishWork(), LLTextureFetchWorker::writeToCacheComplete(), and LLTextureFetchWorker::~LLTextureFetchWorker().

LLTextureCache::handle_t LLTextureCache::writeToCache ( const LLUUID id,
U32  priority,
U8 data,
S32  datasize,
S32  imagesize,
WriteResponder responder 
)

Definition at line 1284 of file lltexturecache.cpp.

References FALSE, llassert_always, LLTextureCacheWorker, mDoPurge, mReadOnly, mWorkersMutex, mWriters, LLQueuedThread::nullHandle(), purgeTextures(), TEXTURE_CACHE_ENTRY_SIZE, and LLTextureCacheWorker::write().

Referenced by LLTextureFetchWorker::doWork().


Friends And Related Function Documentation

friend class LLTextureCacheWorker [friend]

Definition at line 46 of file lltexturecache.h.

Referenced by readFromCache(), and writeToCache().


Member Data Documentation

responder_list_t LLTextureCache::mCompletedList [private]

Definition at line 137 of file lltexturecache.h.

Referenced by addCompleted(), and update().

LLAtomic32<BOOL> LLTextureCache::mDoPurge [private]

Definition at line 171 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), and writeToCache().

apr_pool_t* LLTextureCache::mFileAPRPool [private]

Definition at line 127 of file lltexturecache.h.

Referenced by getFileAPRPool(), LLTextureCache(), and ~LLTextureCache().

std::string LLTextureCache::mHeaderDataFileName [private]

Definition at line 158 of file lltexturecache.h.

Referenced by LLTextureCacheWorker::doRead(), LLTextureCacheWorker::doWrite(), purgeCache(), and setDirNames().

std::string LLTextureCache::mHeaderEntriesFileName [private]

Definition at line 157 of file lltexturecache.h.

Referenced by getHeaderCacheEntry(), purgeCache(), readHeaderCache(), removeHeaderCacheEntry(), and setDirNames().

EntriesInfo LLTextureCache::mHeaderEntriesInfo [private]

Definition at line 159 of file lltexturecache.h.

Referenced by getHeaderCacheEntry(), and readHeaderCache().

id_map_t LLTextureCache::mHeaderIDMap [private]

Definition at line 163 of file lltexturecache.h.

Referenced by getHeaderCacheEntry(), readHeaderCache(), and removeHeaderCacheEntry().

LLMutex LLTextureCache::mHeaderMutex [private]

Definition at line 125 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), getHeaderCacheEntry(), lockHeaders(), purgeTextures(), readHeaderCache(), removeHeaderCacheEntry(), and unlockHeaders().

LLMutex LLTextureCache::mListMutex [private]

Definition at line 126 of file lltexturecache.h.

Referenced by addCompleted(), prioritizeWrite(), and update().

index_map_t LLTextureCache::mLRU [private]

Definition at line 161 of file lltexturecache.h.

Referenced by getHeaderCacheEntry(), readHeaderCache(), and removeHeaderCacheEntry().

handle_list_t LLTextureCache::mPrioritizeWriteList [private]

Definition at line 134 of file lltexturecache.h.

Referenced by prioritizeWrite(), and update().

handle_map_t LLTextureCache::mReaders [private]

Definition at line 130 of file lltexturecache.h.

Referenced by getNumReads(), getReader(), readComplete(), and readFromCache().

BOOL LLTextureCache::mReadOnly [private]

Definition at line 139 of file lltexturecache.h.

Referenced by getHeaderCacheEntry(), initCache(), purgeAllTextures(), purgeCache(), purgeTextures(), readHeaderCache(), removeFromCache(), removeHeaderCacheEntry(), and writeToCache().

std::string LLTextureCache::mTexturesDirEntriesFileName [private]

Definition at line 167 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), purgeAllTextures(), purgeTextures(), and setDirNames().

std::string LLTextureCache::mTexturesDirName [private]

Definition at line 166 of file lltexturecache.h.

Referenced by getTextureFileName(), initCache(), purgeAllTextures(), and setDirNames().

size_map_t LLTextureCache::mTexturesSizeMap [private]

Definition at line 169 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), getHeaderCacheEntry(), purgeAllTextures(), purgeTextures(), and removeHeaderCacheEntry().

S64 LLTextureCache::mTexturesSizeTotal [private]

Definition at line 170 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), and purgeTextures().

LLMutex LLTextureCache::mWorkersMutex [private]

Definition at line 124 of file lltexturecache.h.

Referenced by lockWorkers(), readFromCache(), unlockWorkers(), and writeToCache().

handle_map_t LLTextureCache::mWriters [private]

Definition at line 131 of file lltexturecache.h.

Referenced by getNumWrites(), getWriter(), update(), writeComplete(), and writeToCache().

U32 LLTextureCache::sCacheMaxEntries = MAX_REASONABLE_FILE_SIZE / TEXTURE_CACHE_ENTRY_SIZE [static, private]

Definition at line 175 of file lltexturecache.h.

Referenced by getHeaderCacheEntry(), initCache(), and readHeaderCache().

S64 LLTextureCache::sCacheMaxTexturesSize = 0 [static, private]

Definition at line 176 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), initCache(), and purgeTextures().

F32 LLTextureCache::sHeaderCacheVersion = 1.0f [static, private]

Definition at line 174 of file lltexturecache.h.

Referenced by readHeaderCache().


The documentation for this class was generated from the following files:
Generated on Thu Jul 1 06:11:51 2010 for Second Life Viewer by  doxygen 1.4.7