Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,6 @@ def sources(self, build):

"widget/wwaveformviewer.cpp",

"waveform/sharedglcontext.cpp",
"waveform/waveform.cpp",
"waveform/waveformfactory.cpp",
"waveform/waveformwidgetfactory.cpp",
Expand Down
11 changes: 1 addition & 10 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <QDesktopServices>
#include <QDesktopWidget>
#include <QFileDialog>
#include <QGLWidget>
#include <QOpenGLWidget>
#include <QUrl>
#include <QtDebug>

Expand Down Expand Up @@ -50,7 +50,6 @@
#include "sources/soundsourceproxy.h"
#include "track/track.h"
#include "waveform/waveformwidgetfactory.h"
#include "waveform/sharedglcontext.h"
#include "database/mixxxdb.h"
#include "util/debug.h"
#include "util/statsmanager.h"
Expand Down Expand Up @@ -377,14 +376,6 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
// and emit newSkinLoaded.
connectMenuBar();

// Before creating the first skin we need to create a QGLWidget so that all
// the QGLWidget's we create can use it as a shared QGLContext.
if (!CmdlineArgs::Instance().getSafeMode()) {
QGLWidget* pContextWidget = new QGLWidget(this);
pContextWidget->hide();
SharedGLContext::setWidget(pContextWidget);
}

launchProgress(63);

QWidget* oldWidget = m_pWidgetParent;
Expand Down
37 changes: 0 additions & 37 deletions src/waveform/sharedglcontext.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions src/waveform/sharedglcontext.h

This file was deleted.

