From 90d98e1330bd46b5defafd5d6b86fa8fe157b48d Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Tue, 15 Mar 2016 13:39:41 +0100 Subject: 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 --- src/quick/util/qquickanimator.cpp | 3 ++- src/quick/util/qquickanimator_p.h | 6 ++++-- src/quick/util/qquickanimatorjob.cpp | 22 +++++++++++++++++----- src/quick/util/qquickanimatorjob_p.h | 3 ++- src/quick/util/qquickutilmodule.cpp | 3 ++- 5 files changed, 27 insertions(+), 10 deletions(-) (limited to 'src/quick/util') diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp index abae6321b0..100b7bd402 100644 --- a/src/quick/util/qquickanimator.cpp +++ b/src/quick/util/qquickanimator.cpp @@ -502,7 +502,7 @@ QQuickRotationAnimator::RotationDirection QQuickRotationAnimator::direction() co Q_D(const QQuickRotationAnimator); return d->direction; } - +#ifndef QT_NO_OPENGL /*! \qmltype UniformAnimator \instantiates QQuickUniformAnimator @@ -580,5 +580,6 @@ QQuickAnimatorJob *QQuickUniformAnimator::createJob() const job->setUniform(u.toLatin1()); return job; } +#endif QT_END_NAMESPACE diff --git a/src/quick/util/qquickanimator_p.h b/src/quick/util/qquickanimator_p.h index c23aa0a7e9..f1e2d4e1d9 100644 --- a/src/quick/util/qquickanimator_p.h +++ b/src/quick/util/qquickanimator_p.h @@ -169,7 +169,7 @@ protected: QQuickAnimatorJob *createJob() const; QString propertyName() const { return QStringLiteral("rotation"); } }; - +#ifndef QT_NO_OPENGL class QQuickUniformAnimatorPrivate; class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator { @@ -190,6 +190,7 @@ protected: QQuickAnimatorJob *createJob() const; QString propertyName() const; }; +#endif QT_END_NAMESPACE @@ -199,6 +200,7 @@ QML_DECLARE_TYPE(QQuickYAnimator) QML_DECLARE_TYPE(QQuickScaleAnimator) QML_DECLARE_TYPE(QQuickRotationAnimator) QML_DECLARE_TYPE(QQuickOpacityAnimator) +#ifndef QT_NO_OPENGL QML_DECLARE_TYPE(QQuickUniformAnimator) - +#endif #endif // QQUICKANIMATOR_P_H diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index d7be237a39..b7e0d6437a 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -43,8 +43,9 @@ #include "qquickanimator_p_p.h" #include #include -#include - +#ifndef QT_NO_OPENGL +# include +#endif #include #include @@ -386,8 +387,9 @@ void QQuickXAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; +#ifndef QT_NO_OPENGL Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - +#endif m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_helper->dx = m_value; m_helper->wasChanged = true; @@ -403,8 +405,9 @@ void QQuickYAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; +#ifndef QT_NO_OPENGL Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - +#endif m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_helper->dy = m_value; m_helper->wasChanged = true; @@ -473,7 +476,9 @@ void QQuickOpacityAnimatorJob::updateCurrentTime(int time) { if (!m_controller || !m_opacityNode) return; +#ifndef QT_NO_OPENGL Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); +#endif m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_opacityNode->setOpacity(m_value); @@ -489,7 +494,9 @@ void QQuickScaleAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; +#ifndef QT_NO_OPENGL Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); +#endif m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_helper->scale = m_value; @@ -509,7 +516,9 @@ void QQuickRotationAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; +#ifndef QT_NO_OPENGL Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); +#endif float t = m_easing.valueForProgress(time / (qreal) m_duration); switch (m_direction) { @@ -541,6 +550,7 @@ void QQuickRotationAnimatorJob::writeBack() m_target->setRotation(value()); } +#ifndef QT_NO_OPENGL QQuickUniformAnimatorJob::QQuickUniformAnimatorJob() : m_node(0) , m_uniformIndex(-1) @@ -589,8 +599,9 @@ void QQuickUniformAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; +#ifndef QT_NO_OPENGL Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); - +#endif if (!m_node || m_uniformIndex == -1 || m_uniformType == -1) return; @@ -610,5 +621,6 @@ void QQuickUniformAnimatorJob::writeBack() if (m_target) m_target->setProperty(m_uniform, value()); } +#endif QT_END_NAMESPACE diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index 71c1e93746..75d2b962a5 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -275,7 +275,7 @@ public: private: QSGOpacityNode *m_opacityNode; }; - +#ifndef QT_NO_OPENGL class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimatorJob : public QQuickAnimatorJob { public: @@ -299,6 +299,7 @@ private: int m_uniformIndex : 8; int m_uniformType : 8; }; +#endif QT_END_NAMESPACE diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp index f5d11c6230..66994e22ba 100644 --- a/src/quick/util/qquickutilmodule.cpp +++ b/src/quick/util/qquickutilmodule.cpp @@ -107,8 +107,9 @@ void QQuickUtilModule::defineModule() qmlRegisterType("QtQuick", 2, 2, "ScaleAnimator"); qmlRegisterType("QtQuick", 2, 2, "RotationAnimator"); qmlRegisterType("QtQuick", 2, 2, "OpacityAnimator"); +#ifndef QT_NO_OPENGL qmlRegisterType("QtQuick", 2, 2, "UniformAnimator"); - +#endif qmlRegisterType(); qmlRegisterCustomType("QtQuick",2,0,"PropertyChanges", new QQuickPropertyChangesParser); -- cgit v1.2.3 From 0a1ff7aacaf7da52c4345f4c354729d53c2f31c7 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 30 Mar 2016 16:36:46 +0200 Subject: D3D12: Fix Animators with non-GL backends Add a test for render thread Animators. Change-Id: Iddb11f734ccec00d76ca99cd8349cbb65750e784 Reviewed-by: Andy Nichols --- src/quick/util/qquickanimatorjob.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'src/quick/util') diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index b7e0d6437a..3502a28301 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -174,7 +174,7 @@ void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window) } else if (!m_controller && m_job) { m_controller = QQuickWindowPrivate::get(window)->animationController; - if (window->openglContext()) + if (window->isSceneGraphInitialized()) readyToAnimate(); else connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized())); @@ -387,9 +387,7 @@ void QQuickXAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; -#ifndef QT_NO_OPENGL - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); -#endif + m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_helper->dx = m_value; m_helper->wasChanged = true; @@ -405,9 +403,7 @@ void QQuickYAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; -#ifndef QT_NO_OPENGL - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); -#endif + m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_helper->dy = m_value; m_helper->wasChanged = true; @@ -476,9 +472,6 @@ void QQuickOpacityAnimatorJob::updateCurrentTime(int time) { if (!m_controller || !m_opacityNode) return; -#ifndef QT_NO_OPENGL - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); -#endif m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_opacityNode->setOpacity(m_value); @@ -494,9 +487,6 @@ void QQuickScaleAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; -#ifndef QT_NO_OPENGL - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); -#endif m_value = m_from + (m_to - m_from) * m_easing.valueForProgress(time / (qreal) m_duration); m_helper->scale = m_value; @@ -516,9 +506,6 @@ void QQuickRotationAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; -#ifndef QT_NO_OPENGL - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); -#endif float t = m_easing.valueForProgress(time / (qreal) m_duration); switch (m_direction) { @@ -599,9 +586,7 @@ void QQuickUniformAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; -#ifndef QT_NO_OPENGL - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); -#endif + if (!m_node || m_uniformIndex == -1 || m_uniformType == -1) return; -- cgit v1.2.3 From e188a3d864a5310bf18c3ad759a12560013deb64 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 11 Apr 2016 14:49:12 +0200 Subject: Prefix GL-specific shader effect code Rename the C++ sources and classes. The QML type name remains the same. No changes in functionality. The shader effect, node, material (and uniform animator and particles and bits and pieces here and there...) are highly interconnected and do not follow the usual design practices for Quick and the scenegraph and the adaptation layer. Therefore while we aim for keeping full compatibility for GL apps, other backends will likely get a different ShaderEffect item implementation. The C++ class QQuickShaderEffect itself is currently a dummy with an unchanged API. It is not in use for now but forms the basis for the implementation for other backends. This will be covered in future commits. Change-Id: Ia39ce4b303f8f33e2f241d11e35fa62423e43127 Reviewed-by: Andy Nichols --- src/quick/util/qquickanimatorjob.cpp | 19 ++++++++++--------- src/quick/util/qquickanimatorjob_p.h | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src/quick/util') diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index f0ecb8150a..a0c787dae5 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -44,7 +44,8 @@ #include #include #ifndef QT_NO_OPENGL -# include +# include +# include #endif #include @@ -553,7 +554,7 @@ QQuickUniformAnimatorJob::QQuickUniformAnimatorJob() void QQuickUniformAnimatorJob::setTarget(QQuickItem *target) { - if (qobject_cast(target) != 0) + if (qobject_cast(target) != 0) m_target = target; } @@ -566,14 +567,14 @@ void QQuickUniformAnimatorJob::nodeWasDestroyed() void QQuickUniformAnimatorJob::afterNodeSync() { - m_node = static_cast(QQuickItemPrivate::get(m_target)->paintNode); + m_node = static_cast(QQuickItemPrivate::get(m_target)->paintNode); if (m_node && m_uniformIndex == -1 && m_uniformType == -1) { - QQuickShaderEffectMaterial *material = - static_cast(m_node->material()); + QQuickOpenGLShaderEffectMaterial *material = + static_cast(m_node->material()); bool found = false; - for (int t=0; !found && t &uniforms = material->uniforms[t]; + for (int t=0; !found && t &uniforms = material->uniforms[t]; for (int i=0; i(m_node->material()); + QQuickOpenGLShaderEffectMaterial *material = + static_cast(m_node->material()); material->uniforms[m_uniformType][m_uniformIndex].value = m_value; // As we're not touching the nodes, we need to explicitly mark it dirty. // Otherwise, the renderer will abort repainting if this was the only diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index 118487f937..64e849d322 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -68,7 +68,7 @@ class QQuickAbstractAnimation; class QQuickAnimatorController; class QQuickAnimatorProxyJobPrivate; -class QQuickShaderEffectNode; +class QQuickOpenGLShaderEffectNode; class QSGOpacityNode; @@ -296,7 +296,7 @@ public: private: QByteArray m_uniform; - QQuickShaderEffectNode *m_node; + QQuickOpenGLShaderEffectNode *m_node; int m_uniformIndex : 8; int m_uniformType : 8; -- cgit v1.2.3