summaryrefslogtreecommitdiff
path: root/indra/newview/llviewertexturelist.cpp
diff options
context:
space:
mode:
authorandreykproductengine <akleshchev@productengine.com>2016-02-16 20:44:53 +0200
committerandreykproductengine <akleshchev@productengine.com>2016-02-16 20:44:53 +0200
commita0e9ee475758c1825ba4a0957f4047e1dc24c8a3 (patch)
tree1fbef6cef6a23b47af1a29266d28120dadfeffc5 /indra/newview/llviewertexturelist.cpp
parentd8f7a40dea011b3a68fdf8120c8bc7035e93019a (diff)
MAINT-2199 separating UI elements from in-world textures.
Diffstat (limited to 'indra/newview/llviewertexturelist.cpp')
-rwxr-xr-xindra/newview/llviewertexturelist.cpp106
1 files changed, 75 insertions, 31 deletions
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 926c40307b..10fbc8bd25 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -70,6 +70,25 @@ S32 LLViewerTextureList::sNumImages = 0;
LLViewerTextureList gTextureList;
static LLTrace::BlockTimerStatHandle FTM_PROCESS_IMAGES("Process Images");
+bool is_ui_element(S32 priority)
+{
+ // alternatively don't discard flag can be used
+ return priority == LLViewerFetchedTexture::BOOST_ICON
+ || priority == LLViewerFetchedTexture::BOOST_UI;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+LLTextureKey::LLTextureKey()
+: textureId(LLUUID::null),
+isUI(false)
+{
+}
+
+LLTextureKey::LLTextureKey(LLUUID id, bool is_ui)
+: textureId(id), isUI(is_ui)
+{
+}
///////////////////////////////////////////////////////////////////////////////
@@ -351,7 +370,8 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
if (full_path.empty())
{
LL_WARNS() << "Failed to find local image file: " << filename << LL_ENDL;
- return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+ LLViewerTexture::EBoostLevel priority = LLGLTexture::BOOST_UI;
+ return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, priority);
}
std::string url = "file://" + full_path;
@@ -384,7 +404,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
new_id.generate(url);
}
- LLPointer<LLViewerFetchedTexture> imagep = findImage(new_id);
+ LLPointer<LLViewerFetchedTexture> imagep = findImage(new_id, is_ui_element(boost_priority));
if (!imagep.isNull())
{
@@ -422,12 +442,12 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
imagep->setExplicitFormat(internal_format, primary_format);
}
- addImage(imagep);
-
+ bool is_ui = is_ui_element(boost_priority);
+ addImage(imagep, is_ui);
+
if (boost_priority != 0)
{
- if (boost_priority == LLViewerFetchedTexture::BOOST_UI ||
- boost_priority == LLViewerFetchedTexture::BOOST_ICON)
+ if (is_ui)
{
imagep->dontDiscard();
}
@@ -464,7 +484,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
return (LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI));
}
- LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id);
+ LLPointer<LLViewerFetchedTexture> imagep = findImage(image_id, is_ui_element(boost_priority));
if (!imagep.isNull())
{
LLViewerFetchedTexture *texture = imagep.get();
@@ -525,13 +545,13 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
{
imagep->setExplicitFormat(internal_format, primary_format);
}
-
- addImage(imagep);
-
+
+ bool is_ui = is_ui_element(boost_priority);
+ addImage(imagep, is_ui);
+
if (boost_priority != 0)
{
- if (boost_priority == LLViewerFetchedTexture::BOOST_UI ||
- boost_priority == LLViewerFetchedTexture::BOOST_ICON)
+ if (is_ui)
{
imagep->dontDiscard();
}
@@ -553,12 +573,28 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
return imagep ;
}
-LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id)
+void LLViewerTextureList::findTexturesByID(const LLUUID &image_id, std::vector<LLViewerFetchedTexture*> &output)
+{
+ LLTextureKey search_key(image_id, false);
+ uuid_map_t::iterator iter = mUUIDMap.lower_bound(search_key);
+ while (iter != mUUIDMap.end() && iter->first.textureId == image_id)
+ {
+ output.push_back(iter->second);
+ iter++;
+ }
+}
+
+LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLTextureKey &search_key)
+{
+ uuid_map_t::iterator iter = mUUIDMap.find(search_key);
+ if (iter == mUUIDMap.end())
+ return NULL;
+ return iter->second;
+}
+
+LLViewerFetchedTexture *LLViewerTextureList::findImage(const LLUUID &image_id, bool is_ui)
{
- uuid_map_t::iterator iter = mUUIDMap.find(image_id);
- if(iter == mUUIDMap.end())
- return NULL;
- return iter->second;
+ return findImage(LLTextureKey(image_id, is_ui));
}
void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image)
@@ -603,7 +639,7 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
<< " but doesn't have mInImageList set"
<< " ref count is " << image->getNumRefs()
<< LL_ENDL;
- uuid_map_t::iterator iter = mUUIDMap.find(image->getID());
+ uuid_map_t::iterator iter = mUUIDMap.find(LLTextureKey(image->getID(), image->isUITexture()));
if(iter == mUUIDMap.end())
{
LL_INFOS() << "Image " << image->getID() << " is also not in mUUIDMap!" << LL_ENDL ;
@@ -628,7 +664,7 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
image->setInImageList(FALSE) ;
}
-void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
+void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image, bool add_ui)
{
if (!new_image)
{
@@ -636,16 +672,17 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
}
//llassert(new_image);
LLUUID image_id = new_image->getID();
+ LLTextureKey key(image_id, add_ui);
- LLViewerFetchedTexture *image = findImage(image_id);
+ LLViewerFetchedTexture *image = findImage(key);
if (image)
{
LL_INFOS() << "Image with ID " << image_id << " already in list" << LL_ENDL;
}
sNumImages++;
-
+
addImageToList(new_image);
- mUUIDMap[image_id] = new_image;
+ mUUIDMap[key] = new_image;
}
@@ -657,8 +694,8 @@ void LLViewerTextureList::deleteImage(LLViewerFetchedTexture *image)
{
mCallbackList.erase(image);
}
-
- llverify(mUUIDMap.erase(image->getID()) == 1);
+ LLTextureKey key(image->getID(), image->isUITexture());
+ llverify(mUUIDMap.erase(key) == 1);
sNumImages--;
removeImageFromList(image);
}
@@ -801,14 +838,14 @@ void LLViewerTextureList::updateImagesDecodePriorities()
static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities"); // default: 32
const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds.value()) + 1, MAX_PRIO_UPDATES);
S32 update_counter = llmin(max_update_count, mUUIDMap.size());
- uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID);
+ uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateKey);
while ((update_counter-- > 0) && !mUUIDMap.empty())
{
if (iter == mUUIDMap.end())
{
iter = mUUIDMap.begin();
- }
- mLastUpdateUUID = iter->first;
+ }
+ mLastUpdateKey = iter->first;
LLPointer<LLViewerFetchedTexture> imagep = iter->second;
++iter; // safe to increment now
@@ -1061,7 +1098,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
update_counter = max_update_count;
if(update_counter > 0)
{
- uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchUUID);
+ uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchKey);
while ((update_counter > 0) && (total_update_count > 0))
{
if (iter2 == mUUIDMap.end())
@@ -1091,7 +1128,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
fetch_count += (imagep->updateFetch() ? 1 : 0);
if (min_count <= min_update_count)
{
- mLastFetchUUID = imagep->getID();
+ mLastFetchKey = LLTextureKey(imagep->getID(), imagep->isUITexture());
}
if ((min_count-- <= 0) && (image_op_timer.getElapsedTimeF32() > max_time))
{
@@ -1543,12 +1580,19 @@ void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **
LLUUID image_id;
msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, image_id);
- LLViewerFetchedTexture* image = gTextureList.findImage( image_id );
+ LLViewerFetchedTexture* image = gTextureList.findImage( image_id, false);
if( image )
{
- LL_WARNS() << "not in db" << LL_ENDL;
+ LL_WARNS() << "Image not in db" << LL_ENDL;
image->setIsMissingAsset();
}
+
+ image = gTextureList.findImage(image_id, true);
+ if (image)
+ {
+ LL_WARNS() << "Icon not in db" << LL_ENDL;
+ image->setIsMissingAsset();
+ }
}