aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerimage.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/llviewerimage.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/newview/llviewerimage.cpp')
-rw-r--r--linden/indra/newview/llviewerimage.cpp72
1 files changed, 42 insertions, 30 deletions
diff --git a/linden/indra/newview/llviewerimage.cpp b/linden/indra/newview/llviewerimage.cpp
index d436cd0..0b70f51 100644
--- a/linden/indra/newview/llviewerimage.cpp
+++ b/linden/indra/newview/llviewerimage.cpp
@@ -68,6 +68,8 @@ LLPointer<LLViewerImage> LLViewerImage::sSmokeImagep = NULL;
68LLPointer<LLImageGL> LLViewerImage::sNullImagep = NULL; 68LLPointer<LLImageGL> LLViewerImage::sNullImagep = NULL;
69 69
70S32 LLViewerImage::sImageCount = 0; 70S32 LLViewerImage::sImageCount = 0;
71S32 LLViewerImage::sRawCount = 0;
72S32 LLViewerImage::sAuxCount = 0;
71LLTimer LLViewerImage::sEvaluationTimer; 73LLTimer LLViewerImage::sEvaluationTimer;
72F32 LLViewerImage::sDesiredDiscardBias = 0.f; 74F32 LLViewerImage::sDesiredDiscardBias = 0.f;
73static F32 sDesiredDiscardBiasMin = -2.0f; // -max number of levels to improve image quality by 75static F32 sDesiredDiscardBiasMin = -2.0f; // -max number of levels to improve image quality by
@@ -206,7 +208,7 @@ LLViewerImage::LLViewerImage(const LLUUID& id, BOOL usemipmaps)
206 sImageCount++; 208 sImageCount++;
207} 209}
208 210
209LLViewerImage::LLViewerImage(const LLString& filename, const LLUUID& id, BOOL usemipmaps) 211LLViewerImage::LLViewerImage(const std::string& filename, const LLUUID& id, BOOL usemipmaps)
210 : LLImageGL(usemipmaps), 212 : LLImageGL(usemipmaps),
211 mID(id), 213 mID(id),
212 mLocalFileName(filename) 214 mLocalFileName(filename)
@@ -220,7 +222,6 @@ LLViewerImage::LLViewerImage(const U32 width, const U32 height, const U8 compone
220 : LLImageGL(width, height, components, usemipmaps) 222 : LLImageGL(width, height, components, usemipmaps)
221{ 223{
222 init(true); 224 init(true);
223 mNeedsAux = FALSE;
224 // Create an empty image of the specified size and width 225 // Create an empty image of the specified size and width
225 mID.generate(); 226 mID.generate();
226 mFullyLoaded = TRUE; 227 mFullyLoaded = TRUE;
@@ -231,7 +232,6 @@ LLViewerImage::LLViewerImage(const LLImageRaw* raw, BOOL usemipmaps)
231 : LLImageGL(raw, usemipmaps) 232 : LLImageGL(raw, usemipmaps)
232{ 233{
233 init(true); 234 init(true);
234 mNeedsAux = FALSE;
235 // Create an empty image of the specified size and width 235 // Create an empty image of the specified size and width
236 mID.generate(); 236 mID.generate();
237 mFullyLoaded = TRUE; 237 mFullyLoaded = TRUE;
@@ -335,7 +335,8 @@ void LLViewerImage::cleanup()
335 delete entryp; 335 delete entryp;
336 } 336 }
337 mLoadedCallbackList.clear(); 337 mLoadedCallbackList.clear();
338 338 mNeedsAux = FALSE;
339
339 // Clean up image data 340 // Clean up image data
340 destroyRawImage(); 341 destroyRawImage();
341 342
@@ -423,6 +424,7 @@ BOOL LLViewerImage::createTexture(S32 usename/*= 0*/)
423 424
424 if (!imageraw_callbacks) 425 if (!imageraw_callbacks)
425 { 426 {
427 mNeedsAux = FALSE;
426 destroyRawImage(); 428 destroyRawImage();
427 } 429 }
428 return res; 430 return res;
@@ -605,6 +607,7 @@ F32 LLViewerImage::calcDecodePriority()
605 607
606 F32 priority; 608 F32 priority;
607 S32 cur_discard = getDiscardLevel(); 609 S32 cur_discard = getDiscardLevel();
610 bool have_all_data = (cur_discard >= 0 && (cur_discard <= mDesiredDiscardLevel));
608 F32 pixel_priority = fsqrtf(mMaxVirtualSize) * (1.f + mMaxCosAngle); 611 F32 pixel_priority = fsqrtf(mMaxVirtualSize) * (1.f + mMaxCosAngle);
609 const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame 612 const S32 MIN_NOT_VISIBLE_FRAMES = 30; // NOTE: this function is not called every frame
610 mDecodeFrame++; 613 mDecodeFrame++;
@@ -622,11 +625,11 @@ F32 LLViewerImage::calcDecodePriority()
622 // Don't decode anything we don't need 625 // Don't decode anything we don't need
623 priority = -1.0f; 626 priority = -1.0f;
624 } 627 }
625 else if (mBoostLevel == LLViewerImage::BOOST_UI) 628 else if (mBoostLevel == LLViewerImage::BOOST_UI && !have_all_data)
626 { 629 {
627 priority = 1.f; 630 priority = 1.f;
628 } 631 }
629 else if (pixel_priority <= 0.f && (cur_discard < 0 || mDesiredDiscardLevel < cur_discard)) 632 else if (pixel_priority <= 0.f && !have_all_data)
630 { 633 {
631 // Not on screen but we might want some data 634 // Not on screen but we might want some data
632 if (mBoostLevel > BOOST_HIGH) 635 if (mBoostLevel > BOOST_HIGH)
@@ -645,6 +648,11 @@ F32 LLViewerImage::calcDecodePriority()
645 return mDecodePriority; 648 return mDecodePriority;
646 } 649 }
647 } 650 }
651 else if ((mBoostLevel == LLViewerImage::BOOST_SCULPTED) && !have_all_data)
652 {
653 // Sculpted images are small, treat them like they always have no data.
654 priority = 900000.f;
655 }
648 else if (cur_discard < 0) 656 else if (cur_discard < 0)
649 { 657 {
650 // We don't have any data yet, so we don't know the size of the image, treat as 1024x1024 658 // We don't have any data yet, so we don't know the size of the image, treat as 1024x1024
@@ -655,7 +663,7 @@ F32 LLViewerImage::calcDecodePriority()
655 ddiscard = llclamp(ddiscard, 1, 9); 663 ddiscard = llclamp(ddiscard, 1, 9);
656 priority = ddiscard*100000.f; 664 priority = ddiscard*100000.f;
657 } 665 }
658 else if (cur_discard <= mMinDiscardLevel) 666 else if ((mMinDiscardLevel > 0) && (cur_discard <= mMinDiscardLevel))
659 { 667 {
660 // larger mips are corrupted 668 // larger mips are corrupted
661 priority = -3.0f; 669 priority = -3.0f;
@@ -681,15 +689,14 @@ F32 LLViewerImage::calcDecodePriority()
681 } 689 }
682 if (priority > 0.0f) 690 if (priority > 0.0f)
683 { 691 {
684 pixel_priority = llclamp(pixel_priority, 0.0f, priority-1.f); 692 pixel_priority = llclamp(pixel_priority, 0.0f, priority-1.f); // priority range = 100000-900000
685 priority += pixel_priority;
686 if ( mBoostLevel > BOOST_HIGH) 693 if ( mBoostLevel > BOOST_HIGH)
687 { 694 {
688 priority += 1000000.f + 1000.f * mBoostLevel; 695 priority = 1000000.f + pixel_priority + 1000.f * mBoostLevel;
689 } 696 }
690 else if ( mBoostLevel > 0) 697 else
691 { 698 {
692 priority += 0.f + 1000.f * mBoostLevel; 699 priority += 0.f + pixel_priority + 1000.f * mBoostLevel;
693 } 700 }
694 } 701 }
695 return priority; 702 return priority;
@@ -774,7 +781,11 @@ bool LLViewerImage::updateFetch()
774 { 781 {
775 // Sets mRawDiscardLevel, mRawImage, mAuxRawImage 782 // Sets mRawDiscardLevel, mRawImage, mAuxRawImage
776 S32 fetch_discard = current_discard; 783 S32 fetch_discard = current_discard;
784 if (mRawImage.notNull()) sRawCount--;
785 if (mAuxRawImage.notNull()) sAuxCount--;
777 bool finished = LLAppViewer::getTextureFetch()->getRequestFinished(getID(), fetch_discard, mRawImage, mAuxRawImage); 786 bool finished = LLAppViewer::getTextureFetch()->getRequestFinished(getID(), fetch_discard, mRawImage, mAuxRawImage);
787 if (mRawImage.notNull()) sRawCount++;
788 if (mAuxRawImage.notNull()) sAuxCount++;
778 if (finished) 789 if (finished)
779 { 790 {
780 mIsFetching = FALSE; 791 mIsFetching = FALSE;
@@ -958,7 +969,8 @@ void LLViewerImage::setIsMissingAsset()
958 969
959//============================================================================ 970//============================================================================
960 971
961void LLViewerImage::setLoadedCallback( loaded_callback_func loaded_callback, S32 discard_level, BOOL keep_imageraw, void* userdata) 972void LLViewerImage::setLoadedCallback( loaded_callback_func loaded_callback,
973 S32 discard_level, BOOL keep_imageraw, BOOL needs_aux, void* userdata)
962{ 974{
963 // 975 //
964 // Don't do ANYTHING here, just add it to the global callback list 976 // Don't do ANYTHING here, just add it to the global callback list
@@ -970,6 +982,12 @@ void LLViewerImage::setLoadedCallback( loaded_callback_func loaded_callback, S32
970 } 982 }
971 LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata); 983 LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata);
972 mLoadedCallbackList.push_back(entryp); 984 mLoadedCallbackList.push_back(entryp);
985 mNeedsAux |= needs_aux;
986 if (mNeedsAux && mAuxRawImage.isNull() && getDiscardLevel() >= 0)
987 {
988 // We need aux data, but we've already loaded the image, and it didn't have any
989 llwarns << "No aux data available for callback for image:" << getID() << llendl;
990 }
973} 991}
974 992
975bool LLViewerImage::doLoadedCallbacks() 993bool LLViewerImage::doLoadedCallbacks()
@@ -1090,9 +1108,7 @@ bool LLViewerImage::doLoadedCallbacks()
1090 // We have GL data. 1108 // We have GL data.
1091 1109
1092 destroyRawImage(); 1110 destroyRawImage();
1093 createRawImage(gl_discard, TRUE); 1111 readBackRawImage(gl_discard);
1094 readBackRaw(gl_discard, mRawImage, false);
1095 mIsRawImageValid = TRUE;
1096 llassert_always(mRawImage.notNull()); 1112 llassert_always(mRawImage.notNull());
1097 llassert_always(!mNeedsAux || mAuxRawImage.notNull()); 1113 llassert_always(!mNeedsAux || mAuxRawImage.notNull());
1098 } 1114 }
@@ -1237,32 +1253,28 @@ BOOL LLViewerImage::bind(S32 stage) const
1237} 1253}
1238 1254
1239// Was in LLImageGL 1255// Was in LLImageGL
1240LLImageRaw* LLViewerImage::createRawImage(S8 discard_level, BOOL allocate) 1256LLImageRaw* LLViewerImage::readBackRawImage(S8 discard_level)
1241{ 1257{
1242 llassert(discard_level >= 0); 1258 llassert_always(discard_level >= 0);
1259 llassert_always(mComponents > 0);
1243 if (mRawImage.notNull()) 1260 if (mRawImage.notNull())
1244 { 1261 {
1245 llerrs << "createRawImage() called with existing mRawImage" << llendl; 1262 llerrs << "called with existing mRawImage" << llendl;
1246 mRawImage = NULL; 1263 mRawImage = NULL;
1247 mAuxRawImage = NULL;
1248 }
1249 if (allocate && mComponents)
1250 {
1251 mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), mComponents);
1252 mIsRawImageValid = TRUE;
1253 }
1254 else
1255 {
1256 mRawImage = new LLImageRaw;
1257 mIsRawImageValid = FALSE;
1258 } 1264 }
1265 mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), mComponents);
1266 sRawCount++;
1259 mRawDiscardLevel = discard_level; 1267 mRawDiscardLevel = discard_level;
1268 readBackRaw(mRawDiscardLevel, mRawImage, false);
1269 mIsRawImageValid = TRUE;
1260 1270
1261 return mRawImage; 1271 return mRawImage;
1262} 1272}
1263 1273
1264void LLViewerImage::destroyRawImage() 1274void LLViewerImage::destroyRawImage()
1265{ 1275{
1276 if (mRawImage.notNull()) sRawCount--;
1277 if (mAuxRawImage.notNull()) sAuxCount--;
1266 mRawImage = NULL; 1278 mRawImage = NULL;
1267 mAuxRawImage = NULL; 1279 mAuxRawImage = NULL;
1268 mIsRawImageValid = FALSE; 1280 mIsRawImageValid = FALSE;