summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-02-05 12:17:17 +0100
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2020-02-18 12:51:13 +0100
commit30034a140ca8aefa1986c9964ae1f30dcfef886e (patch)
tree797fbce757e150d48d00adbc0c1c0b85f7ec5bf1
parentb2606eed8fa46c3f81bb9b03ca10409a00ed134f (diff)
Remove usage of QGL* APIs
QOpenGL API should be used instead. Task-number: QTBUG-74409 Fixes: QTBUG-81902 Change-Id: I80d09cba79248451cf211eabd87651301ae18b63 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp4
-rw-r--r--src/multimediawidgets/qgraphicsvideoitem.cpp4
-rw-r--r--src/multimediawidgets/qpaintervideosurface.cpp90
-rw-r--r--src/multimediawidgets/qpaintervideosurface_p.h13
-rw-r--r--src/multimediawidgets/qvideowidget.cpp3
-rw-r--r--src/multimediawidgets/qvideowidget_p.h2
-rw-r--r--tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp105
7 files changed, 90 insertions, 131 deletions
diff --git a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
index 1fdd1c7f7..2a9900c2b 100644
--- a/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
+++ b/examples/multimediawidgets/customvideosurface/customvideoitem/videoplayer.cpp
@@ -55,7 +55,7 @@
#include <QVideoSurfaceFormat>
#if !defined(QT_NO_OPENGL)
-# include <QGLWidget>
+# include <QOpenGLWidget>
#endif
VideoPlayer::VideoPlayer(QWidget *parent)
@@ -71,7 +71,7 @@ VideoPlayer::VideoPlayer(QWidget *parent)
QGraphicsView *graphicsView = new QGraphicsView(scene);
#if !defined(QT_NO_OPENGL)
- graphicsView->setViewport(new QGLWidget);
+ graphicsView->setViewport(new QOpenGLWidget);
#endif
scene->addItem(videoItem);
diff --git a/src/multimediawidgets/qgraphicsvideoitem.cpp b/src/multimediawidgets/qgraphicsvideoitem.cpp
index fae1f9048..7c0521471 100644
--- a/src/multimediawidgets/qgraphicsvideoitem.cpp
+++ b/src/multimediawidgets/qgraphicsvideoitem.cpp
@@ -49,7 +49,7 @@
#include <QtCore/qpointer.h>
#if QT_CONFIG(opengl)
-#include <QtOpenGL/qgl.h>
+#include <QOpenGLContext>
#endif
QT_BEGIN_NAMESPACE
@@ -395,7 +395,7 @@ void QGraphicsVideoItem::paint(
if (painter->paintEngine()->type() == QPaintEngine::OpenGL
|| painter->paintEngine()->type() == QPaintEngine::OpenGL2)
{
- d->surface->setGLContext(const_cast<QGLContext *>(QGLContext::currentContext()));
+ d->surface->updateGLContext();
if (d->surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) {
d->surface->setShaderType(QPainterVideoSurface::GlslShader);
} else {
diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp
index 1c8e2dd63..5fe76d869 100644
--- a/src/multimediawidgets/qpaintervideosurface.cpp
+++ b/src/multimediawidgets/qpaintervideosurface.cpp
@@ -47,9 +47,9 @@
#include <private/qmediaopenglhelper_p.h>
#if QT_CONFIG(opengl)
-#include <qglshaderprogram.h>
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLFunctions>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+#include <QOpenGLShaderProgram>
#include <QtGui/QWindow>
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
@@ -57,15 +57,6 @@
#ifndef GL_RGB8
#define GL_RGB8 0x8051
#endif
-
-static void makeCurrent(QGLContext *context)
-{
- context->makeCurrent();
-
- auto handle = context->contextHandle();
- if (handle && QOpenGLContext::currentContext() != handle)
- handle->makeCurrent(handle->surface());
-}
#endif
#include <QtDebug>
@@ -264,7 +255,7 @@ void QVideoSurfaceGenericPainter::updateColors(int, int, int, int)
class QVideoSurfaceGLPainter : public QVideoSurfacePainter, protected QOpenGLFunctions
{
public:
- QVideoSurfaceGLPainter(QGLContext *context);
+ QVideoSurfaceGLPainter(QOpenGLContext *context);
~QVideoSurfaceGLPainter();
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType) const override;
@@ -292,17 +283,12 @@ protected:
|| format.pixelFormat() == QVideoFrame::Format_ARGB32);
}
-#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
- typedef void (APIENTRY *_glActiveTexture) (GLenum);
- _glActiveTexture glActiveTexture;
-#endif
-
QList<QVideoFrame::PixelFormat> m_imagePixelFormats;
QList<QVideoFrame::PixelFormat> m_glPixelFormats;
QMatrix4x4 m_colorMatrix;
QVideoFrame m_frame;
- QGLContext *m_context;
+ QOpenGLContext *m_context;
QAbstractVideoBuffer::HandleType m_handleType;
QVideoSurfaceFormat::Direction m_scanLineDirection;
bool m_mirrored;
@@ -320,7 +306,7 @@ protected:
bool m_yuv;
};
-QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context)
+QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QOpenGLContext *context)
: m_context(context)
, m_handleType(QAbstractVideoBuffer::NoHandle)
, m_scanLineDirection(QVideoSurfaceFormat::TopToBottom)
@@ -332,10 +318,6 @@ QVideoSurfaceGLPainter::QVideoSurfaceGLPainter(QGLContext *context)
, m_textureCount(0)
, m_yuv(false)
{
-#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
- glActiveTexture = (_glActiveTexture)m_context->getProcAddress(QLatin1String("glActiveTexture"));
-#endif
-
memset(m_textureIds, 0, sizeof(m_textureIds));
memset(m_textureWidths, 0, sizeof(m_textureWidths));
memset(m_textureHeights, 0, sizeof(m_textureHeights));
@@ -404,8 +386,6 @@ QAbstractVideoSurface::Error QVideoSurfaceGLPainter::setCurrentFrame(const QVide
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
} else if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) {
- makeCurrent(m_context);
-
for (int i = 0; i < m_textureCount; ++i) {
glBindTexture(GL_TEXTURE_2D, m_textureIds[i]);
glTexImage2D(
@@ -680,7 +660,7 @@ static const char *qt_arbfp_ayuvShaderProgram =
class QVideoSurfaceArbFpPainter : public QVideoSurfaceGLPainter
{
public:
- QVideoSurfaceArbFpPainter(QGLContext *context);
+ QVideoSurfaceArbFpPainter(QOpenGLContext *context);
QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) override;
void stop() override;
@@ -707,20 +687,20 @@ private:
QSize m_frameSize;
};
-QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context)
+QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QOpenGLContext *context)
: QVideoSurfaceGLPainter(context)
, m_programId(0)
{
glProgramStringARB = (_glProgramStringARB) m_context->getProcAddress(
- QLatin1String("glProgramStringARB"));
+ QByteArray("glProgramStringARB"));
glBindProgramARB = (_glBindProgramARB) m_context->getProcAddress(
- QLatin1String("glBindProgramARB"));
+ QByteArray("glBindProgramARB"));
glDeleteProgramsARB = (_glDeleteProgramsARB) m_context->getProcAddress(
- QLatin1String("glDeleteProgramsARB"));
+ QByteArray("glDeleteProgramsARB"));
glGenProgramsARB = (_glGenProgramsARB) m_context->getProcAddress(
- QLatin1String("glGenProgramsARB"));
+ QByteArray("glGenProgramsARB"));
glProgramLocalParameter4fARB = (_glProgramLocalParameter4fARB) m_context->getProcAddress(
- QLatin1String("glProgramLocalParameter4fARB"));
+ QByteArray("glProgramLocalParameter4fARB"));
m_imagePixelFormats
<< QVideoFrame::Format_RGB32
@@ -746,8 +726,6 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac
QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError;
- makeCurrent(m_context);
-
const char *program = 0;
if (format.handleType() == QAbstractVideoBuffer::NoHandle) {
@@ -871,8 +849,6 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac
void QVideoSurfaceArbFpPainter::stop()
{
if (m_context) {
- makeCurrent(m_context);
-
if (m_handleType != QAbstractVideoBuffer::GLTextureHandle)
glDeleteTextures(m_textureCount, m_textureIds);
glDeleteProgramsARB(1, &m_programId);
@@ -1079,7 +1055,7 @@ static const char *qt_glsl_ayuvShaderProgram =
class QVideoSurfaceGlslPainter : public QVideoSurfaceGLPainter
{
public:
- QVideoSurfaceGlslPainter(QGLContext *context);
+ QVideoSurfaceGlslPainter(QOpenGLContext *context);
QAbstractVideoSurface::Error start(const QVideoSurfaceFormat &format) override;
void stop() override;
@@ -1088,11 +1064,11 @@ public:
const QRectF &target, QPainter *painter, const QRectF &source) override;
private:
- QGLShaderProgram m_program;
+ QOpenGLShaderProgram m_program;
QSize m_frameSize;
};
-QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context)
+QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QOpenGLContext *context)
: QVideoSurfaceGLPainter(context)
, m_program(context)
{
@@ -1100,7 +1076,7 @@ QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context)
<< QVideoFrame::Format_RGB32
<< QVideoFrame::Format_BGR32
<< QVideoFrame::Format_ARGB32;
- if (!context->contextHandle()->isOpenGLES()) {
+ if (!context->isOpenGLES()) {
m_imagePixelFormats
<< QVideoFrame::Format_RGB24
<< QVideoFrame::Format_BGR24;
@@ -1124,8 +1100,6 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface
QAbstractVideoSurface::Error error = QAbstractVideoSurface::NoError;
- makeCurrent(m_context);
-
const char *fragmentProgram = 0;
if (format.handleType() == QAbstractVideoBuffer::NoHandle) {
@@ -1143,13 +1117,13 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface
fragmentProgram = qt_glsl_argbShaderProgram;
break;
case QVideoFrame::Format_RGB24:
- if (!m_context->contextHandle()->isOpenGLES()) {
+ if (!m_context->isOpenGLES()) {
initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize());
fragmentProgram = qt_glsl_rgbShaderProgram;
}
break;
case QVideoFrame::Format_BGR24:
- if (!m_context->contextHandle()->isOpenGLES()) {
+ if (!m_context->isOpenGLES()) {
initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize());
fragmentProgram = qt_glsl_argbShaderProgram;
}
@@ -1202,11 +1176,11 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface
if (!fragmentProgram) {
error = QAbstractVideoSurface::UnsupportedFormatError;
- } else if (!m_program.addShaderFromSourceCode(QGLShader::Vertex, qt_glsl_vertexShaderProgram)) {
+ } else if (!m_program.addShaderFromSourceCode(QOpenGLShader::Vertex, qt_glsl_vertexShaderProgram)) {
qWarning("QPainterVideoSurface: Vertex shader compile error %s",
qPrintable(m_program.log()));
error = QAbstractVideoSurface::ResourceError;
- } else if (!m_program.addShaderFromSourceCode(QGLShader::Fragment, fragmentProgram)) {
+ } else if (!m_program.addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentProgram)) {
qWarning("QPainterVideoSurface: Shader compile error %s", qPrintable(m_program.log()));
error = QAbstractVideoSurface::ResourceError;
m_program.removeAllShaders();
@@ -1231,8 +1205,6 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface
void QVideoSurfaceGlslPainter::stop()
{
if (m_context) {
- makeCurrent(m_context);
-
if (m_handleType != QAbstractVideoBuffer::GLTextureHandle)
glDeleteTextures(m_textureCount, m_textureIds);
}
@@ -1611,35 +1583,33 @@ void QPainterVideoSurface::paint(QPainter *painter, const QRectF &target, const
/*!
*/
-const QGLContext *QPainterVideoSurface::glContext() const
+const QOpenGLContext *QPainterVideoSurface::glContext() const
{
return m_glContext;
}
/*!
*/
-void QPainterVideoSurface::setGLContext(QGLContext *context)
+void QPainterVideoSurface::updateGLContext()
{
- if (m_glContext == context)
+ auto oldContext = m_glContext;
+ m_glContext = QOpenGLContext::currentContext();
+ if (oldContext == m_glContext)
return;
- m_glContext = context;
-
m_shaderTypes = NoShaders;
if (m_glContext) {
//Set a dynamic property to access the OpenGL context
- this->setProperty("GLContext", QVariant::fromValue<QObject*>(m_glContext->contextHandle()));
-
- makeCurrent(m_glContext);
+ this->setProperty("GLContext", QVariant::fromValue<QObject *>(m_glContext));
const QByteArray extensions(reinterpret_cast<const char *>(
- context->contextHandle()->functions()->glGetString(GL_EXTENSIONS)));
+ m_glContext->functions()->glGetString(GL_EXTENSIONS)));
#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
if (extensions.contains("ARB_fragment_program"))
m_shaderTypes |= FragmentProgramShader;
#endif
- if (QGLShaderProgram::hasOpenGLShaderPrograms(m_glContext)
+ if (QOpenGLShaderProgram::hasOpenGLShaderPrograms(m_glContext)
#if !defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_DYNAMIC)
&& extensions.contains("ARB_shader_objects")
#endif
@@ -1742,13 +1712,11 @@ void QPainterVideoSurface::createPainter()
#if !defined(QT_OPENGL_ES) && !defined(QT_OPENGL_DYNAMIC)
case FragmentProgramShader:
Q_ASSERT(m_glContext);
- makeCurrent(m_glContext);
m_painter = new QVideoSurfaceArbFpPainter(m_glContext);
break;
#endif // !QT_OPENGL_ES && !QT_OPENGL_DYNAMIC
case GlslShader:
Q_ASSERT(m_glContext);
- makeCurrent(m_glContext);
m_painter = new QVideoSurfaceGlslPainter(m_glContext);
break;
default:
diff --git a/src/multimediawidgets/qpaintervideosurface_p.h b/src/multimediawidgets/qpaintervideosurface_p.h
index 990d20cbe..582d6944c 100644
--- a/src/multimediawidgets/qpaintervideosurface_p.h
+++ b/src/multimediawidgets/qpaintervideosurface_p.h
@@ -59,11 +59,6 @@
#include <qabstractvideosurface.h>
#include <qvideoframe.h>
-QT_BEGIN_NAMESPACE
-
-class QGLContext;
-QT_END_NAMESPACE
-
QT_USE_NAMESPACE
QT_BEGIN_NAMESPACE
@@ -90,7 +85,7 @@ public:
virtual void viewportDestroyed() {}
};
-
+class QOpenGLContext;
class Q_AUTOTEST_EXPORT QPainterVideoSurface : public QAbstractVideoSurface
{
Q_OBJECT
@@ -126,8 +121,8 @@ public:
void paint(QPainter *painter, const QRectF &target, const QRectF &source = QRectF(0, 0, 1, 1));
#if QT_CONFIG(opengl)
- const QGLContext *glContext() const;
- void setGLContext(QGLContext *context);
+ const QOpenGLContext *glContext() const;
+ void updateGLContext();
enum ShaderType
{
@@ -155,7 +150,7 @@ private:
QVideoSurfacePainter *m_painter;
#if QT_CONFIG(opengl)
- QGLContext *m_glContext;
+ QOpenGLContext *m_glContext;
ShaderTypes m_shaderTypes;
ShaderType m_shaderType;
#endif
diff --git a/src/multimediawidgets/qvideowidget.cpp b/src/multimediawidgets/qvideowidget.cpp
index 723a9bbb3..5158b2f35 100644
--- a/src/multimediawidgets/qvideowidget.cpp
+++ b/src/multimediawidgets/qvideowidget.cpp
@@ -228,7 +228,6 @@ void QRendererVideoWidgetBackend::hideEvent(QHideEvent *)
{
#if QT_CONFIG(opengl)
m_updatePaintDevice = true;
- m_surface->setGLContext(0);
#endif
}
@@ -265,7 +264,7 @@ void QRendererVideoWidgetBackend::paintEvent(QPaintEvent *event)
|| painter.paintEngine()->type() == QPaintEngine::OpenGL2)) {
m_updatePaintDevice = false;
- m_surface->setGLContext(const_cast<QGLContext *>(QGLContext::currentContext()));
+ m_surface->updateGLContext();
if (m_surface->supportedShaderTypes() & QPainterVideoSurface::GlslShader) {
m_surface->setShaderType(QPainterVideoSurface::GlslShader);
} else {
diff --git a/src/multimediawidgets/qvideowidget_p.h b/src/multimediawidgets/qvideowidget_p.h
index 1db91f3f9..a3e687488 100644
--- a/src/multimediawidgets/qvideowidget_p.h
+++ b/src/multimediawidgets/qvideowidget_p.h
@@ -55,7 +55,7 @@
#include "qvideowidget.h"
#ifndef QT_NO_OPENGL
-#include <QGLWidget>
+#include <QOpenGLWidget>
#endif
#include "qpaintervideosurface_p.h"
diff --git a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp b/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
index 6aaeab855..be5c85ab9 100644
--- a/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
+++ b/tests/auto/unit/qpaintervideosurface/tst_qpaintervideosurface.cpp
@@ -35,9 +35,9 @@
#include <qvideosurfaceformat.h>
#if QT_CONFIG(opengl)
-#include <QtOpenGL/qgl.h>
-#include <QtOpenGL/qglframebufferobject.h>
-#include <QtGui/qopenglfunctions.h>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+#include <QOpenGLWidget>
#endif
QT_USE_NAMESPACE
@@ -559,20 +559,19 @@ void tst_QPainterVideoSurface::presentOpaqueFrame()
void tst_QPainterVideoSurface::shaderType()
{
QPainterVideoSurface surface;
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support OpenGLContext");
QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders);
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.glContext(), widget.context());
{
@@ -612,12 +611,14 @@ void tst_QPainterVideoSurface::shaderType()
{
QSignalSpy spy(&surface, SIGNAL(supportedFormatsChanged()));
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.glContext(), widget.context());
QCOMPARE(spy.count(), 0);
}
- surface.setGLContext(0);
+ widget.doneCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
QCOMPARE(surface.supportedShaderTypes(), QPainterVideoSurface::NoShaders);
@@ -656,19 +657,18 @@ void tst_QPainterVideoSurface::shaderTypeStarted()
{
QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support OpenGLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");
@@ -712,7 +712,8 @@ void tst_QPainterVideoSurface::shaderTypeStarted()
QCOMPARE(surface.isActive(), true);
QCOMPARE(spy.count(), 0);
- surface.setGLContext(0);
+ widget.doneCurrent();
+ surface.updateGLContext();
QCOMPARE(surface.shaderType(), QPainterVideoSurface::NoShaders);
QCOMPARE(surface.isActive(), false);
QCOMPARE(spy.count(), 1);
@@ -904,18 +905,17 @@ void tst_QPainterVideoSurface::shaderSupportedFormat()
QFETCH(bool, supportedPixelFormat);
QFETCH(bool, supportedFormat);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
@@ -1026,18 +1026,17 @@ void tst_QPainterVideoSurface::shaderPresent()
QFETCH(int, bytesB);
QFETCH(int, bytesPerLineB);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");
@@ -1163,18 +1162,17 @@ void tst_QPainterVideoSurface::shaderPresentOpaqueFrame()
{
QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");
@@ -1217,18 +1215,17 @@ void tst_QPainterVideoSurface::shaderPresentGLFrame()
{
QFETCH(QPainterVideoSurface::ShaderType, shaderType);
- QGLWidget widget;
- if (!widget.context()
- || !widget.context()->isValid()) {
- QSKIP("Platform does not support GLContext");
- }
-
+ QOpenGLWidget widget;
widget.show();
+
QVERIFY(QTest::qWaitForWindowExposed(&widget));
- widget.makeCurrent();
+
+ if (!widget.context() || !widget.context()->isValid())
+ QSKIP("Platform does not support GLContext");
QPainterVideoSurface surface;
- surface.setGLContext(const_cast<QGLContext *>(widget.context()));
+ widget.makeCurrent();
+ surface.updateGLContext();
if (!(surface.supportedShaderTypes() & shaderType))
QSKIP("Shader type unsupported on this platform");