summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2023-03-01 10:26:34 -0500
committerAndrey Lihatskiy <alihatskiy@productengine.com>2023-03-03 19:44:22 +0200
commitcdb3c018af9fc75064dc63537e61c5df567c331a (patch)
tree04b8fafb96972dc7fa76cc61d008a59b45a4579a /indra/llui
parent89afd1cd4838022267f117efb65939c04c35f3da (diff)
SL-19336 Unload avatar and group icons from memory when not visible to reduce memory pressure on extremely large friends lists
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/lliconctrl.cpp26
-rw-r--r--indra/llui/lliconctrl.h3
-rw-r--r--indra/llui/lltextbase.cpp4
-rw-r--r--indra/llui/llview.h1
4 files changed, 32 insertions, 2 deletions
diff --git a/indra/llui/lliconctrl.cpp b/indra/llui/lliconctrl.cpp
index e01aba402e..2791377a5e 100644
--- a/indra/llui/lliconctrl.cpp
+++ b/indra/llui/lliconctrl.cpp
@@ -37,6 +37,8 @@
#include "lluiimage.h"
#include "llwindow.h"
+#include "llgltexture.h"
+
static LLDefaultChildRegistry::Register<LLIconCtrl> r("icon");
LLIconCtrl::Params::Params()
@@ -94,6 +96,22 @@ BOOL LLIconCtrl::handleHover(S32 x, S32 y, MASK mask)
return LLUICtrl::handleHover(x, y, mask);
}
+void LLIconCtrl::onVisibilityChange(BOOL new_visibility)
+{
+ LLUICtrl::onVisibilityChange(new_visibility);
+ if (mPriority == LLGLTexture::BOOST_ICON)
+ {
+ if (new_visibility)
+ {
+ loadImage(getValue(), mPriority);
+ }
+ else
+ {
+ mImagep = nullptr;
+ }
+ }
+}
+
// virtual
// value might be a string or a UUID
void LLIconCtrl::setValue(const LLSD& value)
@@ -110,6 +128,14 @@ void LLIconCtrl::setValue(const LLSD& value, S32 priority)
tvalue = LLSD(LLUUID(value.asString()));
}
LLUICtrl::setValue(tvalue);
+
+ loadImage(tvalue, priority);
+}
+
+void LLIconCtrl::loadImage(const LLSD& tvalue, S32 priority)
+{
+ if(mPriority == LLGLTexture::BOOST_ICON && !getVisible()) return;
+
if (tvalue.isUUID())
{
mImagep = LLUI::getUIImageByID(tvalue.asUUID(), priority);
diff --git a/indra/llui/lliconctrl.h b/indra/llui/lliconctrl.h
index 9c3b517bca..5d6c544571 100644
--- a/indra/llui/lliconctrl.h
+++ b/indra/llui/lliconctrl.h
@@ -72,6 +72,7 @@ public:
virtual BOOL handleHover(S32 x, S32 y, MASK mask);
// lluictrl overrides
+ void onVisibilityChange(BOOL new_visibility);
virtual void setValue(const LLSD& value );
std::string getImageName() const;
@@ -95,6 +96,8 @@ protected:
bool mInteractable;
private:
+ void loadImage(const LLSD& value, S32 priority);
+
LLUIColor mColor;
LLPointer<LLUIImage> mImagep;
};
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 82a3c01c6d..3d8cf74855 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1356,9 +1356,9 @@ void LLTextBase::draw()
drawCursor();
}
- mDocumentView->setVisible(FALSE);
+ mDocumentView->setVisibleDirect(FALSE);
LLUICtrl::draw();
- mDocumentView->setVisible(TRUE);
+ mDocumentView->setVisibleDirect(TRUE);
}
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index bec45df78a..8aa97aac39 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -287,6 +287,7 @@ public:
void setAllChildrenEnabled(BOOL b);
virtual void setVisible(BOOL visible);
+ void setVisibleDirect(BOOL visible) { mVisible = visible; }
const BOOL& getVisible() const { return mVisible; }
virtual void setEnabled(BOOL enabled);
BOOL getEnabled() const { return mEnabled; }