Remove manual isDirty tracking in SvgItem
This commit is contained in:
parent
9492340ba6
commit
fd4bf875a7
@ -33,9 +33,8 @@ namespace Plasma
|
|||||||
|
|
||||||
SvgItem::SvgItem(QQuickItem *parent)
|
SvgItem::SvgItem(QQuickItem *parent)
|
||||||
: QQuickItem(parent),
|
: QQuickItem(parent),
|
||||||
m_smooth(false),
|
m_texture(0),
|
||||||
m_dirty(false),
|
m_smooth(false)
|
||||||
m_texture(0)
|
|
||||||
{
|
{
|
||||||
setFlag(QQuickItem::ItemHasContents, true);
|
setFlag(QQuickItem::ItemHasContents, true);
|
||||||
}
|
}
|
||||||
@ -62,7 +61,7 @@ void SvgItem::setElementId(const QString &elementID)
|
|||||||
m_elementID = elementID;
|
m_elementID = elementID;
|
||||||
emit elementIdChanged();
|
emit elementIdChanged();
|
||||||
emit naturalSizeChanged();
|
emit naturalSizeChanged();
|
||||||
updateNeeded();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SvgItem::elementId() const
|
QString SvgItem::elementId() const
|
||||||
@ -136,10 +135,13 @@ QSGNode* SvgItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updateP
|
|||||||
QSGSimpleTextureNode *textureNode = static_cast<QSGSimpleTextureNode*>(oldNode);
|
QSGSimpleTextureNode *textureNode = static_cast<QSGSimpleTextureNode*>(oldNode);
|
||||||
if (!textureNode) {
|
if (!textureNode) {
|
||||||
textureNode = new QSGSimpleTextureNode;
|
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()->resize(width(), height());
|
||||||
m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty());
|
m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty());
|
||||||
|
|
||||||
@ -147,12 +149,9 @@ QSGNode* SvgItem::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* updateP
|
|||||||
delete m_texture;
|
delete m_texture;
|
||||||
m_texture = window()->createTextureFromImage(image);
|
m_texture = window()->createTextureFromImage(image);
|
||||||
textureNode->setTexture(m_texture);
|
textureNode->setTexture(m_texture);
|
||||||
|
textureNode->setRect(0,0, width(), height());
|
||||||
m_dirty = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
textureNode->setRect(0,0, width(), height());
|
|
||||||
|
|
||||||
return textureNode;
|
return textureNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,8 +163,6 @@ void SvgItem::updateNeeded()
|
|||||||
if (implicitHeight() <= 0) {
|
if (implicitHeight() <= 0) {
|
||||||
setImplicitHeight(naturalSize().height());
|
setImplicitHeight(naturalSize().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dirty = true;
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,6 @@ private:
|
|||||||
QString m_elementID;
|
QString m_elementID;
|
||||||
QSGTexture *m_texture;
|
QSGTexture *m_texture;
|
||||||
bool m_smooth;
|
bool m_smooth;
|
||||||
bool m_dirty;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user