diff options
author | Andy Nichols <andy.nichols@theqtcompany.com> | 2016-03-15 13:39:41 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-03-22 09:51:54 +0000 |
commit | 90d98e1330bd46b5defafd5d6b86fa8fe157b48d (patch) | |
tree | 722e2b1d371c6b58144d51b8167faa9d1c86e7f0 /src/quick/scenegraph/qsgrenderloop.cpp | |
parent | e32fb877ec0662dfda41ce490d77d8bf35a377f1 (diff) |
Enable building Qt Quick module with QT_NO_OPENGL defined
Currently the Qt Quick module depends on either the OpenGL or OpenGLES
headers being available at build time. Since we are adding support for
adaptations that do not depend on OpenGL, it should be possible to build
Qt Quick in environments that do not have OpenGL development headers.
This does present many challenges though because in some cases GL types,
and classes that require OpenGL are part of the public APIs. However
since these classes were never available when QT_NO_OPENGL was defined,
it should be possible to redefine the function signatures under this
scenario, since it's not possible to break binary compatibility if there
never were any binaries to break compatibility with.
One of the bigger changes that was necessary to facilitate this change
is creating interfaces out of QSGContext and QSGRenderContext. Here the
default behavior was usage of OpenGL directly, even though subclasses
could override all OpenGL usage. Making them interfaces should bring
QSGContext and QSGRenderContext more in line with the other classes
present in the adaptation layer.
Change-Id: Iaa54dc0f6cfd18d2da1d059548abf509bd71f200
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/quick/scenegraph/qsgrenderloop.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 1b0b1acc0e..3d019eab72 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -47,7 +47,6 @@ #include <QtCore/QLibraryInfo> #include <QtCore/private/qabstractanimation_p.h> -#include <QtGui/QOpenGLContext> #include <QtGui/QOffscreenSurface> #include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformintegration.h> @@ -59,7 +58,11 @@ #include <QtQuick/private/qsgcontext_p.h> #include <private/qquickprofiler_p.h> -#include <private/qquickshadereffectnode_p.h> +#ifndef QT_NO_OPENGL +# include <QtGui/QOpenGLContext> +# include <private/qsgdefaultrendercontext_p.h> +# include <private/qquickshadereffectnode_p.h> +#endif #ifdef Q_OS_WIN # include <QtCore/qt_windows.h> @@ -69,7 +72,7 @@ QT_BEGIN_NAMESPACE extern bool qsg_useConsistentTiming(); extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha); - +#ifndef QT_NO_OPENGL /*! expectations for this manager to work: - one opengl context to render multiple windows @@ -81,7 +84,7 @@ extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_ DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_BAD_GUI_RENDER_LOOP); DEFINE_BOOL_CONFIG_OPTION(qmlForceThreadedRenderer, QML_FORCE_THREADED_RENDERER); // Might trigger graphics driver threading bugs, use at own risk - +#endif QSGRenderLoop *QSGRenderLoop::s_instance = 0; QSGRenderLoop::~QSGRenderLoop() @@ -113,17 +116,20 @@ void QSGRenderLoop::cleanup() */ void QSGRenderLoop::postJob(QQuickWindow *window, QRunnable *job) { - Q_ASSERT(window); Q_ASSERT(job); - +#ifndef QT_NO_OPENGL + Q_ASSERT(window); if (window->openglContext()) { window->openglContext()->makeCurrent(window); job->run(); } - +#else + Q_UNUSED(window) + job->run(); +#endif delete job; } - +#ifndef QT_NO_OPENGL class QSGGuiThreadRenderLoop : public QSGRenderLoop { Q_OBJECT @@ -164,7 +170,7 @@ public: QImage grabContent; }; - +#endif QSGRenderLoop *QSGRenderLoop::instance() { if (!s_instance) { @@ -174,7 +180,7 @@ QSGRenderLoop *QSGRenderLoop::instance() const_cast<QLoggingCategory &>(QSG_LOG_INFO()).setEnabled(QtDebugMsg, true); s_instance = QSGContext::createWindowManager(); - +#ifndef QT_NO_OPENGL if (!s_instance) { enum RenderLoopType { @@ -226,9 +232,10 @@ QSGRenderLoop *QSGRenderLoop::instance() break; } } - +#endif qAddPostRoutine(QSGRenderLoop::cleanup); } + return s_instance; } @@ -263,7 +270,7 @@ void QSGRenderLoop::handleContextCreationFailure(QQuickWindow *window, if (!signalEmitted) qFatal("%s", qPrintable(untranslatedMessage)); } - +#ifndef QT_NO_OPENGL QSGGuiThreadRenderLoop::QSGGuiThreadRenderLoop() : gl(0) { @@ -358,8 +365,10 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) cd->fireOpenGLContextCreated(gl); current = gl->makeCurrent(window); } - if (current) - cd->context->initialize(gl); + if (current) { + auto openglRenderContext = static_cast<QSGDefaultRenderContext *>(cd->context); + openglRenderContext->initialize(gl); + } } else { current = gl->makeCurrent(window); } @@ -480,6 +489,8 @@ void QSGGuiThreadRenderLoop::handleUpdateRequest(QQuickWindow *window) renderWindow(window); } +#endif + #include "qsgrenderloop.moc" QT_END_NAMESPACE |