diff options
author | Brad Linden <46733234+brad-linden@users.noreply.github.com> | 2024-06-12 17:04:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-12 17:04:34 -0700 |
commit | 100ebbab2437de7f5d124a0d7b8279a7a7b57656 (patch) | |
tree | e8b4200dae16e89698c2f3eadae05634041681a1 /indra/newview/lltexturecache.cpp | |
parent | f5e2708a0fc4e08d3d0a5dc393bbd4bac09e1c55 (diff) | |
parent | ae74ca80692c8bcf157e903033fcfa1778706d64 (diff) |
Merge pull request #1745 from secondlife/project/gltf_development
move project/gltf development to develop
Diffstat (limited to 'indra/newview/lltexturecache.cpp')
-rw-r--r-- | indra/newview/lltexturecache.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 56f26c953b..843da97089 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -96,7 +96,7 @@ private: public: LLTextureCacheWorker(LLTextureCache* cache, const LLUUID& id, - U8* data, S32 datasize, S32 offset, + const U8* data, S32 datasize, S32 offset, S32 imagesize, // for writes LLTextureCache::Responder* responder) : LLWorkerClass(cache, "LLTextureCacheWorker"), @@ -108,7 +108,7 @@ public: mOffset(offset), mImageSize(imagesize), mImageFormat(IMG_CODEC_J2C), - mImageLocal(FALSE), + mImageLocal(false), mResponder(responder), mFileHandle(LLLFSThread::nullHandle()), mBytesToRead(0), @@ -145,12 +145,12 @@ protected: LLUUID mID; U8* mReadData; - U8* mWriteData; + const U8* mWriteData; S32 mDataSize; S32 mOffset; S32 mImageSize; EImageCodec mImageFormat; - BOOL mImageLocal; + bool mImageLocal; LLPointer<LLTextureCache::Responder> mResponder; LLLFSThread::handle_t mFileHandle; S32 mBytesToRead; @@ -224,7 +224,7 @@ bool LLTextureCacheLocalFileWorker::doRead() else { mImageSize = local_size; - mImageLocal = TRUE; + mImageLocal = true; } return true; } @@ -239,7 +239,7 @@ class LLTextureCacheRemoteWorker : public LLTextureCacheWorker { public: LLTextureCacheRemoteWorker(LLTextureCache* cache, const LLUUID& id, - U8* data, S32 datasize, S32 offset, + const U8* data, S32 datasize, S32 offset, S32 imagesize, // for writes LLPointer<LLImageRaw> raw, S32 discardlevel, LLTextureCache::Responder* responder) @@ -364,7 +364,7 @@ bool LLTextureCacheRemoteWorker::doRead() else { mImageSize = local_size; - mImageLocal = TRUE; + mImageLocal = true; } } else @@ -796,9 +796,9 @@ LLTextureCache::LLTextureCache(bool threaded) mListMutex(), mFastCacheMutex(), mHeaderAPRFile(NULL), - mReadOnly(TRUE), //do not allow to change the texture cache until setReadOnly() is called. + mReadOnly(true), //do not allow to change the texture cache until setReadOnly() is called. mTexturesSizeTotal(0), - mDoPurge(FALSE), + mDoPurge(false), mFastCachep(NULL), mFastCachePoolp(NULL), mFastCachePadBuffer(NULL) @@ -873,7 +873,7 @@ std::string LLTextureCache::getTextureFileName(const LLUUID& id) } //debug -BOOL LLTextureCache::isInCache(const LLUUID& id) +bool LLTextureCache::isInCache(const LLUUID& id) { LLMutexLock lock(&mHeaderMutex); id_map_t::const_iterator iter = mHeaderIDMap.find(id); @@ -882,7 +882,7 @@ BOOL LLTextureCache::isInCache(const LLUUID& id) } //debug -BOOL LLTextureCache::isInLocal(const LLUUID& id) +bool LLTextureCache::isInLocal(const LLUUID& id) { S32 local_size = 0; std::string local_filename; @@ -894,7 +894,7 @@ BOOL LLTextureCache::isInLocal(const LLUUID& id) local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool()); if (local_size > 0) { - return TRUE ; + return true ; } } @@ -904,7 +904,7 @@ BOOL LLTextureCache::isInLocal(const LLUUID& id) local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool()); if (local_size > 0) { - return TRUE ; + return true ; } } @@ -914,11 +914,11 @@ BOOL LLTextureCache::isInLocal(const LLUUID& id) local_size = LLAPRFile::size(local_filename, getLocalAPRFilePool()); if (local_size > 0) { - return TRUE ; + return true ; } } - return FALSE ; + return false ; } ////////////////////////////////////////////////////////////////////////////// @@ -982,14 +982,14 @@ void LLTextureCache::purgeCache(ELLPath location, bool remove_dir) } //is called in the main thread before initCache(...) is called. -void LLTextureCache::setReadOnly(BOOL read_only) +void LLTextureCache::setReadOnly(bool read_only) { mReadOnly = read_only ; } // Called in the main thread. // Returns the unused amount of max_size if any -S64 LLTextureCache::initCache(ELLPath location, S64 max_size, BOOL texture_cache_mismatch) +S64 LLTextureCache::initCache(ELLPath location, S64 max_size, bool texture_cache_mismatch) { llassert_always(getPending() == 0) ; //should not start accessing the texture cache before initialized. @@ -1314,7 +1314,7 @@ bool LLTextureCache::updateEntry(S32& idx, Entry& entry, S32 new_image_size, S32 if (purge) { - mDoPurge = TRUE; + mDoPurge = true; } } @@ -1375,13 +1375,13 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries) void LLTextureCache::writeEntriesAndClose(const std::vector<Entry>& entries) { - S32 num_entries = entries.size(); + auto num_entries = entries.size(); llassert_always(num_entries == mHeaderEntriesInfo.mEntries); if (!mReadOnly) { LLAPRFile* aprfile = openHeaderEntriesFile(false, (S32)sizeof(EntriesInfo)); - for (S32 idx=0; idx<num_entries; idx++) + for (size_t idx=0; idx<num_entries; idx++) { S32 bytes_written = aprfile->write((void*)(&entries[idx]), (S32)sizeof(Entry)); if(bytes_written != sizeof(Entry)) @@ -1961,7 +1961,7 @@ bool LLTextureCache::readComplete(handle_t handle, bool abort) } LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id, - U8* data, S32 datasize, S32 imagesize, + const U8* data, S32 datasize, S32 imagesize, LLPointer<LLImageRaw> rawimage, S32 discardlevel, WriteResponder* responder) { @@ -2047,6 +2047,9 @@ LLPointer<LLImageRaw> LLTextureCache::readFromFastCache(const LLUUID& id, S32& d bool LLTextureCache::writeToFastCache(LLUUID image_id, S32 id, LLPointer<LLImageRaw> raw, S32 discardlevel) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + + LLImageDataSharedLock lock(raw); + //rescale image if needed if (raw.isNull() || raw->isBufferInvalid() || !raw->getData()) { @@ -2282,11 +2285,11 @@ bool LLTextureCache::removeFromCache(const LLUUID& id) LLTextureCache::ReadResponder::ReadResponder() : mImageSize(0), - mImageLocal(FALSE) + mImageLocal(false) { } -void LLTextureCache::ReadResponder::setData(U8* data, S32 datasize, S32 imagesize, S32 imageformat, BOOL imagelocal) +void LLTextureCache::ReadResponder::setData(U8* data, S32 datasize, S32 imagesize, S32 imageformat, bool imagelocal) { if (mFormattedImage.notNull()) { |