summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2024-08-28 23:05:58 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-09-04 10:16:46 +0300
commit4ae1de1f8a78d795958d67afab8356f9a13f707d (patch)
treeea0fe05983562f061a4748a6f4af7253018f9660 /indra/llui
parent36423bd6603c5708028c6e8e9705587b961a4bb2 (diff)
viewer#2411 LLFontGL::render optimizations
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llbutton.cpp45
-rw-r--r--indra/llui/llbutton.h14
2 files changed, 51 insertions, 8 deletions
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 30968225a8..3df7f83d49 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -120,8 +120,9 @@ LLButton::Params::Params()
LLButton::LLButton(const LLButton::Params& p)
-: LLUICtrl(p),
+ : LLUICtrl(p),
LLBadgeOwner(getHandle()),
+ mFontBuffer(false),
mMouseDownFrame(0),
mMouseHeldDownCount(0),
mBorderEnabled( false ),
@@ -329,6 +330,30 @@ void LLButton::onCommit()
LLUICtrl::onCommit();
}
+void LLButton::setUnselectedLabelColor(const LLUIColor& c)
+{
+ mUnselectedLabelColor = c;
+ mFontBuffer.reset();
+}
+
+void LLButton::setSelectedLabelColor(const LLUIColor& c)
+{
+ mSelectedLabelColor = c;
+ mFontBuffer.reset();
+}
+
+void LLButton::setUseEllipses(bool use_ellipses)
+{
+ mUseEllipses = use_ellipses;
+ mFontBuffer.reset();
+}
+
+void LLButton::setUseFontColor(bool use_font_color)
+{
+ mUseFontColor = use_font_color;
+ mFontBuffer.reset();
+}
+
boost::signals2::connection LLButton::setClickedCallback(const CommitCallbackParam& cb)
{
return setClickedCallback(initCommitCallback(cb));
@@ -396,6 +421,15 @@ bool LLButton::postBuild()
return LLUICtrl::postBuild();
}
+void LLButton::onVisibilityChange(bool new_visibility)
+{
+ if (!new_visibility)
+ {
+ mFontBuffer.reset();
+ }
+ return LLUICtrl::onVisibilityChange(new_visibility);
+}
+
bool LLButton::handleUnicodeCharHere(llwchar uni_char)
{
bool handled = false;
@@ -954,7 +988,7 @@ void LLButton::draw()
// LLFontGL::render expects S32 max_chars variable but process in a separate way -1 value.
// Due to U32_MAX is equal to S32 -1 value I have rest this value for non-ellipses mode.
// Not sure if it is really needed. Probably S32_MAX should be always passed as max_chars.
- mLastDrawCharsCount = mGLFont->render(label, 0,
+ mLastDrawCharsCount = mFontBuffer.render(mGLFont, label, 0,
(F32)x,
(F32)(getRect().getHeight() / 2 + mBottomVPad),
label_color % alpha,
@@ -996,6 +1030,7 @@ void LLButton::setToggleState(bool b)
setFlashing(false); // stop flash state whenever the selected/unselected state if reset
// Unselected label assignments
autoResize();
+ mFontBuffer.reset();
}
}
@@ -1025,11 +1060,13 @@ bool LLButton::toggleState()
void LLButton::setLabel( const std::string& label )
{
mUnselectedLabel = mSelectedLabel = label;
+ mFontBuffer.reset();
}
void LLButton::setLabel( const LLUIString& label )
{
mUnselectedLabel = mSelectedLabel = label;
+ mFontBuffer.reset();
}
void LLButton::setLabel( const LLStringExplicit& label )
@@ -1043,17 +1080,20 @@ bool LLButton::setLabelArg( const std::string& key, const LLStringExplicit& text
{
mUnselectedLabel.setArg(key, text);
mSelectedLabel.setArg(key, text);
+ mFontBuffer.reset();
return true;
}
void LLButton::setLabelUnselected( const LLStringExplicit& label )
{
mUnselectedLabel = label;
+ mFontBuffer.reset();
}
void LLButton::setLabelSelected( const LLStringExplicit& label )
{
mSelectedLabel = label;
+ mFontBuffer.reset();
}
bool LLButton::labelIsTruncated() const
@@ -1113,6 +1153,7 @@ void LLButton::resize(const LLUIString& label)
if (btn_width < min_width)
{
reshape(min_width, getRect().getHeight());
+ mFontBuffer.reset();
}
}
}
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h
index 4ecea6d473..f522281e30 100644
--- a/indra/llui/llbutton.h
+++ b/indra/llui/llbutton.h
@@ -35,6 +35,7 @@
#include "v4color.h"
#include "llframetimer.h"
#include "llfontgl.h"
+#include "llfontvertexbuffer.h"
#include "lluiimage.h"
#include "lluistring.h"
@@ -167,15 +168,17 @@ public:
virtual void draw();
/*virtual*/ bool postBuild();
+ /*virtual*/ void onVisibilityChange(bool visible);
+
virtual void onMouseLeave(S32 x, S32 y, MASK mask);
virtual void onMouseCaptureLost();
virtual void onCommit();
- void setUnselectedLabelColor( const LLUIColor& c ) { mUnselectedLabelColor = c; }
- void setSelectedLabelColor( const LLUIColor& c ) { mSelectedLabelColor = c; }
- void setUseEllipses( bool use_ellipses ) { mUseEllipses = use_ellipses; }
- void setUseFontColor( bool use_font_color) { mUseFontColor = use_font_color; }
+ void setUnselectedLabelColor(const LLUIColor& c);
+ void setSelectedLabelColor(const LLUIColor& c);
+ void setUseEllipses(bool use_ellipses);
+ void setUseFontColor(bool use_font_color);
boost::signals2::connection setClickedCallback(const CommitCallbackParam& cb);
@@ -223,7 +226,6 @@ public:
const std::string getLabelUnselected() const { return wstring_to_utf8str(mUnselectedLabel); }
const std::string getLabelSelected() const { return wstring_to_utf8str(mSelectedLabel); }
- void setImageColor(const std::string& color_control);
void setImageColor(const LLUIColor& c);
/*virtual*/ void setColor(const LLUIColor& c);
@@ -278,7 +280,6 @@ public:
void setCommitOnReturn(bool commit) { mCommitOnReturn = commit; }
bool getCommitOnReturn() const { return mCommitOnReturn; }
- static void onHeldDown(void *userdata); // to be called by gIdleCallbacks
static void toggleFloaterAndSetToggleState(LLUICtrl* ctrl, const LLSD& sdname);
static void setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname);
static void setDockableFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname);
@@ -306,6 +307,7 @@ protected:
commit_signal_t* mHeldDownSignal;
const LLFontGL* mGLFont;
+ LLFontVertexBuffer mFontBuffer;
S32 mMouseDownFrame;
S32 mMouseHeldDownCount; // Counter for parameter passed to held-down callback