summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturefetch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rw-r--r--indra/newview/lltexturefetch.cpp87
1 files changed, 46 insertions, 41 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 40bbe2b934..5fd3fb6e29 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -392,7 +392,7 @@ public:
// Threads: Ttc
void callbackCacheRead(bool success, LLImageFormatted* image,
- S32 imagesize, BOOL islocal);
+ S32 imagesize, bool islocal);
// Threads: Ttc
void callbackCacheWrite(bool success);
@@ -571,13 +571,13 @@ private:
mCachedSize;
e_request_state mSentRequest;
handle_t mDecodeHandle;
- BOOL mLoaded;
- BOOL mDecoded;
- BOOL mWritten;
- BOOL mNeedsAux;
- BOOL mHaveAllData;
- BOOL mInLocalCache;
- BOOL mInCache;
+ bool mLoaded;
+ bool mDecoded;
+ bool mWritten;
+ bool mNeedsAux;
+ bool mHaveAllData;
+ bool mInLocalCache;
+ bool mInCache;
bool mCanUseHTTP;
S32 mRetryAttempt;
S32 mActiveCount;
@@ -909,15 +909,15 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
mFileSize(0),
mSkippedStatesTime(0),
mCachedSize(0),
- mLoaded(FALSE),
+ mLoaded(false),
mSentRequest(UNSENT),
mDecodeHandle(0),
- mDecoded(FALSE),
- mWritten(FALSE),
- mNeedsAux(FALSE),
- mHaveAllData(FALSE),
- mInLocalCache(FALSE),
- mInCache(FALSE),
+ mDecoded(false),
+ mWritten(false),
+ mNeedsAux(false),
+ mHaveAllData(false),
+ mInLocalCache(false),
+ mInCache(false),
mCanUseHTTP(true),
mRetryAttempt(0),
mActiveCount(0),
@@ -1054,7 +1054,7 @@ void LLTextureFetchWorker::resetFormattedData()
}
mHttpReplySize = 0;
mHttpReplyOffset = 0;
- mHaveAllData = FALSE;
+ mHaveAllData = false;
}
F32 LLTextureFetchWorker::getImagePriority() const
@@ -1152,10 +1152,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
mRequestedOffset = 0;
mFileSize = 0;
mCachedSize = 0;
- mLoaded = FALSE;
+ mLoaded = false;
mSentRequest = UNSENT;
- mDecoded = FALSE;
- mWritten = FALSE;
+ mDecoded = false;
+ mWritten = false;
if (mHttpBufferArray)
{
mHttpBufferArray->release();
@@ -1163,12 +1163,12 @@ bool LLTextureFetchWorker::doWork(S32 param)
}
mHttpReplySize = 0;
mHttpReplyOffset = 0;
- mHaveAllData = FALSE;
+ mHaveAllData = false;
clearPackets(); // TODO: Shouldn't be necessary
mCacheReadHandle = LLTextureCache::nullHandle();
mCacheWriteHandle = LLTextureCache::nullHandle();
setState(LOAD_FROM_TEXTURE_CACHE);
- mInCache = FALSE;
+ mInCache = false;
mDesiredSize = llmax(mDesiredSize, TEXTURE_CACHE_ENTRY_SIZE); // min desired size is TEXTURE_CACHE_ENTRY_SIZE
LL_DEBUGS(LOG_TXT) << mID << ": Priority: " << llformat("%8.0f",mImagePriority)
<< " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
@@ -1190,7 +1190,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
// return false;
}
mFileSize = 0;
- mLoaded = FALSE;
+ mLoaded = false;
add(LLTextureFetch::sCacheAttempt, 1.0);
@@ -1264,7 +1264,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
<< ", should be >=0" << LL_ENDL;
}
setState(DECODE_IMAGE);
- mInCache = TRUE;
+ mInCache = true;
mWriteToCacheState = NOT_WRITE ;
LL_DEBUGS(LOG_TXT) << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize()
<< " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight())
@@ -1476,7 +1476,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
}
mRequestedDeltaTimer.reset();
- mLoaded = FALSE;
+ mLoaded = false;
mGetStatus = LLCore::HttpStatus();
mGetReason.clear();
LL_DEBUGS(LOG_TXT) << "HTTP GET: " << mID << " Offset: " << mRequestedOffset
@@ -1593,7 +1593,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
else if (http_not_sat == mGetStatus)
{
// Allowed, we'll accept whatever data we have as complete.
- mHaveAllData = TRUE;
+ mHaveAllData = true;
}
else
{
@@ -1699,7 +1699,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
mFormattedImage = new LLImageJ2C; // default
}
}
-
+
+ LLImageDataLock lock(mFormattedImage);
+
if (mHaveAllData) //the image file is fully loaded.
{
mFileSize = total_size;
@@ -1796,7 +1798,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
mAuxImage = NULL;
llassert_always(mFormattedImage.notNull());
S32 discard = mHaveAllData ? 0 : mLoadedDiscard;
- mDecoded = FALSE;
+ mDecoded = false;
setState(DECODE_IMAGE_UPDATE);
LL_DEBUGS(LOG_TXT) << mID << ": Decoding. Bytes: " << mFormattedImage->getDataSize() << " Discard: " << discard
<< " All Data: " << mHaveAllData << LL_ENDL;
@@ -1871,6 +1873,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
//return false;
return doWork(param);
}
+
+ LLImageDataSharedLock lock(mFormattedImage);
+
S32 datasize = mFormattedImage->getDataSize();
if(mFileSize < datasize)//This could happen when http fetching and sim fetching mixed.
{
@@ -1884,7 +1889,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
}
}
llassert_always(datasize);
- mWritten = FALSE;
+ mWritten = false;
setState(WAIT_ON_WRITE);
++mCacheWriteCount;
CacheWriteResponder* responder = new CacheWriteResponder(mFetcher, mID);
@@ -2234,19 +2239,19 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
<< mFileSize << " datasize: " << mFormattedImage->getDataSize()
<< LL_ENDL;
}
- mHaveAllData = TRUE;
+ mHaveAllData = true;
llassert_always(mDecodeHandle == 0);
mFormattedImage = NULL; // discard any previous data we had
}
else if (data_size < mRequestedSize)
{
- mHaveAllData = TRUE;
+ mHaveAllData = true;
}
else if (data_size > mRequestedSize)
{
// *TODO: This shouldn't be happening any more (REALLY don't expect this anymore)
LL_WARNS(LOG_TXT) << "data_size = " << data_size << " > requested: " << mRequestedSize << LL_ENDL;
- mHaveAllData = TRUE;
+ mHaveAllData = true;
llassert_always(mDecodeHandle == 0);
mFormattedImage = NULL; // discard any previous data we had
}
@@ -2255,7 +2260,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
{
// We requested data but received none (and no error),
// so presumably we have all of it
- mHaveAllData = TRUE;
+ mHaveAllData = true;
}
mRequestedSize = data_size;
@@ -2271,7 +2276,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
mRequestedSize = -1; // error
}
- mLoaded = TRUE;
+ mLoaded = true;
return data_size ;
}
@@ -2280,7 +2285,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
// Threads: Ttc
void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* image,
- S32 imagesize, BOOL islocal)
+ S32 imagesize, bool islocal)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
LLMutexLock lock(&mWorkMutex); // +Mw
@@ -2298,10 +2303,10 @@ void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* ima
mInLocalCache = islocal;
if (mFileSize != 0 && mFormattedImage->getDataSize() >= mFileSize)
{
- mHaveAllData = TRUE;
+ mHaveAllData = true;
}
}
- mLoaded = TRUE;
+ mLoaded = true;
} // -Mw
// Threads: Ttc
@@ -2313,7 +2318,7 @@ void LLTextureFetchWorker::callbackCacheWrite(bool success)
// LL_WARNS(LOG_TXT) << "Write callback for " << mID << " with state = " << mState << LL_ENDL;
return;
}
- mWritten = TRUE;
+ mWritten = true;
} // -Mw
//////////////////////////////////////////////////////////////////////////////
@@ -2358,7 +2363,7 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag
removeFromCache();
mDecodedDiscard = -1; // Redundant, here for clarity and paranoia
}
- mDecoded = TRUE;
+ mDecoded = true;
// LL_INFOS(LOG_TXT) << mID << " : DECODE COMPLETE " << LL_ENDL;
} // -Mw
@@ -2435,7 +2440,7 @@ std::string LLTextureFetch::getStateString(S32 state)
LLTextureFetch::LLTextureFetch(LLTextureCache* cache, bool threaded, bool qa_mode)
: LLWorkerThread("TextureFetch", threaded, true),
mDebugCount(0),
- mDebugPause(FALSE),
+ mDebugPause(false),
mPacketCount(0),
mBadPacketCount(0),
mQueueMutex(),
@@ -3144,9 +3149,9 @@ LLViewerRegion* LLTextureFetchWorker::getRegion()
//////////////////////////////////////////////////////////////////////////////
// Threads: T*
-BOOL LLTextureFetch::isFromLocalCache(const LLUUID& id)
+bool LLTextureFetch::isFromLocalCache(const LLUUID& id)
{
- BOOL from_cache = FALSE ;
+ bool from_cache = false ;
LLTextureFetchWorker* worker = getWorker(id);
if (worker)