From 4ae1de1f8a78d795958d67afab8356f9a13f707d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 28 Aug 2024 23:05:58 +0300 Subject: viewer#2411 LLFontGL::render optimizations --- indra/llui/llbutton.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'indra/llui/llbutton.cpp') 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(); } } } -- cgit v1.2.3 From a638d9610d9f369eca6dff74e8860ca466c253c7 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 29 Aug 2024 18:49:10 +0300 Subject: viewer#2411 LLFontGL::render optimizations #2 --- indra/llui/llbutton.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 7 deletions(-) (limited to 'indra/llui/llbutton.cpp') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 3df7f83d49..a9f1c10256 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -125,7 +125,6 @@ LLButton::LLButton(const LLButton::Params& p) mFontBuffer(false), mMouseDownFrame(0), mMouseHeldDownCount(0), - mBorderEnabled( false ), mFlashing( false ), mCurGlowStrength(0.f), mNeedsHighlight(false), @@ -423,11 +422,38 @@ bool LLButton::postBuild() void LLButton::onVisibilityChange(bool new_visibility) { - if (!new_visibility) + mFontBuffer.reset(); + return LLUICtrl::onVisibilityChange(new_visibility); +} + +void LLButton::reshape(S32 width, S32 height, bool called_from_parent) +{ + S32 delta_width = width - getRect().getWidth(); + S32 delta_height = height - getRect().getHeight(); + + if (delta_width || delta_height || sForceReshape) { + LLUICtrl::reshape(width, height, called_from_parent); mFontBuffer.reset(); } - return LLUICtrl::onVisibilityChange(new_visibility); +} + +void LLButton::translate(S32 x, S32 y) +{ + LLUICtrl::translate(x, y); + mFontBuffer.reset(); +} + +void LLButton::setRect(const LLRect& rect) +{ + LLUICtrl::setRect(rect); + mFontBuffer.reset(); +} + +void LLButton::dirtyRect() +{ + LLUICtrl::dirtyRect(); + mFontBuffer.reset(); } bool LLButton::handleUnicodeCharHere(llwchar uni_char) @@ -616,19 +642,25 @@ void LLButton::onMouseLeave(S32 x, S32 y, MASK mask) { LLUICtrl::onMouseLeave(x, y, mask); - mNeedsHighlight = false; + setHighlight(false); } void LLButton::setHighlight(bool b) { - mNeedsHighlight = b; + if (mNeedsHighlight != b) + { + mNeedsHighlight = b; + mFontBuffer.reset(); + } } bool LLButton::handleHover(S32 x, S32 y, MASK mask) { if (isInEnabledChain() && (!gFocusMgr.getMouseCapture() || gFocusMgr.getMouseCapture() == this)) - mNeedsHighlight = true; + { + setHighlight(true); + } if (!childrenHandleHover(x, y, mask)) { @@ -1096,6 +1128,18 @@ void LLButton::setLabelSelected( const LLStringExplicit& label ) mFontBuffer.reset(); } +void LLButton::setDisabledLabelColor(const LLUIColor& c) +{ + mDisabledLabelColor = c; + mFontBuffer.reset(); +} + +void LLButton::setFont(const LLFontGL* font) +{ + mGLFont = (font ? font : LLFontGL::getFontSansSerif()); + mFontBuffer.reset(); +} + bool LLButton::labelIsTruncated() const { return getCurrentLabel().getString().size() > mLastDrawCharsCount; @@ -1106,6 +1150,12 @@ const LLUIString& LLButton::getCurrentLabel() const return getToggleState() ? mSelectedLabel : mUnselectedLabel; } +void LLButton::setDropShadowedText(bool b) +{ + mDropShadowedText = b; + mFontBuffer.reset(); +} + void LLButton::setImageUnselected(LLPointer image) { mImageUnselected = image; @@ -1153,7 +1203,6 @@ void LLButton::resize(const LLUIString& label) if (btn_width < min_width) { reshape(min_width, getRect().getHeight()); - mFontBuffer.reset(); } } } @@ -1190,6 +1239,7 @@ void LLButton::setImageDisabledSelected(LLPointer image) mImageDisabledSelected = image; mDisabledImageColor = mImageColor; mFadeWhenDisabled = true; + mFontBuffer.reset(); } void LLButton::setImagePressed(LLPointer image) -- cgit v1.2.3 From 57ab1a410f9cb3534bb403e034743505758579d8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Sep 2024 13:46:13 +0300 Subject: viewer#2411 A bit more coverage for font buffer --- indra/llui/llbutton.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'indra/llui/llbutton.cpp') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index a9f1c10256..d4e5d501db 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -43,6 +43,8 @@ #include "llfloater.h" #include "llfloaterreg.h" #include "llfocusmgr.h" +#include "llfontgl.h" +#include "llfontvertexbuffer.h" #include "llwindow.h" #include "llnotificationsutil.h" #include "llrender.h" @@ -438,18 +440,6 @@ void LLButton::reshape(S32 width, S32 height, bool called_from_parent) } } -void LLButton::translate(S32 x, S32 y) -{ - LLUICtrl::translate(x, y); - mFontBuffer.reset(); -} - -void LLButton::setRect(const LLRect& rect) -{ - LLUICtrl::setRect(rect); - mFontBuffer.reset(); -} - void LLButton::dirtyRect() { LLUICtrl::dirtyRect(); -- cgit v1.2.3 From 4cc0edb189c4deaa205f986d20a6959aa83fb25c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Sep 2024 22:14:42 +0300 Subject: viewer#2411 Cleanup --- indra/llui/llbutton.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llui/llbutton.cpp') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index d4e5d501db..387d2c0d07 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -124,7 +124,6 @@ LLButton::Params::Params() LLButton::LLButton(const LLButton::Params& p) : LLUICtrl(p), LLBadgeOwner(getHandle()), - mFontBuffer(false), mMouseDownFrame(0), mMouseHeldDownCount(0), mFlashing( false ), -- cgit v1.2.3 From 2fc8d5ff3cfa1b9ad00b310cd4a6cdb557b9415c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 3 Sep 2024 17:22:04 +0300 Subject: viewer#2411 Cleanup #2 --- indra/llui/llbutton.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'indra/llui/llbutton.cpp') diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index 387d2c0d07..1bce31edb1 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -427,18 +427,6 @@ void LLButton::onVisibilityChange(bool new_visibility) return LLUICtrl::onVisibilityChange(new_visibility); } -void LLButton::reshape(S32 width, S32 height, bool called_from_parent) -{ - S32 delta_width = width - getRect().getWidth(); - S32 delta_height = height - getRect().getHeight(); - - if (delta_width || delta_height || sForceReshape) - { - LLUICtrl::reshape(width, height, called_from_parent); - mFontBuffer.reset(); - } -} - void LLButton::dirtyRect() { LLUICtrl::dirtyRect(); -- cgit v1.2.3