Partially revert d9c531781e

This logic changed then timing for when the layer's m_dirtyTexture
was set and unset, which had some side effects. Revert to the old
and known-to-work behavior of using a connection.

Change-Id: I4048e7ae70491afe36b2d766e6c506d9febc44ed
Task-number: QTBUG-41451
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
Gunnar Sletta 2014-10-01 11:12:18 +02:00
parent 125c96476e
commit 64e2fa8001
5 changed files with 22 additions and 48 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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));

View File

@ -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;