diff options
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rw-r--r--[-rwxr-xr-x] | indra/newview/lltexturefetch.cpp | 237 |
1 files changed, 130 insertions, 107 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index fab4203ec3..07b3dc1aa4 100755..100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -35,7 +35,6 @@ #include "lltexturefetch.h" #include "lldir.h" -#include "llhttpclient.h" #include "llhttpconstants.h" #include "llimage.h" #include "llimagej2c.h" @@ -255,6 +254,20 @@ static const S32 HTTP_NONPIPE_REQUESTS_LOW_WATER = 20; static const S32 HTTP_REQUESTS_RANGE_END_MAX = 20000000; ////////////////////////////////////////////////////////////////////////////// +namespace +{ + // The NoOpDeletor is used when passing certain objects (the LLTextureFetchWorker and + // the LLTextureFetchDebugger) in a smart pointer below for passage into + // the LLCore::Http libararies. When the smart pointer is destroyed, no + // action will be taken since we do not in these cases want the object to + // be destroyed at the end of the call. + // + // *NOTE$: Yes! It is "Deletor" + // http://english.stackexchange.com/questions/4733/what-s-the-rule-for-adding-er-vs-or-when-nouning-a-verb + // "delete" derives from Latin "deletus" + void NoOpDeletor(LLCore::HttpHandler *) + { /*NoOp*/ } +} static const char* e_state_name[] = { @@ -656,6 +669,7 @@ private: * is required to distribute data and perform global actions. * In pseudo-UML, it looks like: * + * @verbatim * Main Thread1 * . . * . . @@ -698,7 +712,6 @@ private: * . . * . . * - * * Key: * * SRE - Set Region Enqueued. Enqueue a 'Set Region' command in @@ -723,6 +736,7 @@ private: * global pointers used to find the 'current stats'. * RSC - Read Stats Collector. Extract collector data cloning it * (i.e. deep copy) when necessary. + * @endverbatim * */ class LLTextureFetch::TFRequest // : public LLQueuedThread::QueuedRequest @@ -807,16 +821,10 @@ public: * ownership of the copy and disposes of it * when done. */ - TFReqSendMetrics(const std::string & caps_url, - const LLUUID & session_id, - const LLUUID & agent_id, - LLViewerAssetStats * main_stats) - : LLTextureFetch::TFRequest(), - mCapsURL(caps_url), - mSessionID(session_id), - mAgentID(agent_id), - mMainStats(main_stats) - {} + TFReqSendMetrics(const std::string & caps_url, + const LLUUID & session_id, + const LLUUID & agent_id, + LLViewerAssetStats * main_stats); TFReqSendMetrics & operator=(const TFReqSendMetrics &); // Not defined virtual ~TFReqSendMetrics(); @@ -828,6 +836,9 @@ public: const LLUUID mSessionID; const LLUUID mAgentID; LLViewerAssetStats * mMainStats; + +private: + LLCore::HttpHandler::ptr_t mHandler; }; /* @@ -966,7 +977,7 @@ LLTextureFetchWorker::~LLTextureFetchWorker() if (mHttpActive) { // Issue a cancel on a live request... - mFetcher->getHttpRequest().requestCancel(mHttpHandle, NULL); + mFetcher->getHttpRequest().requestCancel(mHttpHandle, LLCore::HttpHandler::ptr_t()); } if (mCacheReadHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache) { @@ -1329,11 +1340,11 @@ bool LLTextureFetchWorker::doWork(S32 param) static LLCachedControl<bool> use_http(gSavedSettings, "ImagePipelineUseHTTP", true); -// if (mHost != LLHost::invalid) get_url = false; +// if (mHost.isInvalid()) get_url = false; if ( use_http && mCanUseHTTP && mUrl.empty())//get http url. { LLViewerRegion* region = NULL; - if (mHost == LLHost::invalid) + if (mHost.isInvalid()) region = gAgent.getRegion(); else region = LLWorld::getInstance()->getRegion(mHost); @@ -1558,7 +1569,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // Will call callbackHttpGet when curl request completes // Only server bake images use the returned headers currently, for getting retry-after field. - LLCore::HttpOptions *options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions; + LLCore::HttpOptions::ptr_t options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions; if (disable_range_req) { // 'Range:' requests may be disabled in which case all HTTP @@ -1570,7 +1581,7 @@ bool LLTextureFetchWorker::doWork(S32 param) mUrl, options, mFetcher->mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); } else { @@ -1583,7 +1594,7 @@ bool LLTextureFetchWorker::doWork(S32 param) : mRequestedSize, options, mFetcher->mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); } if (LLCORE_HTTP_HANDLE_INVALID == mHttpHandle) { @@ -2066,11 +2077,18 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe if (log_texture_traffic && data_size > 0) { - LLViewerTexture* tex = LLViewerTextureManager::findTexture(mID); - if (tex) - { - gTotalTextureBytesPerBoostLevel[tex->getBoostLevel()] += data_size ; - } + // one worker per multiple textures + std::vector<LLViewerTexture*> textures; + LLViewerTextureManager::findTextures(mID, textures); + std::vector<LLViewerTexture*>::iterator iter = textures.begin(); + while (iter != textures.end()) + { + LLViewerTexture* tex = *iter++; + if (tex) + { + gTotalTextureBytesPerBoostLevel[tex->getBoostLevel()] += data_size; + } + } } mFetcher->removeFromHTTPQueue(mID, data_size); @@ -2510,11 +2528,11 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mTotalHTTPRequests(0), mQAMode(qa_mode), mHttpRequest(NULL), - mHttpOptions(NULL), - mHttpOptionsWithHeaders(NULL), - mHttpHeaders(NULL), + mHttpOptions(), + mHttpOptionsWithHeaders(), + mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpMetricsHeaders(NULL), + mHttpMetricsHeaders(), mHttpMetricsPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mTotalCacheReadCount(0U), mTotalCacheWriteCount(0U), @@ -2522,20 +2540,21 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mFetchDebugger(NULL), mFetchSource(LLTextureFetch::FROM_ALL), mOriginFetchSource(LLTextureFetch::FROM_ALL), - mFetcherLocked(FALSE) + mFetcherLocked(FALSE), + mTextureInfoMainThread(false) { mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS"); mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), U32Bytes(gSavedSettings.getU32("TextureLoggingThreshold"))); LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); mHttpRequest = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; - mHttpOptionsWithHeaders = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + mHttpOptionsWithHeaders = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptionsWithHeaders->setWantHeaders(true); - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_TEXTURE); - mHttpMetricsHeaders = new LLCore::HttpHeaders; + mHttpMetricsHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpMetricsHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpMetricsPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_REPORTING); mHttpHighWater = HTTP_NONPIPE_REQUESTS_HIGH_WATER; @@ -2569,30 +2588,6 @@ LLTextureFetch::~LLTextureFetch() delete req; } - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } - - if (mHttpOptionsWithHeaders) - { - mHttpOptionsWithHeaders->release(); - mHttpOptionsWithHeaders = NULL; - } - - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } - - if (mHttpMetricsHeaders) - { - mHttpMetricsHeaders->release(); - mHttpMetricsHeaders = NULL; - } - mHttpWaitResource.clear(); delete mHttpRequest; @@ -3128,6 +3123,7 @@ void LLTextureFetch::shutDownImageDecodeThread() // Threads: Ttf void LLTextureFetch::startThread() { + mTextureInfo.startRecording(); } // Threads: Ttf @@ -3138,6 +3134,8 @@ void LLTextureFetch::endThread() << ", ResWaits: " << mTotalResourceWaitCount << ", TotalHTTPReq: " << getTotalNumHTTPRequests() << LL_ENDL; + + mTextureInfo.stopRecording(); } // Threads: Ttf @@ -3249,7 +3247,7 @@ void LLTextureFetch::sendRequestListToSimulators() { LLHost host = iter1->first; // invalid host = use agent host - if (host == LLHost::invalid) + if (host.isInvalid()) { host = gAgent.getRegionHost(); } @@ -3329,7 +3327,7 @@ void LLTextureFetch::sendRequestListToSimulators() iter1 != mCancelQueue.end(); ++iter1) { LLHost host = iter1->first; - if (host == LLHost::invalid) + if (host.isInvalid()) { host = gAgent.getRegionHost(); } @@ -3541,8 +3539,8 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1 if (log_to_viewer_log || log_to_sim) { U64Microseconds timeNow = LLTimer::getTotalTime(); - mTextureInfo.setRequestSize(id, worker->mFileSize); - mTextureInfo.setRequestCompleteTimeAndLog(id, timeNow); + mTextureInfoMainThread.setRequestSize(id, worker->mFileSize); + mTextureInfoMainThread.setRequestCompleteTimeAndLog(id, timeNow); } } worker->unlockWorkMutex(); // -Mw @@ -3962,9 +3960,6 @@ public: } }; // end class AssetReportHandler -AssetReportHandler stats_handler; - - /** * Implements the 'Set Region' command. * @@ -3978,6 +3973,18 @@ TFReqSetRegion::doWork(LLTextureFetch *) return true; } +TFReqSendMetrics::TFReqSendMetrics(const std::string & caps_url, + const LLUUID & session_id, + const LLUUID & agent_id, + LLViewerAssetStats * main_stats): + LLTextureFetch::TFRequest(), + mCapsURL(caps_url), + mSessionID(session_id), + mAgentID(agent_id), + mMainStats(main_stats), + mHandler(new AssetReportHandler) +{} + TFReqSendMetrics::~TFReqSendMetrics() { @@ -3996,7 +4003,6 @@ bool TFReqSendMetrics::doWork(LLTextureFetch * fetcher) { static const U32 report_priority(1); - static LLCore::HttpHandler * const handler(fetcher->isQAMode() || true ? &stats_handler : NULL); //if (! gViewerAssetStatsThread1) // return true; @@ -4044,9 +4050,9 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) report_priority, mCapsURL, sd, - NULL, + LLCore::HttpOptions::ptr_t(), fetcher->getMetricsHeaders(), - handler); + mHandler); LLTextureFetch::svMetricsDataBreak = false; } else @@ -4163,7 +4169,7 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur mFetcher(fetcher), mTextureCache(cache), mImageDecodeThread(imagedecodethread), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(fetcher->getPolicyClass()), mNbCurlCompleted(0), mTempIndex(0), @@ -4177,11 +4183,6 @@ LLTextureFetchDebugger::~LLTextureFetchDebugger() mFetchingHistory.clear(); mStopDebug = TRUE; tryToStopDebug(); - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } } void LLTextureFetchDebugger::init() @@ -4226,7 +4227,7 @@ void LLTextureFetchDebugger::init() if (! mHttpHeaders) { - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); } } @@ -4322,26 +4323,33 @@ bool LLTextureFetchDebugger::processStartDebug(F32 max_time) fetched_textures.insert(mFetchingHistory[i].mID); in_list = false; } - - LLViewerFetchedTexture* tex = LLViewerTextureManager::findFetchedTexture(mFetchingHistory[i].mID); - if(tex && tex->isJustBound()) //visible - { - if(!in_list) - { - mNumVisibleFetchedTextures++; - } - mNumVisibleFetchingRequests++; - - mVisibleFetchedData += mFetchingHistory[i].mFetchedSize; - mVisibleDecodedData += mFetchingHistory[i].mDecodedSize; - - if(tex->getDiscardLevel() >= mFetchingHistory[i].mDecodedLevel) - { - mRenderedData += mFetchingHistory[i].mFetchedSize; - mRenderedDecodedData += mFetchingHistory[i].mDecodedSize; - mRenderedPixels += tex->getWidth() * tex->getHeight(); - } - } + + std::vector<LLViewerFetchedTexture*> textures; + LLViewerTextureManager::findFetchedTextures(mFetchingHistory[i].mID, textures); + std::vector<LLViewerFetchedTexture*>::iterator iter = textures.begin(); + while (iter != textures.end()) + { + LLViewerFetchedTexture* tex = *iter++; + // fetched data will be counted for both ui and regular elements + if (tex && tex->isJustBound()) //visible + { + if (!in_list) + { + mNumVisibleFetchedTextures++; + } + mNumVisibleFetchingRequests++; + + mVisibleFetchedData += mFetchingHistory[i].mFetchedSize; + mVisibleDecodedData += mFetchingHistory[i].mDecodedSize; + + if (tex->getDiscardLevel() >= mFetchingHistory[i].mDecodedLevel) + { + mRenderedData += mFetchingHistory[i].mFetchedSize; + mRenderedDecodedData += mFetchingHistory[i].mDecodedSize; + mRenderedPixels += tex->getWidth() * tex->getHeight(); + } + } + } } mNumFetchedTextures = fetched_textures.size(); @@ -4441,7 +4449,8 @@ void LLTextureFetchDebugger::addHistoryEntry(LLTextureFetchWorker* worker) mRefetchedAllPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight(); mRefetchedAllData += worker->mFormattedImage->getDataSize(); - LLViewerFetchedTexture* tex = LLViewerTextureManager::findFetchedTexture(worker->mID); + // refetch list only requests/creates normal images, so requesting ui='false' + LLViewerFetchedTexture* tex = LLViewerTextureManager::findFetchedTexture(worker->mID, TEX_LIST_STANDARD); if(tex && mRefetchList[tex].begin() != mRefetchList[tex].end()) { if(worker->mDecodedDiscard == mFetchingHistory[mRefetchList[tex][0]].mDecodedLevel) @@ -4626,9 +4635,9 @@ S32 LLTextureFetchDebugger::fillCurlQueue() texture_url, 0, requestedSize, - NULL, + LLCore::HttpOptions::ptr_t(), mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); if (LLCORE_HTTP_HANDLE_INVALID != handle) { mHandleToFetchIndex[handle] = i; @@ -4668,12 +4677,18 @@ void LLTextureFetchDebugger::debugGLTextureCreation() { if(mFetchingHistory[i].mRawImage.notNull()) { - LLViewerFetchedTexture* tex = gTextureList.findImage(mFetchingHistory[i].mID) ; - if(tex && !tex->isForSculptOnly()) - { - tex->destroyGLTexture() ; - mTempTexList.push_back(tex); - } + std::vector<LLViewerFetchedTexture*> textures; + gTextureList.findTexturesByID(mFetchingHistory[i].mID, textures); + std::vector<LLViewerFetchedTexture*>::iterator iter = textures.begin(); + while (iter != textures.end()) + { + LLViewerFetchedTexture* tex = *iter++; + if (tex && !tex->isForSculptOnly()) + { + tex->destroyGLTexture(); + mTempTexList.push_back(tex); + } + } } } @@ -4728,11 +4743,17 @@ void LLTextureFetchDebugger::clearTextures() S32 size = mFetchingHistory.size(); for(S32 i = 0 ; i < size ; i++) { - LLViewerFetchedTexture* tex = gTextureList.findImage(mFetchingHistory[i].mID) ; - if(tex) - { - tex->clearFetchedResults() ; - } + std::vector<LLViewerFetchedTexture*> textures; + gTextureList.findTexturesByID(mFetchingHistory[i].mID, textures); + std::vector<LLViewerFetchedTexture*>::iterator iter = textures.begin(); + while (iter != textures.end()) + { + LLViewerFetchedTexture* tex = *iter++; + if (tex) + { + tex->clearFetchedResults(); + } + } } } @@ -4748,6 +4769,8 @@ void LLTextureFetchDebugger::makeRefetchList() continue; //the texture fetch pipeline will take care of visible textures. } + // todo: Will attempt to refetch icons and ui elements as normal images (boost_none) + // thus will create unnecessary LLViewerFetchedTexture, consider supporting separate UI textures mRefetchList[tex].push_back(i); } } |