aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-06-10 09:26:52 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-06-11 22:23:50 +0200
commit132e2fb2bf28c6aa3c1598deecf4d723f83396ec (patch)
tree805c55e6e49b2b05500b5ecf1f563fdf15e068be /tests/auto/quick
parent2cb24f7054e1105be0dcb1a4d61a5b52d62d1a55 (diff)
Make openglContext getter in QQuickWindow private
Fix up the scenegraph and qquickwindow autotests as well. (direct OpenGL specifics are now completely removed from both, i.e. the remaning OpenGL specific tests are now run (and not skipped) with OpenGL-on-RHI) [ChangeLog][Qt Quick][QQuickWindow] openglContext() has been removed from QQuickWindow. Use QSGRendererInterface to query the QOpenGLContext. Change-Id: If5c9802b71ac5f9cffc695827e286eb2a2d03580 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp17
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp14
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp31
3 files changed, 19 insertions, 43 deletions
diff --git a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp
index aff081c4a8..09c423890b 100644
--- a/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp
+++ b/tests/auto/quick/qquickgraphicsinfo/tst_qquickgraphicsinfo.cpp
@@ -35,11 +35,6 @@
#include "../../shared/util.h"
-#if QT_CONFIG(opengl)
-#include <qopenglcontext.h>
-#include <QtGui/qsurfaceformat.h>
-#endif
-
class tst_QQuickGraphicsInfo : public QQmlDataTest
{
Q_OBJECT
@@ -66,18 +61,6 @@ void tst_QQuickGraphicsInfo::testProperties()
const int expectedAPI = rif ? rif->graphicsApi() : QSGRendererInterface::Unknown;
QCOMPARE(obj->property("api").toInt(), expectedAPI);
-
-#if QT_CONFIG(opengl)
- if (expectedAPI == QSGRendererInterface::OpenGL) {
- QCOMPARE(obj->property("shaderType").toInt(), int(QSGRendererInterface::GLSL));
- QVERIFY(view.openglContext());
- QSurfaceFormat format = view.openglContext()->format();
- QCOMPARE(obj->property("majorVersion").toInt(), format.majorVersion());
- QCOMPARE(obj->property("minorVersion").toInt(), format.minorVersion());
- QCOMPARE(obj->property("profile").toInt(), static_cast<int>(format.profile()));
- QCOMPARE(obj->property("renderableType").toInt(), static_cast<int>(format.renderableType()));
- }
-#endif
}
QTEST_MAIN(tst_QQuickGraphicsInfo)
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index cd551c1837..871f80b027 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -2409,10 +2409,11 @@ void tst_qquickwindow::defaultSurfaceFormat()
// Depth and stencil should be >= what has been requested. For real. But use
// the context since the window's surface format is only partially updated
// on most platforms.
- const QOpenGLContext *openglContext = nullptr;
- QTRY_VERIFY((openglContext = window.openglContext()) != nullptr);
- QVERIFY(openglContext->format().depthBufferSize() >= 16);
- QVERIFY(openglContext->format().stencilBufferSize() >= 8);
+ const QOpenGLContext *ctx = nullptr;
+ QTRY_VERIFY((ctx = static_cast<QOpenGLContext *>(window.rendererInterface()->getResource(
+ &window, QSGRendererInterface::OpenGLContextResource))) != nullptr);
+ QVERIFY(ctx->format().depthBufferSize() >= 16);
+ QVERIFY(ctx->format().stencilBufferSize() >= 8);
#endif
QSurfaceFormat::setDefaultFormat(savedDefaultFormat);
}
@@ -2539,7 +2540,10 @@ void tst_qquickwindow::testRenderJob()
// Do a synchronized GL job.
GLubyte readPixel[4] = {0, 0, 0, 0};
GlRenderJob *glJob = new GlRenderJob(readPixel);
- if (window.openglContext()->thread() != QThread::currentThread()) {
+ QOpenGLContext *ctx = static_cast<QOpenGLContext *>(window.rendererInterface()->getResource(
+ &window, QSGRendererInterface::OpenGLContextResource));
+ QVERIFY(ctx);
+ if (ctx->thread() != QThread::currentThread()) {
QMutex mutex;
QWaitCondition condition;
glJob->mutex = &mutex;
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index 34e2630019..8e79f89dc6 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -118,7 +118,6 @@ private slots:
private:
QQuickView *createView(const QString &file, QWindow *parent = nullptr, int x = -1, int y = -1, int w = -1, int h = -1);
- bool isRunningOnOpenGLDirectly();
bool isRunningOnRhi();
};
@@ -411,8 +410,8 @@ void tst_SceneGraph::render_data()
void tst_SceneGraph::render()
{
- if (!isRunningOnOpenGLDirectly() && !isRunningOnRhi())
- QSKIP("Skipping complex rendering tests due to not running with OpenGL or QRhi");
+ if (!isRunningOnRhi())
+ QSKIP("Skipping complex rendering tests due to not running with QRhi");
QFETCH(QString, file);
QFETCH(QList<Sample>, baseStage);
@@ -462,8 +461,8 @@ void tst_SceneGraph::render()
// current on the other window.
void tst_SceneGraph::hideWithOtherContext()
{
- if (!isRunningOnOpenGLDirectly())
- QSKIP("Skipping OpenGL context test due to not running with OpenGL");
+ if (!isRunningOnRhi())
+ QSKIP("Skipping OpenGL context test due to not running with QRhi");
QWindow window;
window.setSurfaceType(QWindow::OpenGLSurface);
@@ -480,7 +479,12 @@ void tst_SceneGraph::hideWithOtherContext()
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
- renderingOnMainThread = view.openglContext()->thread() == QGuiApplication::instance()->thread();
+ if (view.rendererInterface()->graphicsApi() != QSGRendererInterface::OpenGLRhi)
+ QSKIP("Skipping OpenGL context test due to not using OpenGL");
+
+ QOpenGLContext *ctx = static_cast<QOpenGLContext *>(view.rendererInterface()->getResource(
+ &view, QSGRendererInterface::OpenGLContextResource));
+ renderingOnMainThread = ctx->thread() == QGuiApplication::instance()->thread();
// Make the local context current on the local window...
context.makeCurrent(&window);
@@ -526,21 +530,6 @@ void tst_SceneGraph::createTextureFromImage()
QCOMPARE(texture->hasAlphaChannel(), expectedAlpha);
}
-bool tst_SceneGraph::isRunningOnOpenGLDirectly()
-{
- static bool retval = false;
- static bool decided = false;
- if (!decided) {
- decided = true;
- QQuickView dummy;
- dummy.show();
- if (QTest::qWaitForWindowExposed(&dummy))
- retval = dummy.rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL;
- dummy.hide();
- }
- return retval;
-}
-
bool tst_SceneGraph::isRunningOnRhi()
{
static bool retval = false;