summaryrefslogtreecommitdiff
path: root/indra/newview/lltexturefetch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltexturefetch.cpp')
-rwxr-xr-xindra/newview/lltexturefetch.cpp224
1 files changed, 121 insertions, 103 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 17b273f316..750140245b 100755
--- 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[] =
{
@@ -807,16 +820,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 +835,9 @@ public:
const LLUUID mSessionID;
const LLUUID mAgentID;
LLViewerAssetStats * mMainStats;
+
+private:
+ LLCore::HttpHandler::ptr_t mHandler;
};
/*
@@ -966,7 +976,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 +1339,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 +1568,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 +1580,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
mUrl,
options,
mFetcher->mHttpHeaders,
- this);
+ LLCore::HttpHandler::ptr_t(this, &NoOpDeletor));
}
else
{
@@ -1583,7 +1593,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 +2076,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 +2527,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),
@@ -2530,13 +2547,13 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
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;
@@ -2570,30 +2587,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;
@@ -3253,7 +3246,7 @@ void LLTextureFetch::sendRequestListToSimulators()
{
LLHost host = iter1->first;
// invalid host = use agent host
- if (host == LLHost::invalid)
+ if (host.isInvalid())
{
host = gAgent.getRegionHost();
}
@@ -3333,7 +3326,7 @@ void LLTextureFetch::sendRequestListToSimulators()
iter1 != mCancelQueue.end(); ++iter1)
{
LLHost host = iter1->first;
- if (host == LLHost::invalid)
+ if (host.isInvalid())
{
host = gAgent.getRegionHost();
}
@@ -3966,9 +3959,6 @@ public:
}
}; // end class AssetReportHandler
-AssetReportHandler stats_handler;
-
-
/**
* Implements the 'Set Region' command.
*
@@ -3982,6 +3972,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()
{
@@ -4000,7 +4002,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;
@@ -4048,9 +4049,9 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
report_priority,
mCapsURL,
sd,
- NULL,
+ LLCore::HttpOptions::ptr_t(),
fetcher->getMetricsHeaders(),
- handler);
+ mHandler);
LLTextureFetch::svMetricsDataBreak = false;
}
else
@@ -4167,7 +4168,7 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur
mFetcher(fetcher),
mTextureCache(cache),
mImageDecodeThread(imagedecodethread),
- mHttpHeaders(NULL),
+ mHttpHeaders(),
mHttpPolicyClass(fetcher->getPolicyClass()),
mNbCurlCompleted(0),
mTempIndex(0),
@@ -4181,11 +4182,6 @@ LLTextureFetchDebugger::~LLTextureFetchDebugger()
mFetchingHistory.clear();
mStopDebug = TRUE;
tryToStopDebug();
- if (mHttpHeaders)
- {
- mHttpHeaders->release();
- mHttpHeaders = NULL;
- }
}
void LLTextureFetchDebugger::init()
@@ -4230,7 +4226,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);
}
}
@@ -4326,26 +4322,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();
@@ -4445,7 +4448,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_DISCARD);
if(tex && mRefetchList[tex].begin() != mRefetchList[tex].end())
{
if(worker->mDecodedDiscard == mFetchingHistory[mRefetchList[tex][0]].mDecodedLevel)
@@ -4630,9 +4634,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;
@@ -4672,12 +4676,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);
+ }
+ }
}
}
@@ -4732,11 +4742,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();
+ }
+ }
}
}
@@ -4752,6 +4768,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);
}
}