mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 04:08:55 +00:00
Fix FPS counter and Game Window speed % breaking on pause/unpause
-Add pause state to FPSCounter. -Add ability to have more than one "OnStateChanged" callback in core. -Add GetActualEmulationSpeed() to Core. Returns 1 by default. It's used by my input PRs.
This commit is contained in:
parent
31780a6059
commit
818672b585
7 changed files with 125 additions and 31 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Timer.h"
|
||||
#include "Core/Core.h"
|
||||
#include "VideoCommon/FPSCounter.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
|
@ -16,6 +17,18 @@ static constexpr u64 FPS_REFRESH_INTERVAL = 250000;
|
|||
FPSCounter::FPSCounter()
|
||||
{
|
||||
m_last_time = Common::Timer::GetTimeUs();
|
||||
|
||||
m_on_state_changed_handle = Core::AddOnStateChangedCallback([this](Core::State state) {
|
||||
if (state == Core::State::Paused)
|
||||
SetPaused(true);
|
||||
else if (state == Core::State::Running)
|
||||
SetPaused(false);
|
||||
});
|
||||
}
|
||||
|
||||
FPSCounter::~FPSCounter()
|
||||
{
|
||||
Core::RemoveOnStateChangedCallback(&m_on_state_changed_handle);
|
||||
}
|
||||
|
||||
void FPSCounter::LogRenderTimeToFile(u64 val)
|
||||
|
@ -31,8 +44,9 @@ void FPSCounter::LogRenderTimeToFile(u64 val)
|
|||
|
||||
void FPSCounter::Update()
|
||||
{
|
||||
u64 time = Common::Timer::GetTimeUs();
|
||||
u64 diff = time - m_last_time;
|
||||
const u64 time = Common::Timer::GetTimeUs();
|
||||
const u64 diff = time - m_last_time;
|
||||
m_time_diff_secs = static_cast<double>(diff / 1000000.0);
|
||||
if (g_ActiveConfig.bLogRenderTimeToFile)
|
||||
LogRenderTimeToFile(diff);
|
||||
|
||||
|
@ -47,3 +61,17 @@ void FPSCounter::Update()
|
|||
m_time_since_update = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void FPSCounter::SetPaused(bool paused)
|
||||
{
|
||||
if (paused)
|
||||
{
|
||||
m_last_time_pause = Common::Timer::GetTimeUs();
|
||||
}
|
||||
else
|
||||
{
|
||||
const u64 time = Common::Timer::GetTimeUs();
|
||||
const u64 diff = time - m_last_time_pause;
|
||||
m_last_time += diff;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue