aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltexturefetch.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltexturefetch.cpp84
1 files changed, 72 insertions, 12 deletions
diff --git a/linden/indra/newview/lltexturefetch.cpp b/linden/indra/newview/lltexturefetch.cpp
index 3201055..9399ed3 100644
--- a/linden/indra/newview/lltexturefetch.cpp
+++ b/linden/indra/newview/lltexturefetch.cpp
@@ -52,8 +52,8 @@
52//static 52//static
53class LLTextureFetchWorker : public LLWorkerClass 53class LLTextureFetchWorker : public LLWorkerClass
54{ 54{
55 friend class LLTextureFetch; 55friend class LLTextureFetch;
56 56
57private: 57private:
58#if 0 58#if 0
59 class URLResponder : public LLHTTPClient::Responder 59 class URLResponder : public LLHTTPClient::Responder
@@ -235,6 +235,7 @@ private:
235 /*virtual*/ void startWork(S32 param); // called from addWork() (MAIN THREAD) 235 /*virtual*/ void startWork(S32 param); // called from addWork() (MAIN THREAD)
236 /*virtual*/ void endWork(S32 param, bool aborted); // called from doWork() (MAIN THREAD) 236 /*virtual*/ void endWork(S32 param, bool aborted); // called from doWork() (MAIN THREAD)
237 237
238 virtual LLString getName() { return LLString::null; }
238 void resetFormattedData(); 239 void resetFormattedData();
239 240
240 void setImagePriority(F32 priority); 241 void setImagePriority(F32 priority);
@@ -339,6 +340,26 @@ private:
339 U8 mImageCodec; 340 U8 mImageCodec;
340}; 341};
341 342
343class LLTextureFetchLocalFileWorker : public LLTextureFetchWorker
344{
345friend class LLTextureFetch;
346
347protected:
348 LLTextureFetchLocalFileWorker(LLTextureFetch* fetcher, const LLString& filename, const LLUUID& id, const LLHost& host,
349 F32 priority, S32 discard, S32 size)
350 : LLTextureFetchWorker(fetcher, id, host, priority, discard, size),
351 mFileName(filename)
352 {}
353
354private:
355 /*virtual*/ LLString getName() { return mFileName; }
356
357
358private:
359 LLString mFileName;
360};
361
362
342//static 363//static
343const char* LLTextureFetchWorker::sStateDescs[] = { 364const char* LLTextureFetchWorker::sStateDescs[] = {
344 "INVALID", 365 "INVALID",
@@ -581,9 +602,19 @@ bool LLTextureFetchWorker::doWork(S32 param)
581 mFileSize = 0; 602 mFileSize = 0;
582 mLoaded = FALSE; 603 mLoaded = FALSE;
583 setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it 604 setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); // Set priority first since Responder may change it
605
584 CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage); 606 CacheReadResponder* responder = new CacheReadResponder(mFetcher, mID, mFormattedImage);
585 mCacheReadHandle = mFetcher->mTextureCache->readFromCache(mID, cache_priority, 607 if (getName().empty())
586 offset, size, responder); 608 {
609 mCacheReadHandle = mFetcher->mTextureCache->readFromCache(mID, cache_priority,
610 offset, size, responder);
611 }
612 else
613 {
614 // read file from local disk
615 mCacheReadHandle = mFetcher->mTextureCache->readFromCache(getName(), mID, cache_priority,
616 offset, size, responder);
617 }
587 } 618 }
588 619
589 if (mLoaded) 620 if (mLoaded)
@@ -608,6 +639,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
608 639
609 if (mState == CACHE_POST) 640 if (mState == CACHE_POST)
610 { 641 {
642 mDesiredSize = llmax(mDesiredSize, FIRST_PACKET_SIZE);
611 mCachedSize = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0; 643 mCachedSize = mFormattedImage.notNull() ? mFormattedImage->getDataSize() : 0;
612 // Successfully loaded 644 // Successfully loaded
613 if ((mCachedSize >= mDesiredSize) || mHaveAllData) 645 if ((mCachedSize >= mDesiredSize) || mHaveAllData)
@@ -619,6 +651,11 @@ bool LLTextureFetchWorker::doWork(S32 param)
619 } 651 }
620 else 652 else
621 { 653 {
654 if (!getName().empty())
655 {
656 // failed to load local file, we're done.
657 return true;
658 }
622 // need more data 659 // need more data
623 mState = LOAD_FROM_NETWORK; 660 mState = LOAD_FROM_NETWORK;
624 // fall through 661 // fall through
@@ -1274,7 +1311,13 @@ LLTextureFetch::~LLTextureFetch()
1274} 1311}
1275 1312
1276bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 priority, 1313bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 priority,
1277 S32 w, S32 h, S32 c, S32 discard, bool needs_aux) 1314 S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux)
1315{
1316 return createRequest(LLString::null, id, host, priority, w, h, c, desired_discard, needs_aux);
1317}
1318
1319bool LLTextureFetch::createRequest(const LLString& filename, const LLUUID& id, const LLHost& host, F32 priority,
1320 S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux)
1278{ 1321{
1279 if (mDebugPause) 1322 if (mDebugPause)
1280 { 1323 {
@@ -1298,7 +1341,7 @@ bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 pri
1298 } 1341 }
1299 1342
1300 S32 desired_size; 1343 S32 desired_size;
1301 if ((discard == 0) && worker && worker->mFileSize) 1344 if ((desired_discard == 0) && worker && worker->mFileSize)
1302 { 1345 {
1303 // if we want the entire image, and we know its size, then get it all 1346 // if we want the entire image, and we know its size, then get it all
1304 // (calcDataSizeJ2C() below makes assumptions about how the image 1347 // (calcDataSizeJ2C() below makes assumptions about how the image
@@ -1311,12 +1354,20 @@ bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 pri
1311 // If the requester knows the dimentions of the image, 1354 // If the requester knows the dimentions of the image,
1312 // this will calculate how much data we need without having to parse the header 1355 // this will calculate how much data we need without having to parse the header
1313 1356
1314 desired_size = LLImageJ2C::calcDataSizeJ2C(w, h, c, discard); 1357 desired_size = LLImageJ2C::calcDataSizeJ2C(w, h, c, desired_discard);
1315 } 1358 }
1316 else 1359 else
1317 { 1360 {
1318 desired_size = FIRST_PACKET_SIZE; 1361 if (desired_discard == 0)
1319 discard = MAX_DISCARD_LEVEL; 1362 {
1363 // If we want all of the image, request the maximum possible data
1364 desired_size = MAX_IMAGE_DATA_SIZE;
1365 }
1366 else
1367 {
1368 desired_size = FIRST_PACKET_SIZE;
1369 desired_discard = MAX_DISCARD_LEVEL;
1370 }
1320 } 1371 }
1321 if (worker) 1372 if (worker)
1322 { 1373 {
@@ -1326,7 +1377,7 @@ bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 pri
1326 } 1377 }
1327 worker->lockWorkData(); 1378 worker->lockWorkData();
1328 worker->setImagePriority(priority); 1379 worker->setImagePriority(priority);
1329 worker->setDesiredDiscard(discard, desired_size); 1380 worker->setDesiredDiscard(desired_discard, desired_size);
1330 worker->unlockWorkData(); 1381 worker->unlockWorkData();
1331 if (!worker->haveWork()) 1382 if (!worker->haveWork())
1332 { 1383 {
@@ -1336,12 +1387,21 @@ bool LLTextureFetch::createRequest(const LLUUID& id, const LLHost& host, F32 pri
1336 } 1387 }
1337 else 1388 else
1338 { 1389 {
1339 worker = new LLTextureFetchWorker(this, id, host, priority, discard, desired_size); 1390 if (filename.empty())
1391 {
1392 // do remote fetch
1393 worker = new LLTextureFetchWorker(this, id, host, priority, desired_discard, desired_size);
1394 }
1395 else
1396 {
1397 // do local file fetch
1398 worker = new LLTextureFetchLocalFileWorker(this, filename, id, host, priority, desired_discard, desired_size);
1399 }
1340 mRequestMap[id] = worker; 1400 mRequestMap[id] = worker;
1341 } 1401 }
1342 worker->mActiveCount++; 1402 worker->mActiveCount++;
1343 worker->mNeedsAux = needs_aux; 1403 worker->mNeedsAux = needs_aux;
1344// llinfos << "REQUESTED: " << id << " Discard: " << discard << llendl; 1404// llinfos << "REQUESTED: " << id << " Discard: " << desired_discard << llendl;
1345 return true; 1405 return true;
1346} 1406}
1347 1407