From 43c08ce5dbe1c4d7d84380a8c88dc198edd986c9 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev <andreykproductengine@lindenlab.com> Date: Fri, 18 Sep 2020 16:57:57 +0300 Subject: [PATCH] SL-13729 Performance of LLUI and LLRender2D #3 --- indra/llui/llaccordionctrltab.cpp | 2 +- indra/llui/llconsole.cpp | 4 ++-- indra/llui/llfolderview.cpp | 6 +++--- indra/llui/llfolderviewmodel.cpp | 2 +- indra/llui/lltooltip.cpp | 2 +- indra/llui/llui.cpp | 14 ------------- indra/llui/llui.h | 4 ---- indra/llui/llview.cpp | 14 +++++++++++-- indra/llui/llview.h | 3 +++ indra/newview/llviewerdisplay.cpp | 33 +++++++++++++++---------------- indra/newview/llviewerwindow.cpp | 2 +- 11 files changed, 40 insertions(+), 46 deletions(-) diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 098621b543c..04485c62623 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -1006,7 +1006,7 @@ void LLAccordionCtrlTab::drawChild(const LLRect& root_rect,LLView* child) LLRect screen_rect; localRectToScreen(child->getRect(),&screen_rect); - if ( root_rect.overlaps(screen_rect) && LLUI::getInstance()->mDirtyRect.overlaps(screen_rect)) + if ( root_rect.overlaps(screen_rect) && sDirtyRect.overlaps(screen_rect)) { gGL.matrixMode(LLRender::MM_MODELVIEW); LLUI::pushMatrix(); diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index 636d5a265a1..53a25ac4a55 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -180,8 +180,8 @@ void LLConsole::draw() LLUIImagePtr imagep = LLUI::getUIImage("transparent"); - static LLUICachedControl<F32> console_background_opacity("ConsoleBackgroundOpacity", 0.7f); - F32 console_opacity = llclamp(console_background_opacity(), 0.f, 1.f); + static LLUICachedControl<F32> console_bg_opacity("ConsoleBackgroundOpacity", 0.7f); + F32 console_opacity = llclamp(console_bg_opacity(), 0.f, 1.f); static const LLUIColor color_background = LLUIColorTable::instance().getColor("ConsoleBackground"); auto color = color_background.get(); diff --git a/indra/llui/llfolderview.cpp b/indra/llui/llfolderview.cpp index bdf8941ec76..6c139b89b43 100644 --- a/indra/llui/llfolderview.cpp +++ b/indra/llui/llfolderview.cpp @@ -335,9 +335,9 @@ static LLTrace::BlockTimerStatHandle FTM_FILTER("Filter Folder View"); void LLFolderView::filter( LLFolderViewFilter& filter ) { LL_RECORD_BLOCK_TIME(FTM_FILTER); - static const LLUICachedControl<S32> time_visible("FilterItemsMaxTimePerFrameVisible", 10); - static const LLUICachedControl<S32> time_invisible("FilterItemsMaxTimePerFrameUnvisible", 1); - filter.resetTime(llclamp((S32)(mParentPanel.get()->getVisible() ? time_visible : time_invisible), 1, 100)); + static LLUICachedControl<S32> time_visible("FilterItemsMaxTimePerFrameVisible", 10); + static LLUICachedControl<S32> time_invisible("FilterItemsMaxTimePerFrameUnvisible", 1); + filter.resetTime(llclamp((mParentPanel.get()->getVisible() ? time_visible() : time_invisible()), 1, 100)); // Note: we filter the model, not the view getViewModelItem()->filter(filter); diff --git a/indra/llui/llfolderviewmodel.cpp b/indra/llui/llfolderviewmodel.cpp index 21002a1a2c8..fbb6c7aa385 100644 --- a/indra/llui/llfolderviewmodel.cpp +++ b/indra/llui/llfolderviewmodel.cpp @@ -48,7 +48,7 @@ std::string LLFolderViewModelCommon::getStatusText() void LLFolderViewModelCommon::filter() { - static const LLUICachedControl<S32> max_time("FilterItemsMaxTimePerFrameVisible", 10); + static LLUICachedControl<S32> max_time("FilterItemsMaxTimePerFrameVisible", 10); getFilter().resetTime(llclamp(max_time(), 1, 100)); mFolderView->getViewModelItem()->filter(getFilter()); } diff --git a/indra/llui/lltooltip.cpp b/indra/llui/lltooltip.cpp index 02b60c08e17..db1247c7a2b 100644 --- a/indra/llui/lltooltip.cpp +++ b/indra/llui/lltooltip.cpp @@ -364,7 +364,7 @@ void LLToolTip::draw() if (mFadeTimer.getStarted()) { static LLUICachedControl<F32> tool_tip_fade_time("ToolTipFadeTime", 1.f); - alpha = clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, tool_tip_fade_time, 1.f, 0.f); + alpha = clamp_rescale(mFadeTimer.getElapsedTimeF32(), 0.f, tool_tip_fade_time(), 1.f, 0.f); if (alpha == 0.f) { // finished fading out, so hide ourselves diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 39b43aee4f2..c0e438e9889 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -154,7 +154,6 @@ mAudioCallback(audio_callback), mDeferredAudioCallback(deferred_audio_callback), mWindow(NULL), // set later in startup mRootView(NULL), -mDirty(FALSE), mHelpImpl(NULL) { LLRender2D::initParamSingleton(image_provider); @@ -206,19 +205,6 @@ void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& rem mClearPopupsFunc = clear_popups; } -void LLUI::dirtyRect(LLRect rect) -{ - if (!mDirty) - { - mDirtyRect = rect; - mDirty = TRUE; - } - else - { - mDirtyRect.unionWith(rect); - } -} - void LLUI::setMousePositionScreen(S32 x, S32 y) { #if defined(LL_DARWIN) diff --git a/indra/llui/llui.h b/indra/llui/llui.h index a27b9c3da82..a63756ab5d1 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -245,10 +245,6 @@ class LLUI final : public LLParamSingleton<LLUI> void setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t&, const clear_popups_t& ); - LLRect mDirtyRect; - BOOL mDirty; - void dirtyRect(LLRect rect); - // Return the ISO639 language name ("en", "ko", etc.) for the viewer UI. // http://www.loc.gov/standards/iso639-2/php/code_list.php std::string getUILanguage(); diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 031a95ddf2d..47da4b807f8 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -60,6 +60,8 @@ static const S32 LINE_HEIGHT = 15; S32 LLView::sDepth = 0; bool LLView::sDebugRects = false; +bool LLView::sIsRectDirty = false; +LLRect LLView::sDirtyRect; bool LLView::sDebugRectsShowNames = true; bool LLView::sDebugKeys = false; bool LLView::sDebugMouseHandling = false; @@ -1202,7 +1204,7 @@ void LLView::drawChildren() if (viewp->getVisible() && viewp->getRect().isValid()) { LLRect screen_rect = viewp->calcScreenRect(); - if ( rootp->getLocalRect().overlaps(screen_rect) && uiInst.mDirtyRect.overlaps(screen_rect)) + if ( rootp->getLocalRect().overlaps(screen_rect) && sDirtyRect.overlaps(screen_rect)) { LLUI::pushMatrix(); { @@ -1244,7 +1246,15 @@ void LLView::dirtyRect() parent = parent->getParent(); } - LLUI::getInstance()->dirtyRect(cur->calcScreenRect()); + if (!sIsRectDirty) + { + sDirtyRect = cur->calcScreenRect(); + sIsRectDirty = true; + } + else + { + sDirtyRect.unionWith(cur->calcScreenRect()); + } } //Draw a box for debugging. diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 5c91c37d3cd..c60dcf3344f 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -657,6 +657,9 @@ class LLView // Draw debug rectangles around widgets to help with alignment and spacing static bool sDebugRects; + static bool sIsRectDirty; + static LLRect sDirtyRect; + // Draw widget names and sizes when drawing debug rectangles, turning this // off is useful to make the rectangles themselves easier to see. static bool sDebugRectsShowNames; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 8df373dd5e1..249d0feb2ba 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1573,10 +1573,9 @@ void render_ui_2d() if (LLPipeline::RenderUIBuffer) { - LLUI* ui_inst = LLUI::getInstance(); - if (ui_inst->mDirty) + if (LLView::sIsRectDirty) { - ui_inst->mDirty = FALSE; + LLView::sIsRectDirty = false; LLRect t_rect; gPipeline.mUIScreen.bindTarget(); @@ -1584,25 +1583,25 @@ void render_ui_2d() { static const S32 pad = 8; - ui_inst->mDirtyRect.mLeft -= pad; - ui_inst->mDirtyRect.mRight += pad; - ui_inst->mDirtyRect.mBottom -= pad; - ui_inst->mDirtyRect.mTop += pad; + LLView::sDirtyRect.mLeft -= pad; + LLView::sDirtyRect.mRight += pad; + LLView::sDirtyRect.mBottom -= pad; + LLView::sDirtyRect.mTop += pad; LLGLEnable scissor(GL_SCISSOR_TEST); - static LLRect last_rect = ui_inst->mDirtyRect; + static LLRect last_rect = LLView::sDirtyRect; //union with last rect to avoid mouse poop - last_rect.unionWith(ui_inst->mDirtyRect); + last_rect.unionWith(LLView::sDirtyRect); - t_rect = ui_inst->mDirtyRect; - ui_inst->mDirtyRect = last_rect; + t_rect = LLView::sDirtyRect; + LLView::sDirtyRect = last_rect; last_rect = t_rect; - - last_rect.mLeft = LLRect::tCoordType(last_rect.mLeft / ui_inst->getScaleFactor().mV[0]); - last_rect.mRight = LLRect::tCoordType(last_rect.mRight / ui_inst->getScaleFactor().mV[0]); - last_rect.mTop = LLRect::tCoordType(last_rect.mTop / ui_inst->getScaleFactor().mV[1]); - last_rect.mBottom = LLRect::tCoordType(last_rect.mBottom / ui_inst->getScaleFactor().mV[1]); + + last_rect.mLeft = LLRect::tCoordType(last_rect.mLeft / LLUI::getScaleFactor().mV[0]); + last_rect.mRight = LLRect::tCoordType(last_rect.mRight / LLUI::getScaleFactor().mV[0]); + last_rect.mTop = LLRect::tCoordType(last_rect.mTop / LLUI::getScaleFactor().mV[1]); + last_rect.mBottom = LLRect::tCoordType(last_rect.mBottom / LLUI::getScaleFactor().mV[1]); LLRect clip_rect(last_rect); @@ -1614,7 +1613,7 @@ void render_ui_2d() gPipeline.mUIScreen.flush(); gGL.setColorMask(true, false); - ui_inst->mDirtyRect = t_rect; + LLView::sDirtyRect = t_rect; } LLGLDisable cull(GL_CULL_FACE); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b15f7eec901..691cd9e0c0a 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2570,7 +2570,7 @@ void LLViewerWindow::draw() if (!LLPipeline::RenderUIBuffer) { - LLUI::getInstance()->mDirtyRect = getWindowRectScaled(); + LLView::sDirtyRect = getWindowRectScaled(); } // HACK for timecode debugging -- GitLab