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 elementIdChanged();
|
||||||
emit naturalSizeChanged();
|
emit naturalSizeChanged();
|
||||||
|
|
||||||
m_textureChanged = true;
|
scheduleImageUpdate();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SvgItem::elementId() const
|
QString SvgItem::elementId() const
|
||||||
@ -105,7 +104,7 @@ void SvgItem::setSvg(Plasma::Svg *svg)
|
|||||||
setImplicitHeight(naturalSize().height());
|
setImplicitHeight(naturalSize().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_textureChanged = true;
|
scheduleImageUpdate();
|
||||||
|
|
||||||
emit svgChanged();
|
emit svgChanged();
|
||||||
emit naturalSizeChanged();
|
emit naturalSizeChanged();
|
||||||
@ -156,19 +155,15 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP
|
|||||||
//updating the material
|
//updating the material
|
||||||
|
|
||||||
if (m_textureChanged || textureNode->texture()->textureSize() != QSize(width(), height())) {
|
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
|
//despite having a valid size sometimes we still get a null QImage from Plasma::Svg
|
||||||
//loading a null texture to an atlas fatals
|
//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
|
//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;
|
delete textureNode;
|
||||||
return Q_NULLPTR;
|
return Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<QSGTexture> texture(window()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas));
|
QSharedPointer<QSGTexture> texture(window()->createTextureFromImage(m_image, QQuickWindow::TextureCanUseAtlas));
|
||||||
if (m_smooth) {
|
if (m_smooth) {
|
||||||
texture->setFiltering(QSGTexture::Linear);
|
texture->setFiltering(QSGTexture::Linear);
|
||||||
}
|
}
|
||||||
@ -189,8 +184,7 @@ void SvgItem::updateNeeded()
|
|||||||
if (implicitHeight() <= 0) {
|
if (implicitHeight() <= 0) {
|
||||||
setImplicitHeight(naturalSize().height());
|
setImplicitHeight(naturalSize().height());
|
||||||
}
|
}
|
||||||
m_textureChanged = true;
|
scheduleImageUpdate();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SvgItem::updateDevicePixelRatio()
|
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
|
} // Plasma namespace
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define SVGITEM_P
|
#define SVGITEM_P
|
||||||
|
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|
||||||
@ -97,11 +98,16 @@ protected Q_SLOTS:
|
|||||||
/// @endcond
|
/// @endcond
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void scheduleImageUpdate();
|
||||||
|
void updatePolish() Q_DECL_OVERRIDE;
|
||||||
|
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
QWeakPointer<Plasma::Svg> m_svg;
|
QWeakPointer<Plasma::Svg> m_svg;
|
||||||
QString m_elementID;
|
QString m_elementID;
|
||||||
bool m_smooth;
|
bool m_smooth;
|
||||||
bool m_textureChanged;
|
bool m_textureChanged;
|
||||||
Units m_units;
|
Units m_units;
|
||||||
|
QImage m_image;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user