remove vsync and framerate menus from 2d display plugin

This commit is contained in:
Brad Hefta-Gaub 2016-01-08 13:12:43 -08:00
parent e70be2d8fe
commit 86691d5d0e

View file

@ -18,13 +18,6 @@
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("2D Display");
static const QString FULLSCREEN = "Fullscreen";
static const QString FRAMERATE = DisplayPlugin::MENU_PATH() + ">Framerate";
static const QString FRAMERATE_UNLIMITED = "Unlimited";
static const QString FRAMERATE_60 = "60";
static const QString FRAMERATE_50 = "50";
static const QString FRAMERATE_40 = "40";
static const QString FRAMERATE_30 = "30";
static const QString VSYNC_ON = "V-Sync On";
const QString& Basic2DWindowOpenGLDisplayPlugin::getName() const {
return NAME;
@ -42,38 +35,12 @@ void Basic2DWindowOpenGLDisplayPlugin::activate() {
_container->unsetFullscreen();
}
}, true, false);
_container->addMenu(FRAMERATE);
_framerateActions.push_back(
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_UNLIMITED,
[this](bool) { updateFramerate(); }, true, true, FRAMERATE));
_framerateActions.push_back(
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_60,
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
_framerateActions.push_back(
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_50,
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
_framerateActions.push_back(
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_40,
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
_framerateActions.push_back(
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, FRAMERATE, FRAMERATE_30,
[this](bool) { updateFramerate(); }, true, false, FRAMERATE));
// Vsync detection happens in the parent class activate, so we need to check after that
if (_vsyncSupported) {
_vsyncAction = _container->addMenuItem(PluginType::DISPLAY_PLUGIN, MENU_PATH(), VSYNC_ON, [this](bool) {}, true, true);
} else {
_vsyncAction = nullptr;
}
updateFramerate();
}
void Basic2DWindowOpenGLDisplayPlugin::submitSceneTexture(uint32_t frameIndex, uint32_t sceneTexture, const glm::uvec2& sceneSize) {
if (_vsyncAction) {
_wantVsync = _vsyncAction->isChecked();
}
_wantVsync = true; // always
WindowOpenGLDisplayPlugin::submitSceneTexture(frameIndex, sceneTexture, sceneSize);
}
@ -87,9 +54,7 @@ const uint32_t THROTTLED_FRAMERATE = 15;
int Basic2DWindowOpenGLDisplayPlugin::getDesiredInterval() const {
static const int ULIMIITED_PAINT_TIMER_DELAY_MS = 1;
int result = ULIMIITED_PAINT_TIMER_DELAY_MS;
if (0 != _framerateTarget) {
result = MSECS_PER_SECOND / _framerateTarget;
} else if (_isThrottled) {
if (_isThrottled) {
// This test wouldn't be necessary if we could depend on updateFramerate setting _framerateTarget.
// Alas, that gets complicated: isThrottled() is const and other stuff depends on it.
result = MSECS_PER_SECOND / THROTTLED_FRAMERATE;
@ -112,30 +77,6 @@ bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
}
void Basic2DWindowOpenGLDisplayPlugin::updateFramerate() {
QAction* checkedFramerate{ nullptr };
foreach(auto action, _framerateActions) {
if (action->isChecked()) {
checkedFramerate = action;
break;
}
}
_framerateTarget = 0;
if (checkedFramerate) {
QString actionText = checkedFramerate->text();
if (FRAMERATE_60 == actionText) {
_framerateTarget = 60;
} else if (FRAMERATE_50 == actionText) {
_framerateTarget = 50;
} else if (FRAMERATE_40 == actionText) {
_framerateTarget = 40;
} else if (FRAMERATE_30 == actionText) {
_framerateTarget = 30;
}
} else if (_isThrottled) {
_framerateTarget = THROTTLED_FRAMERATE;
}
int newInterval = getDesiredInterval();
_timer.start(newInterval);
}