From 6812d7a23ae831959cdf88e308bddc8f59533206 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 24 Mar 2025 13:45:22 +0100 Subject: [PATCH] Make colors for FPS display optional and themeable --- indra/newview/app_settings/settings.xml | 11 ++++ indra/newview/llstatusbar.cpp | 50 ++++++++++--------- indra/newview/skins/ansastorm/colors.xml | 15 ++++++ .../ansastorm/themes/classic_brown/colors.xml | 15 ++++++ indra/newview/skins/default/colors.xml | 15 ++++++ .../skins/default/xui/de/menu_hide_navbar.xml | 1 + .../skins/default/xui/de/panel_status_bar.xml | 2 +- .../skins/default/xui/en/menu_hide_navbar.xml | 13 +++++ 8 files changed, 98 insertions(+), 24 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 45d2941acf..b28681798a 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -25423,6 +25423,17 @@ Change of this parameter will affect the layout of buttons in notification toast Value 1 + FSStatusBarShowFPSColors + + Comment + If enabled, display FPS number in a color based on the current status. + Persist + 1 + Type + Boolean + Value + 1 + FSExperimentalLostAttachmentsFix Comment diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index f6e682dd5e..070c56c828 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -604,44 +604,48 @@ void LLStatusBar::refresh() static LLCachedControl fsStatusBarShowFPS(gSavedSettings, "FSStatusBarShowFPS"); if (fsStatusBarShowFPS && mFPSUpdateTimer.getElapsedTimeF32() > 1.f) { + static LLCachedControl fsStatusBarShowFPSColors(gSavedSettings, "FSStatusBarShowFPSColors"); static LLCachedControl max_fps(gSavedSettings, "FramePerSecondLimit"); static LLCachedControl limit_fps_enabled(gSavedSettings, "FSLimitFramerate"); static LLCachedControl vsync_enabled(gSavedSettings, "RenderVSyncEnable"); - static const auto fps_below_limit_color = LLUIColorTable::instance().getColor("Yellow"); - static const auto fps_limit_reached_color = LLUIColorTable::instance().getColor("Green"); - static const auto vsync_limit_reached_color = LLUIColorTable::instance().getColor("Green"); - static const auto fps_uncapped_color = LLUIColorTable::instance().getColor("White"); - static const auto fps_unfocussed_color = LLUIColorTable::instance().getColor("Gray"); + static const auto fps_below_limit_color = LLUIColorTable::instance().getColor("FpsDisplayBelowLimitColor"); + static const auto fps_limit_reached_color = LLUIColorTable::instance().getColor("FpsDisplayFpsLimitReachedColor"); + static const auto vsync_limit_reached_color = LLUIColorTable::instance().getColor("FpsDisplayVSyncLimitReachedColor"); + static const auto fps_uncapped_color = LLUIColorTable::instance().getColor("FpsDisplayUncappedColor"); + static const auto fps_unfocussed_color = LLUIColorTable::instance().getColor("FpsDisplayUnfocussedColor"); static auto current_fps_color = fps_uncapped_color; mFPSUpdateTimer.reset(); const auto fps = LLTrace::get_frame_recording().getPeriodMedianPerSec(LLStatViewer::FPS); mFPSText->setText(llformat("%.1f", fps)); - // if background, go grey, else go white unless we have a cap (checked next) auto fps_color{ fps_uncapped_color }; - auto window = gViewerWindow ? gViewerWindow->getWindow() : nullptr; - if ((window && !window->getVisible()) || !gFocusMgr.getAppHasFocus()) + if (fsStatusBarShowFPSColors) { - fps_color = fps_unfocussed_color; - } - else - { - S32 vsync_freq{ -1 }; - if (window) + // if background, go grey, else go white unless we have a cap (checked next) + auto window = gViewerWindow ? gViewerWindow->getWindow() : nullptr; + if ((window && !window->getVisible()) || !gFocusMgr.getAppHasFocus()) { - vsync_freq = window->getRefreshRate(); + fps_color = fps_unfocussed_color; } + else + { + S32 vsync_freq{ -1 }; + if (window) + { + vsync_freq = window->getRefreshRate(); + } - if (limit_fps_enabled && max_fps > 0) - { - fps_color = (fps >= max_fps - 1) ? fps_limit_reached_color : fps_below_limit_color; - } - // use vsync if enabled and the freq is lower than the max_fps - if (vsync_enabled && vsync_freq > 0 && (!limit_fps_enabled || vsync_freq < (S32)max_fps)) - { - fps_color = (fps >= vsync_freq - 1) ? vsync_limit_reached_color : fps_below_limit_color; + if (limit_fps_enabled && max_fps > 0) + { + fps_color = (fps >= max_fps - 1) ? fps_limit_reached_color : fps_below_limit_color; + } + // use vsync if enabled and the freq is lower than the max_fps + if (vsync_enabled && vsync_freq > 0 && (!limit_fps_enabled || vsync_freq < (S32)max_fps)) + { + fps_color = (fps >= vsync_freq - 1) ? vsync_limit_reached_color : fps_below_limit_color; + } } } diff --git a/indra/newview/skins/ansastorm/colors.xml b/indra/newview/skins/ansastorm/colors.xml index 70634c08d7..bcaba9ba01 100644 --- a/indra/newview/skins/ansastorm/colors.xml +++ b/indra/newview/skins/ansastorm/colors.xml @@ -1410,4 +1410,19 @@ + + + + + diff --git a/indra/newview/skins/ansastorm/themes/classic_brown/colors.xml b/indra/newview/skins/ansastorm/themes/classic_brown/colors.xml index e35d792e45..8b269290fe 100644 --- a/indra/newview/skins/ansastorm/themes/classic_brown/colors.xml +++ b/indra/newview/skins/ansastorm/themes/classic_brown/colors.xml @@ -1403,4 +1403,19 @@ + + + + + diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index d7bbd28619..ac8aae67e8 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -1378,4 +1378,19 @@ + + + + + diff --git a/indra/newview/skins/default/xui/de/menu_hide_navbar.xml b/indra/newview/skins/default/xui/de/menu_hide_navbar.xml index f1a396ccc0..47d5ddd525 100644 --- a/indra/newview/skins/default/xui/de/menu_hide_navbar.xml +++ b/indra/newview/skins/default/xui/de/menu_hide_navbar.xml @@ -10,6 +10,7 @@ + diff --git a/indra/newview/skins/default/xui/de/panel_status_bar.xml b/indra/newview/skins/default/xui/de/panel_status_bar.xml index 8f57418564..c365729f9c 100644 --- a/indra/newview/skins/default/xui/de/panel_status_bar.xml +++ b/indra/newview/skins/default/xui/de/panel_status_bar.xml @@ -33,7 +33,7 @@