SvgItem: Don't use Plasma::Theme from rendering thread
Logic is similar to IconItem - rendered image is updated in updatePolish(). REVIEW: 127115
This commit is contained in:
parent
f4e541ad87
commit
596fa082dd
@ -64,8 +64,7 @@ void SvgItem::setElementId(const QString &elementID)
|
||||
emit elementIdChanged();
|
||||
emit naturalSizeChanged();
|
||||
|
||||
m_textureChanged = true;
|
||||
update();
|
||||
scheduleImageUpdate();
|
||||
}
|
||||
|
||||
QString SvgItem::elementId() const
|
||||
@ -105,7 +104,7 @@ void SvgItem::setSvg(Plasma::Svg *svg)
|
||||
setImplicitHeight(naturalSize().height());
|
||||
}
|
||||
|
||||
m_textureChanged = true;
|
||||
scheduleImageUpdate();
|
||||
|
||||
emit svgChanged();
|
||||
emit naturalSizeChanged();
|
||||
@ -156,19 +155,15 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP
|
||||
//updating the material
|
||||
|
||||
if (m_textureChanged || textureNode->texture()->textureSize() != QSize(width(), height())) {
|
||||
//setContainsMultipleImages has to be done there since m_frameSvg can be shared with somebody else
|
||||
m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty());
|
||||
const QImage image = m_svg.data()->image(QSize(width(), height()), m_elementID);
|
||||
|
||||
//despite having a valid size sometimes we still get a null QImage from Plasma::Svg
|
||||
//loading a null texture to an atlas fatals
|
||||
//Dave E fixed this in Qt in 5.3.something onwards but we need this for now
|
||||
if (image.isNull()) {
|
||||
if (m_image.isNull()) {
|
||||
delete textureNode;
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
QSharedPointer<QSGTexture> texture(window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas));
|
||||
QSharedPointer<QSGTexture> texture(window()->createTextureFromImage(m_image, QQuickWindow::TextureCanUseAtlas));
|
||||
if (m_smooth) {
|
||||
texture->setFiltering(QSGTexture::Linear);
|
||||
}
|
||||
@ -189,8 +184,7 @@ void SvgItem::updateNeeded()
|
||||
if (implicitHeight() <= 0) {
|
||||
setImplicitHeight(naturalSize().height());
|
||||
}
|
||||
m_textureChanged = true;
|
||||
update();
|
||||
scheduleImageUpdate();
|
||||
}
|
||||
|
||||
void SvgItem::updateDevicePixelRatio()
|
||||
@ -207,5 +201,32 @@ void SvgItem::updateDevicePixelRatio()
|
||||
}
|
||||
}
|
||||
|
||||
void SvgItem::scheduleImageUpdate()
|
||||
{
|
||||
polish();
|
||||
update();
|
||||
}
|
||||
|
||||
void SvgItem::updatePolish()
|
||||
{
|
||||
QQuickItem::updatePolish();
|
||||
|
||||
if (m_svg) {
|
||||
//setContainsMultipleImages has to be done there since m_frameSvg can be shared with somebody else
|
||||
m_textureChanged = true;
|
||||
m_svg.data()->setContainsMultipleImages(!m_elementID.isEmpty());
|
||||
m_image = m_svg.data()->image(QSize(width(), height()), m_elementID);
|
||||
}
|
||||
}
|
||||
|
||||
void SvgItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
|
||||
{
|
||||
if (newGeometry.size() != oldGeometry.size() && newGeometry.isValid()) {
|
||||
scheduleImageUpdate();
|
||||
}
|
||||
|
||||
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define SVGITEM_P
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QImage>
|
||||
|
||||
#include "units.h"
|
||||
|
||||
@ -97,11 +98,16 @@ protected Q_SLOTS:
|
||||
/// @endcond
|
||||
|
||||
private:
|
||||
void scheduleImageUpdate();
|
||||
void updatePolish() Q_DECL_OVERRIDE;
|
||||
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
|
||||
|
||||
QWeakPointer<Plasma::Svg> m_svg;
|
||||
QString m_elementID;
|
||||
bool m_smooth;
|
||||
bool m_textureChanged;
|
||||
Units m_units;
|
||||
QImage m_image;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user