mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-08 14:09:42 +03:00
* Timer and path utils are done. * Window only implements initialize and setVisible BUG=angleproject:892 Change-Id: I3f49b68ef9ec5be324b25e211199bac2953ae11e Reviewed-on: https://chromium-review.googlesource.com/269520 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
47 lines
893 B
C++
47 lines
893 B
C++
//
|
|
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
|
|
// LinuxTimer.cpp: Implementation of a high precision timer class on Linux
|
|
|
|
#include "linux/LinuxTimer.h"
|
|
|
|
LinuxTimer::LinuxTimer()
|
|
: mRunning(false)
|
|
{
|
|
}
|
|
|
|
void LinuxTimer::start()
|
|
{
|
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &mStartTime);
|
|
mRunning = true;
|
|
}
|
|
|
|
void LinuxTimer::stop()
|
|
{
|
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &mStopTime);
|
|
mRunning = false;
|
|
}
|
|
|
|
double LinuxTimer::getElapsedTime() const
|
|
{
|
|
struct timespec endTime;
|
|
if (mRunning)
|
|
{
|
|
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &endTime);
|
|
}
|
|
else
|
|
{
|
|
endTime = mStopTime;
|
|
}
|
|
|
|
return endTime.tv_sec + (1.0 / 1000000000) * endTime.tv_nsec;
|
|
}
|
|
|
|
Timer *CreateTimer()
|
|
{
|
|
return new LinuxTimer();
|
|
}
|