Skip to content

Commit

Permalink
removed unused methods, setSwapInterval based on vsync mode
Browse files Browse the repository at this point in the history
  • Loading branch information
m0dB authored and m0dB committed Dec 30, 2023
1 parent a6e3880 commit bfbeb71
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void MixxxMainWindow::initializeQOpenGL() {
if (!CmdlineArgs::Instance().getSafeMode()) {
#endif
QOpenGLContext context;
context.setFormat(WaveformWidgetFactory::getSurfaceFormat());
context.setFormat(WaveformWidgetFactory::getSurfaceFormat(m_pCoreServices->getSettings()));
if (context.create()) {
// This widget and its QOpenGLWindow will be used to query QOpenGL
// information (version, driver, etc) in WaveformWidgetFactory.
Expand Down
24 changes: 7 additions & 17 deletions src/waveform/waveformwidgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,21 +509,6 @@ void WaveformWidgetFactory::setEndOfTrackWarningTime(int endTime) {
}
}

void WaveformWidgetFactory::setVSyncType(int type) {
if (m_config) {
m_config->set(ConfigKey("[Waveform]","VSync"), ConfigValue((int)type));
}

m_vSyncType = type;
if (m_vsyncThread) {
m_vsyncThread->setVSyncType(type);
}
}

int WaveformWidgetFactory::getVSyncType() {
return m_vSyncType;
}

bool WaveformWidgetFactory::setWidgetType(WaveformWidgetType::Type type) {
return setWidgetType(type, &m_type);
}
Expand Down Expand Up @@ -1217,7 +1202,11 @@ QString WaveformWidgetFactory::buildWidgetDisplayName() const {
}

// static
QSurfaceFormat WaveformWidgetFactory::getSurfaceFormat() {
QSurfaceFormat WaveformWidgetFactory::getSurfaceFormat(UserSettingsPointer config) {
// The first call should pass the config to set the vsync mode. Subsequent
// calls will use the value as set on the first call.
static const auto vsyncMode = config->getValue(ConfigKey("[Waveform]", "VSync"), 0);

QSurfaceFormat format;
// Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0, default is 2.0
// format.setVersion(2, 1);
Expand All @@ -1240,13 +1229,14 @@ QSurfaceFormat WaveformWidgetFactory::getSurfaceFormat() {
// On OS X, syncing to vsync has good performance FPS-wise and
// eliminates tearing. (This is an comment from pre QOpenGLWindow times)
format.setSwapInterval(1);
(void)vsyncMode;
#else
// It seems that on Windows (at least for some AMD drivers), the setting 1 is not
// not properly handled. We saw frame rates divided by exact integers, like it should
// be with values >1 (see https://github.com/mixxxdj/mixxx/issues/11617)
// Reported as https://bugreports.qt.io/browse/QTBUG-114882
// On Linux, horrible FPS were seen with "VSync off" before switching to QOpenGLWindow too
format.setSwapInterval(0);
format.setSwapInterval(vsyncMode == VSyncThread::ST_PLL ? 1 : 0);
#endif
return format;
}
4 changes: 1 addition & 3 deletions src/waveform/waveformwidgetfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class WaveformWidgetFactory : public QObject, public Singleton<WaveformWidgetFac
int findHandleIndexFromType(WaveformWidgetType::Type type);

/// Returns the desired surface format for the OpenGLWindow
static QSurfaceFormat getSurfaceFormat();
static QSurfaceFormat getSurfaceFormat(UserSettingsPointer config = nullptr);

protected:
bool setWidgetType(
Expand Down Expand Up @@ -130,8 +130,6 @@ class WaveformWidgetFactory : public QObject, public Singleton<WaveformWidgetFac
void addVuMeter(WVuMeterBase* pWidget);

void startVSync(GuiTick* pGuiTick, VisualsManager* pVisualsManager);
void setVSyncType(int vsType);
int getVSyncType();

void setPlayMarkerPosition(double position);
double getPlayMarkerPosition() const { return m_playMarkerPosition; }
Expand Down

0 comments on commit bfbeb71

Please sign in to comment.