mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 10:36:06 +00:00
added windows specific timer class
This commit is contained in:
parent
20c0960cc6
commit
f5dd2e83a9
|
@ -1,42 +1,113 @@
|
|||
#include "Timer.h"
|
||||
|
||||
#ifdef _WIN64
|
||||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
Lib::Timer::Timer()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
LARGE_INTEGER f;
|
||||
QueryPerformanceFrequency(&f);
|
||||
m_Frequency = f.QuadPart;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Lib::Timer::Start()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
m_StartTime = c.QuadPart;
|
||||
m_is_timer_paused = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Lib::Timer::Pause()
|
||||
{
|
||||
#ifdef _WIN64
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
m_PauseTime = c.QuadPart;
|
||||
#endif
|
||||
m_is_timer_paused = true;
|
||||
}
|
||||
|
||||
void Lib::Timer::Resume()
|
||||
{
|
||||
u64 current_time = 0;
|
||||
|
||||
#ifdef _WIN64
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
current_time = c.QuadPart;
|
||||
#endif
|
||||
|
||||
m_StartTime += current_time - m_PauseTime;
|
||||
m_is_timer_paused = false;
|
||||
}
|
||||
|
||||
bool Lib::Timer::IsPaused() const
|
||||
{
|
||||
return false;
|
||||
return m_is_timer_paused;
|
||||
}
|
||||
|
||||
double Lib::Timer::GetTimeMsec() const
|
||||
{
|
||||
return 0.0;
|
||||
if (m_is_timer_paused)
|
||||
{
|
||||
return 1000.0 * (static_cast<double>(m_PauseTime - m_StartTime)) / static_cast<double>(m_Frequency);
|
||||
}
|
||||
|
||||
u64 current_time = 0;
|
||||
|
||||
#ifdef _WIN64
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
current_time = c.QuadPart;
|
||||
#endif
|
||||
|
||||
return 1000.0 * (static_cast<double>(current_time - m_StartTime)) / static_cast<double>(m_Frequency);
|
||||
}
|
||||
|
||||
double Lib::Timer::GetTimeSec() const
|
||||
{
|
||||
return 0.0;
|
||||
if (m_is_timer_paused)
|
||||
{
|
||||
return (static_cast<double>(m_PauseTime - m_StartTime)) / static_cast<double>(m_Frequency);
|
||||
}
|
||||
|
||||
u64 current_time = 0;
|
||||
|
||||
#ifdef _WIN64
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
current_time = c.QuadPart;
|
||||
#endif
|
||||
|
||||
return (static_cast<double>(current_time - m_StartTime)) / static_cast<double>(m_Frequency);
|
||||
}
|
||||
|
||||
u64 Lib::Timer::GetTicks() const
|
||||
{
|
||||
return u64();
|
||||
if (m_is_timer_paused)
|
||||
{
|
||||
return (m_PauseTime - m_StartTime);
|
||||
}
|
||||
|
||||
u64 current_time = 0;
|
||||
|
||||
#ifdef _WIN64
|
||||
LARGE_INTEGER c;
|
||||
QueryPerformanceCounter(&c);
|
||||
current_time = c.QuadPart;
|
||||
#endif
|
||||
|
||||
return (current_time - m_StartTime);
|
||||
}
|
||||
|
||||
u64 Lib::Timer::GetFrequency() const
|
||||
{
|
||||
return u64();
|
||||
return m_Frequency;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue