Remove manual isDirty tracking in SvgItem

This commit is contained in:
David Edmundson 2014-02-20 13:32:53 +01:00
parent 9492340ba6
commit fd4bf875a7
2 changed files with 9 additions and 13 deletions

View File

@ -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<QSGSimpleTextureNode*>(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();
}

View File

@ -107,7 +107,6 @@ private:
QString m_elementID;
QSGTexture *m_texture;
bool m_smooth;
bool m_dirty;
};
}