New cpp folder structure

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-07-17 22:35:52 +03:00
committed by Konstantin Pastbin
parent c9cbb64f12
commit 76ffc99abd
2390 changed files with 345 additions and 339 deletions

View File

@@ -0,0 +1,56 @@
#pragma once
#include "base/timer.hpp"
#include <cstdint>
namespace gui
{
class ScaleFpsHelper
{
public:
uint32_t GetFps() const
{
if (m_frameTime == 0.0)
return 0;
return static_cast<uint32_t>(1.0 / m_frameTime);
}
bool IsPaused() const
{
return m_isPaused;
}
void SetFrameTime(double frameTime, bool isActiveFrame)
{
m_isPaused = !isActiveFrame;
m_framesCounter++;
m_aggregatedFrameTime += frameTime;
double constexpr kAggregationPeriod = 0.5;
if (m_isPaused || m_fpsAggregationTimer.ElapsedSeconds() >= kAggregationPeriod)
{
m_frameTime = m_aggregatedFrameTime / m_framesCounter;
m_aggregatedFrameTime = 0.0;
m_framesCounter = 0;
m_fpsAggregationTimer.Reset();
}
}
int GetScale() const { return m_scale; }
void SetScale(int scale) { m_scale = scale; }
void SetVisible(bool isVisible) { m_isVisible = isVisible; }
bool IsVisible() const { return m_isVisible; }
private:
double m_frameTime = 0.0;
int m_scale = 1;
bool m_isVisible = false;
base::Timer m_fpsAggregationTimer;
double m_aggregatedFrameTime = 0.0;
uint32_t m_framesCounter = 1;
bool m_isPaused = false;
};
} // namespace gui