diff options
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rw-r--r-- | indra/newview/lltexturefetch.cpp | 172 |
1 files changed, 50 insertions, 122 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 77c28bd3f4..69c40066b4 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); @@ -467,14 +467,6 @@ private: // Locks: Mw (ctor invokes without lock) void setDesiredDiscard(S32 discard, S32 size); - // Threads: T* - // Locks: Mw - bool insertPacket(S32 index, U8* data, S32 size); - - // Locks: Mw - void clearPackets(); - - // Locks: Mw void removeFromCache(); @@ -571,13 +563,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; @@ -592,21 +584,6 @@ private: // Work Data LLMutex mWorkMutex; - struct PacketData - { - PacketData(U8* data, S32 size) - : mData(data), mSize(size) - {} - ~PacketData() { clearData(); } - void clearData() { delete[] mData; mData = NULL; } - - U8* mData; - U32 mSize; - }; - std::vector<PacketData*> mPackets; - S32 mFirstPacket; - S32 mLastPacket; - U16 mTotalPackets; U8 mImageCodec; LLViewerAssetStats::duration_t mMetricsStartTime; @@ -909,22 +886,19 @@ 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), mWorkMutex(), - mFirstPacket(0), - mLastPacket(-1), - mTotalPackets(0), mImageCodec(IMG_CODEC_INVALID), mMetricsStartTime(0), mHttpHandle(LLCORE_HTTP_HANDLE_INVALID), @@ -980,7 +954,6 @@ LLTextureFetchWorker::~LLTextureFetchWorker() mFetcher->mTextureCache->writeComplete(mCacheWriteHandle, true); } mFormattedImage = NULL; - clearPackets(); if (mHttpBufferArray) { mHttpBufferArray->release(); @@ -992,16 +965,6 @@ LLTextureFetchWorker::~LLTextureFetchWorker() mFetcher->updateStateStats(mCacheReadCount, mCacheWriteCount, mResourceWaitCount); } -// Locks: Mw -void LLTextureFetchWorker::clearPackets() -{ - for_each(mPackets.begin(), mPackets.end(), DeletePointer()); - mPackets.clear(); - mTotalPackets = 0; - mLastPacket = -1; - mFirstPacket = 0; -} - // Locks: Mw (ctor invokes without lock) void LLTextureFetchWorker::setDesiredDiscard(S32 discard, S32 size) { @@ -1054,7 +1017,7 @@ void LLTextureFetchWorker::resetFormattedData() } mHttpReplySize = 0; mHttpReplyOffset = 0; - mHaveAllData = FALSE; + mHaveAllData = false; } F32 LLTextureFetchWorker::getImagePriority() const @@ -1152,10 +1115,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 +1126,11 @@ bool LLTextureFetchWorker::doWork(S32 param) } mHttpReplySize = 0; mHttpReplyOffset = 0; - mHaveAllData = FALSE; - clearPackets(); // TODO: Shouldn't be necessary + mHaveAllData = false; 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 +1152,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // return false; } mFileSize = 0; - mLoaded = FALSE; + mLoaded = false; add(LLTextureFetch::sCacheAttempt, 1.0); @@ -1264,7 +1226,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 +1438,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 +1555,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 { @@ -1655,7 +1617,7 @@ bool LLTextureFetchWorker::doWork(S32 param) return true; } - S32 append_size(mHttpBufferArray->size()); + S32 append_size(static_cast<S32>(mHttpBufferArray->size())); S32 total_size(cur_size + append_size); S32 src_offset(0); llassert_always(append_size == mRequestedSize); @@ -1664,7 +1626,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // In case of a partial response, our offset may // not be trivially contiguous with the data we have. // Get back into alignment. - if ( (mHttpReplyOffset > cur_size) || (cur_size > mHttpReplyOffset + append_size)) + if ( ((S32)mHttpReplyOffset > cur_size) || (cur_size > (S32)mHttpReplyOffset + append_size)) { LL_WARNS(LOG_TXT) << "Partial HTTP response produces break in image data for texture " << mID << ". Aborting load." << LL_ENDL; @@ -1700,6 +1662,8 @@ bool LLTextureFetchWorker::doWork(S32 param) } } + LLImageDataLock lock(mFormattedImage); + if (mHaveAllData) //the image file is fully loaded. { mFileSize = total_size; @@ -1796,7 +1760,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 +1835,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 +1851,7 @@ bool LLTextureFetchWorker::doWork(S32 param) } } llassert_always(datasize); - mWritten = FALSE; + mWritten = false; setState(WAIT_ON_WRITE); ++mCacheWriteCount; CacheWriteResponder* responder = new CacheWriteResponder(mFetcher, mID); @@ -2188,7 +2155,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response, { // get length of stream: LLCore::BufferArray * body(response->getBody()); - data_size = body ? body->size() : 0; + data_size = body ? static_cast<S32>(body->size()) : 0; LL_DEBUGS(LOG_TXT) << "HTTP RECEIVED: " << mID.asString() << " Bytes: " << data_size << LL_ENDL; if (data_size > 0) @@ -2234,19 +2201,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 +2222,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 +2238,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response, mRequestedSize = -1; // error } - mLoaded = TRUE; + mLoaded = true; return data_size ; } @@ -2280,7 +2247,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 +2265,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 +2280,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 +2325,7 @@ void LLTextureFetchWorker::callbackDecoded(bool success, const std::string &erro removeFromCache(); mDecodedDiscard = -1; // Redundant, here for clarity and paranoia } - mDecoded = TRUE; + mDecoded = true; // LL_INFOS(LOG_TXT) << mID << " : DECODE COMPLETE " << LL_ENDL; } // -Mw @@ -2435,9 +2402,7 @@ std::string LLTextureFetch::getStateString(S32 state) LLTextureFetch::LLTextureFetch(LLTextureCache* cache, bool threaded, bool qa_mode) : LLWorkerThread("TextureFetch", threaded, true), mDebugCount(0), - mDebugPause(FALSE), - mPacketCount(0), - mBadPacketCount(0), + mDebugPause(false), mQueueMutex(), mNetworkQueueMutex(), mTextureCache(cache), @@ -3061,43 +3026,6 @@ void LLTextureFetch::threadedUpdate() #endif } -////////////////////////////////////////////////////////////////////////////// - -// Threads: T* -// Locks: Mw -bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size) -{ - LL_PROFILE_ZONE_SCOPED; - mRequestedDeltaTimer.reset(); - if (index >= mTotalPackets) - { -// LL_WARNS(LOG_TXT) << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << LL_ENDL; - return false; - } - if (index > 0 && index < mTotalPackets-1 && size != MAX_IMG_PACKET_SIZE) - { -// LL_WARNS(LOG_TXT) << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << LL_ENDL; - return false; - } - - if (index >= (S32)mPackets.size()) - { - mPackets.resize(index+1, (PacketData*)NULL); // initializes v to NULL pointers - } - else if (mPackets[index] != NULL) - { -// LL_WARNS(LOG_TXT) << "Received duplicate packet: " << index << " for image: " << mID << LL_ENDL; - return false; - } - - mPackets[index] = new PacketData(data, size); - while (mLastPacket+1 < (S32)mPackets.size() && mPackets[mLastPacket+1] != NULL) - { - ++mLastPacket; - } - return true; -} - void LLTextureFetchWorker::setState(e_state new_state) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -3144,9 +3072,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) @@ -3205,7 +3133,7 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r { requested_priority = worker->mImagePriority; } - fetch_priority = worker->getImagePriority(); + fetch_priority = (U32)worker->getImagePriority(); can_use_http = worker->getCanUseHTTP() ; worker->unlockWorkMutex(); // -Mw } @@ -3400,7 +3328,7 @@ void LLTextureFetch::cancelHttpWaiters() int LLTextureFetch::getHttpWaitersCount() { mNetworkQueueMutex.lock(); // +Mfnq - int ret(mHttpWaitResource.size()); + int ret(static_cast<int>(mHttpWaitResource.size())); mNetworkQueueMutex.unlock(); // -Mfnq return ret; } |