diff options
-rw-r--r-- | src/quick/items/qquickshadereffectsource.cpp | 24 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgadaptationlayer.cpp | 21 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgadaptationlayer_p.h | 9 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultlayer.cpp | 13 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultlayer_p.h | 3 |
5 files changed, 22 insertions, 48 deletions
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp index 120a8956eb..520a58a37b 100644 --- a/src/quick/items/qquickshadereffectsource.cpp +++ b/src/quick/items/qquickshadereffectsource.cpp @@ -74,7 +74,6 @@ public: QSGTexture::WrapMode horizontalWrap; QSGTexture::WrapMode verticalWrap; }; -#include "qquickshadereffectsource.moc" class QQuickShaderEffectSourceCleanup : public QRunnable { @@ -586,13 +585,24 @@ void QQuickShaderEffectSource::releaseResources() } } +class QQuickShaderSourceAttachedNode : public QObject, public QSGNode +{ + Q_OBJECT +public: + Q_SLOT void markTextureDirty() { + QSGNode *pn = QSGNode::parent(); + if (pn) { + Q_ASSERT(pn->type() == QSGNode::GeometryNodeType); + pn->markDirty(DirtyMaterial); + } + } +}; + QSGNode *QQuickShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) { if (!m_sourceItem || m_sourceItem->width() <= 0 || m_sourceItem->height() <= 0) { - if (m_texture) { + if (m_texture) m_texture->setItem(0); - m_texture->setShaderSourceNode(0); - } delete oldNode; return 0; } @@ -658,7 +668,9 @@ QSGNode *QQuickShaderEffectSource::updatePaintNode(QSGNode *oldNode, UpdatePaint node = d->sceneGraphContext()->createImageNode(); node->setFlag(QSGNode::UsePreprocess); node->setTexture(m_texture); - m_texture->setShaderSourceNode(node); + QQuickShaderSourceAttachedNode *attached = new QQuickShaderSourceAttachedNode; + node->appendChildNode(attached); + connect(m_texture, SIGNAL(updateRequested()), attached, SLOT(markTextureDirty())); } // If live and recursive, update continuously. @@ -698,4 +710,6 @@ void QQuickShaderEffectSource::itemChange(ItemChange change, const ItemChangeDat QQuickItem::itemChange(change, value); } +#include "qquickshadereffectsource.moc" + QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index fb9fe00ee5..80234d54f5 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -339,25 +339,4 @@ void QSGNodeVisitorEx::visitChildren(QSGNode *node) } } -void QSGLayer::markDirtyTextureLater() -{ - QCoreApplication::postEvent(this, new QEvent(static_cast<QEvent::Type>(markDirtyEventType()))); -} - -void QSGLayer::customEvent(QEvent *event) -{ - if (event->type() == markDirtyEventType()) - markDirtyTexture(); - else - QObject::customEvent(event); -} - -int QSGLayer::markDirtyEventType() -{ - static int type = QEvent::None; - if (type == QEvent::None) - type = QEvent::registerEventType(); - return type; -} - QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgadaptationlayer_p.h b/src/quick/scenegraph/qsgadaptationlayer_p.h index 71033bd6d0..a63299fcde 100644 --- a/src/quick/scenegraph/qsgadaptationlayer_p.h +++ b/src/quick/scenegraph/qsgadaptationlayer_p.h @@ -198,7 +198,6 @@ class Q_QUICK_EXPORT QSGLayer : public QSGDynamicTexture Q_OBJECT public: virtual void setItem(QSGNode *item) = 0; - virtual void setShaderSourceNode(QSGNode *node) = 0; virtual void setRect(const QRectF &rect) = 0; virtual void setSize(const QSize &size) = 0; virtual void scheduleUpdate() = 0; @@ -211,17 +210,9 @@ public: Q_SLOT virtual void markDirtyTexture() = 0; Q_SLOT virtual void invalidated() = 0; - Q_SLOT void markDirtyTextureLater(); - Q_SIGNALS: void updateRequested(); void scheduledUpdateCompleted(); - -protected: - virtual void customEvent(QEvent *); - -private: - int markDirtyEventType(); }; class Q_QUICK_PRIVATE_EXPORT QSGGlyphNode : public QSGVisitableNode diff --git a/src/quick/scenegraph/qsgdefaultlayer.cpp b/src/quick/scenegraph/qsgdefaultlayer.cpp index c93517fe3f..450a9fbee0 100644 --- a/src/quick/scenegraph/qsgdefaultlayer.cpp +++ b/src/quick/scenegraph/qsgdefaultlayer.cpp @@ -88,7 +88,6 @@ namespace QSGDefaultLayer::QSGDefaultLayer(QSGRenderContext *context) : QSGLayer() , m_item(0) - , m_shaderSourceNode(0) , m_device_pixel_ratio(1) , m_format(GL_RGBA) , m_renderer(0) @@ -259,11 +258,8 @@ void QSGDefaultLayer::scheduleUpdate() if (m_grab) return; m_grab = true; - if (m_dirtyTexture) { + if (m_dirtyTexture) emit updateRequested(); - if (m_shaderSourceNode) - m_shaderSourceNode->markDirty(QSGNode::DirtyMaterial); - } } void QSGDefaultLayer::setRecursive(bool recursive) @@ -274,11 +270,8 @@ void QSGDefaultLayer::setRecursive(bool recursive) void QSGDefaultLayer::markDirtyTexture() { m_dirtyTexture = true; - if (m_live || m_grab) { + if (m_live || m_grab) emit updateRequested(); - if (m_shaderSourceNode) - m_shaderSourceNode->markDirty(QSGNode::DirtyMaterial); - } } void QSGDefaultLayer::grab() @@ -299,7 +292,7 @@ void QSGDefaultLayer::grab() if (!m_renderer) { m_renderer = m_context->createRenderer(); - connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTextureLater())); + connect(m_renderer, SIGNAL(sceneGraphChanged()), this, SLOT(markDirtyTexture())); } m_renderer->setDevicePixelRatio(m_device_pixel_ratio); m_renderer->setRootNode(static_cast<QSGRootNode *>(root)); diff --git a/src/quick/scenegraph/qsgdefaultlayer_p.h b/src/quick/scenegraph/qsgdefaultlayer_p.h index 47a0448846..44c74d7cfd 100644 --- a/src/quick/scenegraph/qsgdefaultlayer_p.h +++ b/src/quick/scenegraph/qsgdefaultlayer_p.h @@ -60,8 +60,6 @@ public: QSGNode *item() const { return m_item; } void setItem(QSGNode *item); - void setShaderSourceNode(QSGNode *node) { m_shaderSourceNode = node; } - QRectF rect() const { return m_rect; } void setRect(const QRectF &rect); @@ -100,7 +98,6 @@ private: void grab(); QSGNode *m_item; - QSGNode *m_shaderSourceNode; QRectF m_rect; QSize m_size; qreal m_device_pixel_ratio; |