From 9760b960c503d8f1742aab514212bc571e532164 Mon Sep 17 00:00:00 2001 From: mobserveur Date: Mon, 27 May 2024 04:33:20 +0200 Subject: added a fps counter in the status bar it displays an fps counter on the status bar --- indra/newview/llstatusbar.cpp | 12 ++++++++++++ indra/newview/llstatusbar.h | 2 ++ indra/newview/skins/default/colors.xml | 3 +++ indra/newview/skins/default/xui/en/panel_status_bar.xml | 16 ++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index f8bb4f3351..a0a625c5fc 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -109,6 +109,7 @@ static void onClickVolume(void*); LLStatusBar::LLStatusBar(const LLRect& rect) : LLPanel(), mTextTime(NULL), + mTextFps(NULL), mSGBandwidth(NULL), mSGPacketLoss(NULL), mBtnVolume(NULL), @@ -127,6 +128,7 @@ LLStatusBar::LLStatusBar(const LLRect& rect) mBalanceTimer = new LLFrameTimer(); mHealthTimer = new LLFrameTimer(); + mFpsUpdateTimer = new LLFrameTimer(); buildFromFile("panel_status_bar.xml"); } @@ -164,6 +166,7 @@ BOOL LLStatusBar::postBuild() gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3)); mTextTime = getChild("TimeText" ); + mTextFps = getChild("FpsText"); getChild("buyL")->setCommitCallback( boost::bind(&LLStatusBar::onClickBuyCurrency, this)); @@ -297,6 +300,15 @@ void LLStatusBar::refresh() //mSGBandwidth->setThreshold(2, bwtotal); } + if(mFpsUpdateTimer->getElapsedTimeF32() >= 1.0f) + { + mFpsUpdateTimer->reset(); + + S32 fps = (S32) llround(LLTrace::get_frame_recording().getPeriodMedianPerSec(LLStatViewer::FPS, 50)); + std::string fpsStr = std::to_string(fps); + mTextFps->setText(fpsStr); + } + // update clock every 10 seconds if(mClockUpdateTimer.getElapsedTimeF32() > 10.f) { diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h index fb923d3d09..da3c4a71f1 100644 --- a/indra/newview/llstatusbar.h +++ b/indra/newview/llstatusbar.h @@ -121,6 +121,7 @@ private: private: LLTextBox *mTextTime; + LLTextBox *mTextFps; LLStatGraph *mSGBandwidth; LLStatGraph *mSGPacketLoss; @@ -131,6 +132,7 @@ private: LLTextBox *mBoxBalance; LLButton *mMediaToggle; LLFrameTimer mClockUpdateTimer; + LLFrameTimer *mFpsUpdateTimer; S32 mBalance; S32 mHealth; diff --git a/indra/newview/skins/default/colors.xml b/indra/newview/skins/default/colors.xml index 64c61ff278..3968f9809f 100644 --- a/indra/newview/skins/default/colors.xml +++ b/indra/newview/skins/default/colors.xml @@ -382,6 +382,9 @@ + diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml index 4501e0df3a..dbc181855f 100644 --- a/indra/newview/skins/default/xui/en/panel_status_bar.xml +++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml @@ -185,4 +185,20 @@ top="2" name="volume_btn" width="16" /> + + 60 + -- cgit v1.2.3