21 changes: 2 additions & 19 deletions src/waveform/vsyncthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,9 @@ void VSyncThread::run() {


// static
void VSyncThread::swapGl(QGLWidget* glw, int index) {
void VSyncThread::swapGl(QOpenGLWidget* glw, int index) {
Q_UNUSED(index);
// No need for glw->makeCurrent() here.
//qDebug() << "swapGl" << m_timer.elapsed().formatNanosWithUnit();
#if defined(__APPLE__)
glw->swapBuffers();
#elif defined(__WINDOWS__)
glw->swapBuffers();
#else
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifdef QT_OPENGL_ES_2
glw->swapBuffers();
#else
const QX11Info *xinfo = qt_x11Info(glw);
glXSwapBuffers(xinfo->display(), glw->winId());
#endif
#else
glw->swapBuffers();
#endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#endif
// TODO: glw->swapBuffers() used to be called here, but it is not offered by the QOpenGLWidget
}

int VSyncThread::elapsed() {
Expand Down
10 changes: 2 additions & 8 deletions src/waveform/vsyncthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QThread>
#include <QSemaphore>
#include <QPair>
#include <QGLWidget>
#include <QOpenGLWidget>

#if defined(__APPLE__)

Expand Down Expand Up @@ -42,41 +42,35 @@ class VSyncThread : public QThread {
ST_COUNT // Dummy Type at last, counting possible types
};

static void swapGl(QGLWidget* glw, int index);
static void swapGl(QOpenGLWidget* glw, int index);

VSyncThread(QObject* pParent, GuiTick* pGuiTick);
~VSyncThread();

void run();
void stop();

bool waitForVideoSync(QGLWidget* glw);
int elapsed();
int toNextSyncMicros();
void setSyncIntervalTimeMicros(int usSyncTimer);
void setVSyncType(int mode);
int droppedFrames();
void setSwapWait(int sw);
int fromTimerToNextSyncMicros(const PerformanceTimer& timer);
void vsyncSlotFinished();
void getAvailableVSyncTypes(QList<QPair<int, QString > >* list);
void setupSync(QGLWidget* glw, int index);
void waitUntilSwap(QGLWidget* glw);

signals:
void vsyncRender();
void vsyncSwap();

private:
bool m_bDoRendering;
//QGLWidget *m_glw;
Comment thread
Be-ing marked this conversation as resolved.

#if defined(__APPLE__)

#elif defined(__WINDOWS__)

#else
void initGlxext(QGLWidget* glw);
//bool glXExtensionSupported(Display *dpy, int screen, const char *extension);

/* Currently unused, but probably part of later a hardware sync solution
Expand Down
11 changes: 6 additions & 5 deletions src/waveform/waveformwidgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include <QWidget>
#include <QtDebug>
#include <QGLFormat>
#include <QGLShaderProgram>
#include <QOpenGLShaderProgram>
#include <QGuiApplication>
#include <QWindow>
#include <QOpenGLContext>

#include "waveform/waveformwidgetfactory.h"

Expand Down Expand Up @@ -170,12 +171,12 @@ WaveformWidgetFactory::WaveformWidgetFactory() :

m_openGLAvailable = true;

QGLWidget* glWidget = new QGLWidget(); // create paint device
QOpenGLWidget* glWidget = new QOpenGLWidget(); // create paint device
// QGLShaderProgram::hasOpenGLShaderPrograms(); valgind error
// Without a makeCurrent, hasOpenGLShaderPrograms returns false on Qt 5.
glWidget->context()->makeCurrent();
glWidget->makeCurrent();
m_openGLShaderAvailable =
QGLShaderProgram::hasOpenGLShaderPrograms(glWidget->context());
QOpenGLShaderProgram::hasOpenGLShaderPrograms(glWidget->context());
delete glWidget;
}

Expand Down Expand Up @@ -565,7 +566,7 @@ void WaveformWidgetFactory::swap() {
for (int i = 0; i < m_waveformWidgetHolders.size(); i++) {
WaveformWidgetAbstract* pWaveformWidget = m_waveformWidgetHolders[i].m_waveformWidget;
if (pWaveformWidget->getWidth() > 0) {
QGLWidget* glw = dynamic_cast<QGLWidget*>(pWaveformWidget->getWidget());
QOpenGLWidget* glw = dynamic_cast<QOpenGLWidget*>(pWaveformWidget->getWidget());
// Don't swap invalid / invisible widgets or widgets with an
// unexposed window. Prevents continuous log spew of
// "QOpenGLContext::swapBuffers() called with non-exposed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing VSyncThread::swapGl(glw, i;) below with glw->context()->swapBuffers(window); does what was done before by VSyncThread::swapGl, but it does not solve the jerky waveform scrolling. (GitHub won't let me comment directly on that line because you have not changed it.)

Expand Down
16 changes: 6 additions & 10 deletions src/waveform/widgets/glrgbwaveformwidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "glrgbwaveformwidget.h"

#include "waveform/sharedglcontext.h"
#include "waveform/renderers/waveformwidgetrenderer.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/glwaveformrendererrgb.h"
Expand All @@ -12,8 +11,10 @@

#include "util/performancetimer.h"

#include <QOpenGLContext>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We conventionally put Qt includes above Mixxx includes.


GLRGBWaveformWidget::GLRGBWaveformWidget(const char* group, QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
: QOpenGLWidget(parent),
WaveformWidgetAbstract(group) {

addRenderer<WaveformRenderBackground>();
Expand All @@ -27,12 +28,7 @@ GLRGBWaveformWidget::GLRGBWaveformWidget(const char* group, QWidget* parent)
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_OpaquePaintEvent);

setAutoBufferSwap(false);

qDebug() << "Created QGLWidget. Context"
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();
if (QGLContext::currentContext() != context()) {
if (QOpenGLContext::currentContext() != context()) {
makeCurrent();
}
m_initSuccess = init();
Expand All @@ -43,7 +39,7 @@ GLRGBWaveformWidget::~GLRGBWaveformWidget() {
}

void GLRGBWaveformWidget::castToQWidget() {
m_widget = static_cast<QWidget*>(static_cast<QGLWidget*>(this));
m_widget = static_cast<QWidget*>(static_cast<QOpenGLWidget*>(this));
}

void GLRGBWaveformWidget::paintEvent(QPaintEvent* event) {
Expand All @@ -55,7 +51,7 @@ mixxx::Duration GLRGBWaveformWidget::render() {
mixxx::Duration t1;
//mixxx::Duration t2, t3;
timer.start();
// QPainter makes QGLContext::currentContext() == context()
// QPainter makes QOpenGLContext::currentContext() == context()
// this may delayed until previous buffer swap finished
QPainter painter(this);
t1 = timer.restart();
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/glrgbwaveformwidget.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef GLRGBWAVEFORMWIDGET_H
#define GLRGBWAVEFORMWIDGET_H

#include <QGLWidget>
#include <QOpenGLWidget>

#include "waveformwidgetabstract.h"

class GLRGBWaveformWidget : public QGLWidget, public WaveformWidgetAbstract {
class GLRGBWaveformWidget : public QOpenGLWidget, public WaveformWidgetAbstract {
Q_OBJECT
public:
GLRGBWaveformWidget(const char* group, QWidget* parent);
Expand Down
17 changes: 6 additions & 11 deletions src/waveform/widgets/glsimplewaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <QPainter>
#include <QtDebug>
#include <QOpenGLContext>

#include "waveform/sharedglcontext.h"
#include "waveform/renderers/waveformwidgetrenderer.h"
#include "waveform/renderers/waveformrenderbackground.h"
#include "waveform/renderers/glwaveformrenderersimplesignal.h"
Expand All @@ -16,7 +16,7 @@
#include "util/performancetimer.h"

GLSimpleWaveformWidget::GLSimpleWaveformWidget(const char* group, QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
: QOpenGLWidget(parent),
WaveformWidgetAbstract(group) {
addRenderer<WaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
Expand All @@ -29,25 +29,20 @@ GLSimpleWaveformWidget::GLSimpleWaveformWidget(const char* group, QWidget* paren
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_OpaquePaintEvent);

setAutoBufferSwap(false);

qDebug() << "Created QGLWidget. Context"
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();
if (QGLContext::currentContext() != context()) {
if (QOpenGLContext::currentContext() != context()) {
makeCurrent();
}
m_initSuccess = init();
}

GLSimpleWaveformWidget::~GLSimpleWaveformWidget() {
if (QGLContext::currentContext() != context()) {
if (QOpenGLContext::currentContext() != context()) {
makeCurrent();
}
}

void GLSimpleWaveformWidget::castToQWidget() {
m_widget = static_cast<QWidget*>(static_cast<QGLWidget*>(this));
m_widget = static_cast<QWidget*>(static_cast<QOpenGLWidget*>(this));
}

void GLSimpleWaveformWidget::paintEvent(QPaintEvent* event) {
Expand All @@ -59,7 +54,7 @@ mixxx::Duration GLSimpleWaveformWidget::render() {
mixxx::Duration t1;
//mixxx::Duration t2, t3;
timer.start();
// QPainter makes QGLContext::currentContext() == context()
// QPainter makes QOpenGLContext::currentContext() == context()
// this may delayed until previous buffer swap finished
QPainter painter(this);
t1 = timer.restart();
Expand Down
4 changes: 2 additions & 2 deletions src/waveform/widgets/glsimplewaveformwidget.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef GLSIMPLEWAVEFORMWIDGET_H
#define GLSIMPLEWAVEFORMWIDGET_H

#include <QGLWidget>
#include <QOpenGLWidget>

#include "waveformwidgetabstract.h"

class GLSimpleWaveformWidget : public QGLWidget, public WaveformWidgetAbstract {
class GLSimpleWaveformWidget : public QOpenGLWidget, public WaveformWidgetAbstract {
Q_OBJECT
public:
GLSimpleWaveformWidget(const char* group, QWidget* parent);
Expand Down
Loading