diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-11 14:51:40 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-07-11 17:24:39 +0200 |
commit | 13374ceb165c44658aa97890c37b206859c9a31c (patch) | |
tree | 562362b196a459ee3449a5a1e60e5216a9dd6984 /src/quick/items/qquickshadereffect.cpp | |
parent | ae47deba4c943c496412530a8d2a5a688ae12038 (diff) | |
parent | b5d18be5a03406d0aac83856dd41e1525fd14a28 (diff) |
Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Change-Id: I2963c1209316fb6755f572969f368970450d7991
Diffstat (limited to 'src/quick/items/qquickshadereffect.cpp')
-rw-r--r-- | src/quick/items/qquickshadereffect.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp index 05d9e5e36d..b3c8386fd9 100644 --- a/src/quick/items/qquickshadereffect.cpp +++ b/src/quick/items/qquickshadereffect.cpp @@ -44,6 +44,9 @@ #include <private/qquickopenglshadereffect_p.h> #endif #include <private/qquickgenericshadereffect_p.h> +#if QT_CONFIG(opengl) /* || QT_CONFIG(vulkan) || defined(Q_OS_WIN) || defined(Q_OS_DARWIN) */ +#include <private/qsgrhisupport_p.h> +#endif QT_BEGIN_NAMESPACE @@ -506,13 +509,34 @@ QQuickShaderEffect::QQuickShaderEffect(QQuickItem *parent) { setFlag(QQuickItem::ItemHasContents); +#if QT_CONFIG(opengl) /* || QT_CONFIG(vulkan) || defined(Q_OS_WIN) || defined(Q_OS_DARWIN) */ + if (QSGRhiSupport::instance()->isRhiEnabled()) { + m_impl = new QQuickGenericShaderEffect(this, this); + } else +#endif + { #if QT_CONFIG(opengl) - if (!qsg_backend_flags().testFlag(QSGContextFactoryInterface::SupportsShaderEffectNode)) - m_glImpl = new QQuickOpenGLShaderEffect(this, this); + if (!qsg_backend_flags().testFlag(QSGContextFactoryInterface::SupportsShaderEffectNode)) + m_glImpl = new QQuickOpenGLShaderEffect(this, this); - if (!m_glImpl) + if (!m_glImpl) #endif - m_impl = new QQuickGenericShaderEffect(this, this); + m_impl = new QQuickGenericShaderEffect(this, this); + } +} + +QQuickShaderEffect::~QQuickShaderEffect() +{ + // Delete the implementations now, while they still have have + // valid references back to us. +#if QT_CONFIG(opengl) + auto *glImpl = m_glImpl; + m_glImpl = nullptr; + delete glImpl; +#endif + auto *impl = m_impl; + m_impl = nullptr; + delete impl; } /*! @@ -865,6 +889,8 @@ QString QQuickShaderEffect::parseLog() // for OpenGL-based autotests void QQuickShaderEffectPrivate::updatePolish() { Q_Q(QQuickShaderEffect); + if (!qmlEngine(q)) + return; #if QT_CONFIG(opengl) if (q->m_glImpl) { q->m_glImpl->maybeUpdateShaders(); |