Add menu item, Developer > Render > Throttle FPS If Not Focus

This commit is contained in:
David Rowe 2015-07-17 16:30:01 -07:00
parent 084a098420
commit d0489bf2a0
5 changed files with 18 additions and 3 deletions

View file

@ -338,6 +338,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_lastNackTime(usecTimestampNow()), _lastNackTime(usecTimestampNow()),
_lastSendDownstreamAudioStats(usecTimestampNow()), _lastSendDownstreamAudioStats(usecTimestampNow()),
_isVSyncOn(true), _isVSyncOn(true),
_isThrottleFPSEnabled(true),
_aboutToQuit(false), _aboutToQuit(false),
_notifiedPacketVersionMismatchThisDomain(false), _notifiedPacketVersionMismatchThisDomain(false),
_domainConnectionRefusals(QList<QString>()), _domainConnectionRefusals(QList<QString>()),
@ -4612,6 +4613,10 @@ void Application::setVSyncEnabled() {
#endif #endif
} }
void Application::setThrottleFPSEnabled() {
_isThrottleFPSEnabled = Menu::getInstance()->isOptionChecked(MenuOption::ThrottleFPSIfNotFocus);
}
bool Application::isVSyncOn() const { bool Application::isVSyncOn() const {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
if (wglewGetExtension("WGL_EXT_swap_control")) { if (wglewGetExtension("WGL_EXT_swap_control")) {

View file

@ -422,6 +422,9 @@ public slots:
void setVSyncEnabled(); void setVSyncEnabled();
void setThrottleFPSEnabled();
bool isThrottleFPSEnabled() { return _isThrottleFPSEnabled; }
void resetSensors(); void resetSensors();
void setActiveFaceTracker(); void setActiveFaceTracker();
void toggleFaceTrackerMute(); void toggleFaceTrackerMute();
@ -637,6 +640,7 @@ private:
quint64 _lastSendDownstreamAudioStats; quint64 _lastSendDownstreamAudioStats;
bool _isVSyncOn; bool _isVSyncOn;
bool _isThrottleFPSEnabled;
bool _aboutToQuit; bool _aboutToQuit;

View file

@ -35,7 +35,8 @@ void GLCanvas::stopFrameTimer() {
} }
bool GLCanvas::isThrottleRendering() const { bool GLCanvas::isThrottleRendering() const {
return _throttleRendering || Application::getInstance()->getWindow()->isMinimized(); return (_throttleRendering
|| (Application::getInstance()->getWindow()->isMinimized() && Application::getInstance()->isThrottleFPSEnabled()));
} }
int GLCanvas::getDeviceWidth() const { int GLCanvas::getDeviceWidth() const {
@ -59,7 +60,8 @@ void GLCanvas::initializeGL() {
void GLCanvas::paintGL() { void GLCanvas::paintGL() {
PROFILE_RANGE(__FUNCTION__); PROFILE_RANGE(__FUNCTION__);
if (!_throttleRendering && !Application::getInstance()->getWindow()->isMinimized()) { if (!_throttleRendering
&& (!Application::getInstance()->getWindow()->isMinimized()) || !Application::getInstance()->isThrottleFPSEnabled()) {
Application::getInstance()->paintGL(); Application::getInstance()->paintGL();
} }
} }
@ -85,7 +87,8 @@ void GLCanvas::activeChanged(Qt::ApplicationState state) {
default: default:
// Otherwise, throttle. // Otherwise, throttle.
if (!_throttleRendering && !Application::getInstance()->isAboutToQuit()) { if (!_throttleRendering && !Application::getInstance()->isAboutToQuit()
&& Application::getInstance()->isThrottleFPSEnabled()) {
_frameTimer.start(_idleRenderInterval); _frameTimer.start(_idleRenderInterval);
_throttleRendering = true; _throttleRendering = true;
} }

View file

@ -373,6 +373,8 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true, addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true,
qApp, SLOT(setVSyncEnabled())); qApp, SLOT(setVSyncEnabled()));
#endif #endif
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ThrottleFPSIfNotFocus, 0, true,
qApp, SLOT(setThrottleFPSEnabled()));
} }

View file

@ -280,6 +280,7 @@ namespace MenuOption {
const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
const QString TestPing = "Test Ping"; const QString TestPing = "Test Ping";
const QString ThirdPerson = "Third Person"; const QString ThirdPerson = "Third Person";
const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus";
const QString ToolWindow = "Tool Window"; const QString ToolWindow = "Tool Window";
const QString TransmitterDrive = "Transmitter Drive"; const QString TransmitterDrive = "Transmitter Drive";
const QString TurnWithHead = "Turn using Head"; const QString TurnWithHead = "Turn using Head";