SL-20288 Lags in Appearance floater

meow-7.2.2
Alexander Gavriliuk 2023-10-09 23:39:45 +02:00
parent 393896be16
commit eb7ab13000
2 changed files with 88 additions and 15 deletions

View File

@ -835,7 +835,6 @@ void LLOutfitListBase::onOpen(const LLSD& info)
// arrive.
category->fetch();
refreshList(outfits);
highlightBaseOutfit();
mIsInitialized = true;
}
@ -843,6 +842,9 @@ void LLOutfitListBase::onOpen(const LLSD& info)
void LLOutfitListBase::refreshList(const LLUUID& category_id)
{
bool wasNull = mRefreshListState.CategoryUUID.isNull();
mRefreshListState.CategoryUUID.setNull();
LLInventoryModel::cat_array_t cat_array;
LLInventoryModel::item_array_t item_array;
@ -855,27 +857,81 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id)
LLInventoryModel::EXCLUDE_TRASH,
is_category);
uuid_vec_t vadded;
uuid_vec_t vremoved;
// Memorize item names for each UUID
std::map<LLUUID, std::string> names;
for (const LLPointer<LLViewerInventoryCategory>& cat : cat_array)
{
names.emplace(std::make_pair(cat->getUUID(), cat->getName()));
}
// Create added and removed items vectors.
computeDifference(cat_array, vadded, vremoved);
// Fill added and removed items vectors.
mRefreshListState.Added.clear();
mRefreshListState.Removed.clear();
computeDifference(cat_array, mRefreshListState.Added, mRefreshListState.Removed);
// Sort added items vector by item name.
std::sort(mRefreshListState.Added.begin(), mRefreshListState.Added.end(),
[names](const LLUUID& a, const LLUUID& b)
{
return LLStringUtil::compareDict(names.at(a), names.at(b)) < 0;
});
// Initialize iterators for added and removed items vectors.
mRefreshListState.AddedIterator = mRefreshListState.Added.begin();
mRefreshListState.RemovedIterator = mRefreshListState.Removed.begin();
LL_INFOS() << "added: " << mRefreshListState.Added.size() <<
", removed: " << mRefreshListState.Removed.size() <<
", changed: " << gInventory.getChangedIDs().size() <<
LL_ENDL;
mRefreshListState.CategoryUUID = category_id;
if (wasNull)
{
gIdleCallbacks.addFunction(onIdle, this);
}
}
// static
void LLOutfitListBase::onIdle(void* userdata)
{
LLOutfitListBase* self = (LLOutfitListBase*)userdata;
self->onIdleRefreshList();
}
void LLOutfitListBase::onIdleRefreshList()
{
if (mRefreshListState.CategoryUUID.isNull())
return;
const F64 MAX_TIME = 0.05f;
F64 curent_time = LLTimer::getTotalSeconds();
const F64 end_time = curent_time + MAX_TIME;
// Handle added tabs.
for (uuid_vec_t::const_iterator iter = vadded.begin();
iter != vadded.end();
++iter)
while (mRefreshListState.AddedIterator < mRefreshListState.Added.end())
{
const LLUUID cat_id = (*iter);
const LLUUID cat_id = (*mRefreshListState.AddedIterator++);
updateAddedCategory(cat_id);
curent_time = LLTimer::getTotalSeconds();
if (curent_time >= end_time)
return;
}
mRefreshListState.Added.clear();
mRefreshListState.AddedIterator = mRefreshListState.Added.end();
// Handle removed tabs.
for (uuid_vec_t::const_iterator iter = vremoved.begin(); iter != vremoved.end(); ++iter)
while (mRefreshListState.RemovedIterator < mRefreshListState.Removed.end())
{
const LLUUID cat_id = (*iter);
const LLUUID cat_id = (*mRefreshListState.RemovedIterator++);
updateRemovedCategory(cat_id);
curent_time = LLTimer::getTotalSeconds();
if (curent_time >= end_time)
return;
}
mRefreshListState.Removed.clear();
mRefreshListState.RemovedIterator = mRefreshListState.Removed.end();
// Get changed items from inventory model and update outfit tabs
// which might have been renamed.
@ -888,9 +944,9 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id)
if (!cat)
{
LLInventoryObject* obj = gInventory.getObject(*items_iter);
if(!obj || (obj->getType() != LLAssetType::AT_CATEGORY))
if (!obj || (obj->getType() != LLAssetType::AT_CATEGORY))
{
return;
break;
}
cat = (LLViewerInventoryCategory*)obj;
}
@ -900,6 +956,12 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id)
}
sortOutfits();
highlightBaseOutfit();
gIdleCallbacks.deleteFunction(onIdle, this);
mRefreshListState.CategoryUUID.setNull();
LL_INFOS() << "done" << LL_ENDL;
}
void LLOutfitListBase::computeDifference(
@ -936,7 +998,6 @@ void LLOutfitListBase::highlightBaseOutfit()
mHighlightedOutfitUUID = base_id;
onHighlightBaseOutfit(base_id, prev_id);
}
}
void LLOutfitListBase::removeSelected()

View File

@ -116,8 +116,20 @@ protected:
void onOutfitsRemovalConfirmation(const LLSD& notification, const LLSD& response);
virtual void onChangeOutfitSelection(LLWearableItemsList* list, const LLUUID& category_id) = 0;
static void onIdle(void* userdata);
void onIdleRefreshList();
struct
{
LLUUID CategoryUUID;
uuid_vec_t Added;
uuid_vec_t Removed;
uuid_vec_t::const_iterator AddedIterator;
uuid_vec_t::const_iterator RemovedIterator;
} mRefreshListState;
bool mIsInitialized;
LLInventoryCategoriesObserver* mCategoriesObserver;
LLInventoryCategoriesObserver* mCategoriesObserver;
LLUUID mSelectedOutfitUUID;
// id of currently highlited outfit
LLUUID mHighlightedOutfitUUID;