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()),
_lastSendDownstreamAudioStats(usecTimestampNow()),
_isVSyncOn(true),
_isThrottleFPSEnabled(true),
_aboutToQuit(false),
_notifiedPacketVersionMismatchThisDomain(false),
_domainConnectionRefusals(QList<QString>()),
@ -4612,6 +4613,10 @@ void Application::setVSyncEnabled() {
#endif
}
void Application::setThrottleFPSEnabled() {
_isThrottleFPSEnabled = Menu::getInstance()->isOptionChecked(MenuOption::ThrottleFPSIfNotFocus);
}
bool Application::isVSyncOn() const {
#if defined(Q_OS_WIN)
if (wglewGetExtension("WGL_EXT_swap_control")) {

View file

@ -421,6 +421,9 @@ public slots:
void domainSettingsReceived(const QJsonObject& domainSettingsObject);
void setVSyncEnabled();
void setThrottleFPSEnabled();
bool isThrottleFPSEnabled() { return _isThrottleFPSEnabled; }
void resetSensors();
void setActiveFaceTracker();
@ -637,6 +640,7 @@ private:
quint64 _lastSendDownstreamAudioStats;
bool _isVSyncOn;
bool _isThrottleFPSEnabled;
bool _aboutToQuit;

View file

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

View file

@ -373,6 +373,8 @@ Menu::Menu() {
addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderTargetFramerateVSyncOn, 0, true,
qApp, SLOT(setVSyncEnabled()));
#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 TestPing = "Test Ping";
const QString ThirdPerson = "Third Person";
const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus";
const QString ToolWindow = "Tool Window";
const QString TransmitterDrive = "Transmitter Drive";
const QString TurnWithHead = "Turn using Head";