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 LLString &local_filename, const LLUUID &id, U32 priority, S32 offset, S32 size, ReadResponder *responder)
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, S32id_map_t
typedef std::map< LLUUID, S32size_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
class LLTextureCacheRemoteWorker
class LLTextureCacheLocalFileWorker

Classes

struct  EntriesInfo
struct  Entry
class  ReadResponder
class  Responder
class  WriteResponder


Detailed Description

Definition at line 44 of file lltexturecache.h.


Member Typedef Documentation

Definition at line 134 of file lltexturecache.h.

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

Definition at line 138 of file lltexturecache.h.

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

Definition at line 141 of file lltexturecache.h.

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

Definition at line 165 of file lltexturecache.h.

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

Definition at line 167 of file lltexturecache.h.

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

Definition at line 173 of file lltexturecache.h.


Constructor & Destructor Documentation

LLTextureCache::LLTextureCache ( bool  threaded  ) 

Definition at line 866 of file lltexturecache.cpp.

References mFileAPRPool, and NULL.

LLTextureCache::~LLTextureCache (  ) 

Definition at line 879 of file lltexturecache.cpp.

References mFileAPRPool.


Member Function Documentation

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

void LLTextureCache::purgeCache ( ELLPath  location  ) 

Definition at line 999 of file lltexturecache.cpp.

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

Referenced by LLAppViewer::purgeCache().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1011 of file lltexturecache.cpp.

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

Referenced by LLAppViewer::initCache().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1388 of file lltexturecache.cpp.

References indra::ipc::xml_rpc::handle(), LLTextureCacheLocalFileWorker, mReaders, mWorkersMutex, NULL, and LLTextureCacheWorker::read().

Referenced by LLTextureFetchWorker::doWork().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1402 of file lltexturecache.cpp.

References indra::ipc::xml_rpc::handle(), LLTextureCacheRemoteWorker, mReaders, mWorkersMutex, NULL, and LLTextureCacheWorker::read().

Here is the call graph for this function:

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

Definition at line 1417 of file lltexturecache.cpp.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Definition at line 1470 of file lltexturecache.cpp.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void LLTextureCache::prioritizeWrite ( handle_t  handle  ) 

Definition at line 1490 of file lltexturecache.cpp.

References mListMutex, and mPrioritizeWriteList.

Referenced by LLTextureFetchWorker::doWork().

Here is the caller graph for this function:

void LLTextureCache::removeFromCache ( const LLUUID id  ) 

Definition at line 1535 of file lltexturecache.cpp.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

LLTextureCacheWorker * LLTextureCache::getReader ( handle_t  handle  ) 

Definition at line 1289 of file lltexturecache.cpp.

References mReaders, and NULL.

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

Here is the caller graph for this function:

LLTextureCacheWorker * LLTextureCache::getWriter ( handle_t  handle  ) 

Definition at line 1300 of file lltexturecache.cpp.

References mWriters, and NULL.

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

Here is the caller graph for this function:

void LLTextureCache::lockWorkers (  )  [inline]

Definition at line 102 of file lltexturecache.h.

References LLMutex::lock(), and mWorkersMutex.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void LLTextureCache::unlockWorkers (  )  [inline]

Definition at line 103 of file lltexturecache.h.

References mWorkersMutex, and LLMutex::unlock().

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

Here is the call graph for this function:

Here is the caller graph for this function:

S32 LLTextureCache::getNumReads (  )  [inline]

Definition at line 106 of file lltexturecache.h.

References mReaders.

Referenced by LLGLTexMemBar::draw().

Here is the caller graph for this function:

S32 LLTextureCache::getNumWrites (  )  [inline]

Definition at line 107 of file lltexturecache.h.

References mWriters.

Referenced by LLGLTexMemBar::draw().

Here is the caller graph for this function:

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

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

Definition at line 944 of file lltexturecache.cpp.

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

Referenced by LLTextureCacheRemoteWorker::doWrite().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 928 of file lltexturecache.cpp.

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

Referenced by LLTextureCacheRemoteWorker::doRead().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 936 of file lltexturecache.cpp.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1498 of file lltexturecache.cpp.

References mCompletedList, and mListMutex.

Referenced by LLTextureCacheWorker::finishWork().

Here is the caller graph for this function:

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

Definition at line 990 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Definition at line 1126 of file lltexturecache.cpp.

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

Referenced by purgeCache(), and purgeTextures().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

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

Definition at line 1508 of file lltexturecache.cpp.

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

Referenced by removeFromCache().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 124 of file lltexturecache.h.

References LLMutex::lock(), and mHeaderMutex.

Here is the call graph for this function:

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

Definition at line 125 of file lltexturecache.h.

References mHeaderMutex, and LLMutex::unlock().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class LLTextureCacheWorker [friend]

Definition at line 46 of file lltexturecache.h.

friend class LLTextureCacheRemoteWorker [friend]

Definition at line 47 of file lltexturecache.h.

Referenced by readFromCache(), and writeToCache().

friend class LLTextureCacheLocalFileWorker [friend]

Definition at line 48 of file lltexturecache.h.

Referenced by readFromCache().


Member Data Documentation

Definition at line 129 of file lltexturecache.h.

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

Definition at line 131 of file lltexturecache.h.

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

Definition at line 132 of file lltexturecache.h.

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

Definition at line 135 of file lltexturecache.h.

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

Definition at line 136 of file lltexturecache.h.

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

Definition at line 139 of file lltexturecache.h.

Referenced by prioritizeWrite(), and update().

Definition at line 142 of file lltexturecache.h.

Referenced by addCompleted(), and update().

std::string LLTextureCache::mHeaderDataFileName [private]

Definition at line 164 of file lltexturecache.h.

Referenced by getHeaderCacheEntry(), and readHeaderCache().

Definition at line 166 of file lltexturecache.h.

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

Definition at line 168 of file lltexturecache.h.

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

std::string LLTextureCache::mTexturesDirName [private]

Definition at line 171 of file lltexturecache.h.

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

Definition at line 175 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), and purgeTextures().

Definition at line 176 of file lltexturecache.h.

Referenced by appendToTextureEntryList(), and writeToCache().

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

Definition at line 179 of file lltexturecache.h.

Referenced by readHeaderCache().

Definition at line 180 of file lltexturecache.h.

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

Definition at line 181 of file lltexturecache.h.

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


The documentation for this class was generated from the following files:

Generated on Fri May 16 09:14:19 2008 for SecondLife by  doxygen 1.5.5