Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions indra/llui/llaccordionctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,11 @@ void LLAccordionCtrl::ctrlSetLeftTopAndSize(LLView* panel, S32 left, S32 top, S3
return;
LLRect panel_rect = panel->getRect();
panel_rect.setLeftTopAndSize( left, top, width, height);
panel->reshape( width, height, 1);
panel->setRect(panel_rect);
if (panel->getRect() != panel_rect)
{
panel->reshape( width, height, 1);
panel->setRect(panel_rect);
}
}

void LLAccordionCtrl::ctrlShiftVertical(LLView* panel, S32 delta)
Expand Down Expand Up @@ -494,6 +497,7 @@ void LLAccordionCtrl::arrangeMultiple()

void LLAccordionCtrl::arrange()
{
LL_PROFILE_ZONE_SCOPED;
updateNoTabsHelpTextVisibility();

if (mAccordionTabs.empty())
Expand Down
25 changes: 20 additions & 5 deletions indra/llui/llaccordionctrltab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,22 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw()
void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::reshape(S32 width, S32 height, bool called_from_parent /* = true */)
{
S32 header_height = mHeaderTextbox->getTextPixelHeight();
LLRect old_header_rect = mHeaderTextbox->getRect();

LLRect textboxRect(HEADER_TEXT_LEFT_OFFSET, (height + header_height) / 2, width, (height - header_height) / 2);
mHeaderTextbox->reshape(textboxRect.getWidth(), textboxRect.getHeight());
mHeaderTextbox->setRect(textboxRect);
if (old_header_rect.getHeight() != textboxRect.getHeight()
|| old_header_rect.mLeft != textboxRect.mLeft
|| old_header_rect.mTop != textboxRect.mTop
|| old_header_rect.getWidth() > textboxRect.getWidth() // reducing header's width
|| (old_header_rect.getWidth() < textboxRect.getWidth() && old_header_rect.getWidth() < mHeaderTextbox->getTextPixelWidth()))
{
// Expensive text reflow
// Update if position or height changes
// Update if width reduces
// But do not update if text already fits and width increases (arguably LLTextBox::reshape should be smarter, not Accordion)
mHeaderTextbox->reshape(textboxRect.getWidth(), textboxRect.getHeight());
mHeaderTextbox->setRect(textboxRect);
}

if (mHeaderTextbox->getTextPixelWidth() > mHeaderTextbox->getRect().getWidth())
{
Expand Down Expand Up @@ -416,8 +428,11 @@ void LLAccordionCtrlTab::reshape(S32 width, S32 height, bool called_from_parent
LLRect headerRect;

headerRect.setLeftTopAndSize(0, height, width, HEADER_HEIGHT);
mHeader->setRect(headerRect);
mHeader->reshape(headerRect.getWidth(), headerRect.getHeight());
if (mHeader->getRect() != headerRect)
{
mHeader->setRect(headerRect);
mHeader->reshape(headerRect.getWidth(), headerRect.getHeight());
}

if (!mDisplayChildren)
return;
Expand Down Expand Up @@ -932,7 +947,7 @@ void LLAccordionCtrlTab::adjustContainerPanel(const LLRect& child_rect)
show_hide_scrollbar(child_rect);
updateLayout(child_rect);
}
else
else if (mContainerPanel->getRect() != child_rect)
{
mContainerPanel->reshape(child_rect.getWidth(), child_rect.getHeight());
mContainerPanel->setRect(child_rect);
Expand Down
2 changes: 2 additions & 0 deletions indra/llui/lltextbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,8 @@ void LLTextBase::reshape(S32 width, S32 height, bool called_from_parent)
// up-to-date mVisibleTextRect
updateRects();

// Todo: This might be wrong. updateRects already sets needsReflow conditionaly.
// Reflow is expensive and doing it at any twith can be too much.
needsReflow();
}
}
Expand Down
85 changes: 76 additions & 9 deletions indra/newview/llinventoryitemslist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
#include "llinventorymodel.h"
#include "llviewerinventory.h"

bool LLInventoryItemsList::sListIdleRegistered = false;
LLInventoryItemsList::all_list_t LLInventoryItemsList::sAllLists;
LLInventoryItemsList::all_list_t::iterator LLInventoryItemsList::sAllListIter;

LLInventoryItemsList::Params::Params()
{}

Expand All @@ -55,13 +59,39 @@ LLInventoryItemsList::LLInventoryItemsList(const LLInventoryItemsList::Params& p

setNoFilteredItemsMsg(LLTrans::getString("InventoryNoMatchingItems"));

gIdleCallbacks.addFunction(idle, this);
sAllLists.push_back(this);
sAllListIter = sAllLists.begin();

if (!sListIdleRegistered)
{
sAllListIter = sAllLists.begin();
gIdleCallbacks.addFunction(idle, nullptr);

LLEventPumps::instance().obtain("LLApp").listen(
"LLInventoryItemsList",
[](const LLSD& stat)
{
std::string status(stat["status"]);
if (status != "running")
{
// viewer is starting shutdown
gIdleCallbacks.deleteFunction(idle, nullptr);
}
return false;
});
sListIdleRegistered = true;
}
}

// virtual
LLInventoryItemsList::~LLInventoryItemsList()
{
gIdleCallbacks.deleteFunction(idle, this);
auto it = std::find(sAllLists.begin(), sAllLists.end(), this);
if (it != sAllLists.end())
{
sAllLists.erase(it);
sAllListIter = sAllLists.begin();
}
}

void LLInventoryItemsList::refreshList(const LLInventoryModel::item_array_t item_array)
Expand Down Expand Up @@ -111,25 +141,55 @@ void LLInventoryItemsList::updateSelection()
mSelectTheseIDs.clear();
}

void LLInventoryItemsList::doIdle()
bool LLInventoryItemsList::doIdle()
{
if (mRefreshState == REFRESH_COMPLETE) return;
if (mRefreshState == REFRESH_COMPLETE) return true; // done

if (isInVisibleChain() || mForceRefresh || !getFilterSubString().empty())
{
refresh();

mRefreshCompleteSignal(this, LLSD());
return false; // keep going
}
return true; // done
}

//static
void LLInventoryItemsList::idle(void* user_data)
{
LLInventoryItemsList* self = static_cast<LLInventoryItemsList*>(user_data);
if ( self )
{ // Do the real idle
self->doIdle();
if (sAllLists.empty())
return;

LL_PROFILE_ZONE_SCOPED;

using namespace std::chrono;
auto start = steady_clock::now();
const milliseconds time_limit = milliseconds(3);
const auto end_time = start + time_limit;
S32 max_update_count = 50;

if (sAllListIter == sAllLists.end())
{
sAllListIter = sAllLists.begin();
}

S32 updated = 0;
while (steady_clock::now() < end_time
&& updated < max_update_count
&& sAllListIter != sAllLists.end())
{
LLInventoryItemsList* list = *sAllListIter;
// Refresh is split into multiple separate parts,
// so keep repeating it while there is time, until done.
// Todo: refresh() split is pointless now?
// Or still useful for large folders?
if (list->doIdle())
{
// Item is done
++sAllListIter;
updated++;
}
}
}

Expand All @@ -141,6 +201,7 @@ void LLInventoryItemsList::refresh()
{
case REFRESH_ALL:
{
LL_PROFILE_ZONE_NAMED("items_refresh_all");
mAddedItems.clear();
mRemovedItems.clear();
computeDifference(getIDs(), mAddedItems, mRemovedItems);
Expand All @@ -163,6 +224,7 @@ void LLInventoryItemsList::refresh()
}
case REFRESH_LIST_ERASE:
{
LL_PROFILE_ZONE_NAMED("items_refresh_erase");
uuid_vec_t::const_iterator it = mRemovedItems.begin();
for (; mRemovedItems.end() != it; ++it)
{
Expand All @@ -175,6 +237,7 @@ void LLInventoryItemsList::refresh()
}
case REFRESH_LIST_APPEND:
{
LL_PROFILE_ZONE_NAMED("items_refresh_append");
static const unsigned ADD_LIMIT = 25; // Note: affects perfomance

unsigned int nadded = 0;
Expand Down Expand Up @@ -239,6 +302,7 @@ void LLInventoryItemsList::refresh()
}
case REFRESH_LIST_SORT:
{
LL_PROFILE_ZONE_NAMED("items_refresh_sort");
// Filter, sort, rearrange and notify parent about shape changes
filterItems(true, true);

Expand All @@ -255,7 +319,10 @@ void LLInventoryItemsList::refresh()
break;
}
default:
break;
{
mRefreshState = REFRESH_COMPLETE;
break;
}
}

setForceRefresh(mRefreshState != REFRESH_COMPLETE);
Expand Down
13 changes: 11 additions & 2 deletions indra/newview/llinventoryitemslist.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class LLInventoryItemsList : public LLFlatListViewEx
* Sets the flag indicating that the list needs to be refreshed even if it is
* not currently visible.
*/
void setForceRefresh(bool force_refresh) { mForceRefresh = force_refresh; }
void setForceRefresh(bool force_refresh)
{
mForceRefresh = force_refresh;
}

/**
* If refreshes when invisible.
Expand All @@ -76,7 +79,7 @@ class LLInventoryItemsList : public LLFlatListViewEx
* This is needed for example to filter items of the list hidden by closed
* accordion tab.
*/
virtual void doIdle(); // Real idle routine
bool doIdle(); // Real idle routine
static void idle(void* user_data); // static glue to doIdle()

protected:
Expand Down Expand Up @@ -126,6 +129,12 @@ class LLInventoryItemsList : public LLFlatListViewEx
bool mForceRefresh;

commit_signal_t mRefreshCompleteSignal;

// Update synchronization
typedef std::vector<LLInventoryItemsList*> all_list_t;
static all_list_t sAllLists;
static all_list_t::iterator sAllListIter;
static bool sListIdleRegistered;
};

#endif //LL_LLINVENTORYITEMSLIST_H
1 change: 1 addition & 0 deletions indra/newview/lloutfitgallery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ void LLOutfitGallery::getCurrentCategories(uuid_vec_t& vcur)

void LLOutfitGallery::updateAddedCategory(LLUUID cat_id)
{
LL_PROFILE_ZONE_SCOPED;
LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id);
if (!cat) return;

Expand Down
8 changes: 6 additions & 2 deletions indra/newview/lloutfitslist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void LLOutfitsList::onOpen(const LLSD& info)

void LLOutfitsList::updateAddedCategory(LLUUID cat_id)
{
LL_PROFILE_ZONE_SCOPED;
LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id);
if (!cat) return;

Expand Down Expand Up @@ -251,7 +252,9 @@ void LLOutfitsList::updateAddedCategory(LLUUID cat_id)

if (AISAPI::isAvailable() && LLInventoryModelBackgroundFetch::instance().folderFetchActive())
{
// for reliability just fetch it whole, linked items included
// For reliability just fetch it whole, linked items included
// Todo: list is not warrantied to exist once callback arrives
// Fix it!
LLInventoryModelBackgroundFetch::instance().fetchFolderAndLinks(cat_id, [cat_id, list]
{
if (list)
Expand Down Expand Up @@ -1059,6 +1062,7 @@ void LLOutfitListBase::onIdle(void* userdata)

void LLOutfitListBase::onIdleRefreshList()
{
LL_PROFILE_ZONE_SCOPED;
if (LLAppViewer::instance()->quitRequested())
{
mRefreshListState.CategoryUUID.setNull();
Expand All @@ -1072,7 +1076,7 @@ void LLOutfitListBase::onIdleRefreshList()
return;
}

const F64 MAX_TIME = 0.05f;
const F64 MAX_TIME = 0.005f;
F64 curent_time = LLTimer::getTotalSeconds();
const F64 end_time = curent_time + MAX_TIME;

Expand Down