From fd4bf875a7fef0f60197a4f886e2a10796169b74 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 20 Feb 2014 13:32:53 +0100 Subject: [PATCH] Remove manual isDirty tracking in SvgItem --- src/declarativeimports/core/svgitem.cpp | 21 +++++++++------------ src/declarativeimports/core/svgitem.h | 1 - 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/declarativeimports/core/svgitem.cpp b/src/declarativeimports/core/svgitem.cpp index b5dcd7bd1..d8ed6ed9c 100644 --- a/src/declarativeimports/core/svgitem.cpp +++ b/src/declarativeimports/core/svgitem.cpp @@ -33,9 +33,8 @@ namespace Plasma SvgItem::SvgItem(QQuickItem *parent) : QQuickItem(parent), - m_smooth(false), - m_dirty(false), - m_texture(0) + m_texture(0), + m_smooth(false) { setFlag(QQuickItem::ItemHasContents, true); } @@ -62,7 +61,7 @@ void SvgItem::setElementId(const QString &elementID) m_elementID = elementID; emit elementIdChanged(); emit naturalSizeChanged(); - updateNeeded(); + update(); } QString SvgItem::elementId() const @@ -136,10 +135,13 @@ QSGNode* SvgItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updateP QSGSimpleTextureNode *textureNode = static_cast(oldNode); if (!textureNode) { textureNode = new QSGSimpleTextureNode; - m_dirty = true; } - if (m_dirty) { + //TODO use a heuristic to work out when to redraw + //if !m_smooth and size is approximate simply change the textureNode.rect without + //updating the material + + if (!m_texture || m_texture->textureSize() != QSize(width(), height())) { m_svg.data()->resize(width(), height()); m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty()); @@ -147,12 +149,9 @@ QSGNode* SvgItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updateP delete m_texture; m_texture = window()->createTextureFromImage(image); textureNode->setTexture(m_texture); - - m_dirty = false; + textureNode->setRect(0,0, width(), height()); } - textureNode->setRect(0,0, width(), height()); - return textureNode; } @@ -164,8 +163,6 @@ void SvgItem::updateNeeded() if (implicitHeight() <= 0) { setImplicitHeight(naturalSize().height()); } - - m_dirty = true; update(); } diff --git a/src/declarativeimports/core/svgitem.h b/src/declarativeimports/core/svgitem.h index 93cfb9970..1d658e165 100644 --- a/src/declarativeimports/core/svgitem.h +++ b/src/declarativeimports/core/svgitem.h @@ -107,7 +107,6 @@ private: QString m_elementID; QSGTexture *m_texture; bool m_smooth; - bool m_dirty; }; }