Stop relying on timer to schedule pixmap updates.
The timer was used to skip ahead of parsing and to compress prop updates to handle width/height changes atomically. This achieves both by moving pixmap load into the polish phase after those are guaranteed to be done. This fixes a bunch of flicker all over the place since 150ms is obviously far beyond the frame time budget on 60 hz, but we can usually easily fit into one frame on hot caches.
This commit is contained in:
parent
01cd374c8e
commit
706276d108
@ -65,7 +65,7 @@ IconItem::IconItem(QQuickItem *parent)
|
||||
this, SIGNAL(implicitHeightChanged()));
|
||||
|
||||
connect(this, SIGNAL(enabledChanged()),
|
||||
this, SLOT(loadPixmap()));
|
||||
this, SLOT(schedulePixmapUpdate()));
|
||||
|
||||
//initialize implicit size to the Dialog size
|
||||
setImplicitWidth(KIconLoader::global()->currentSize(KIconLoader::Dialog));
|
||||
@ -97,7 +97,7 @@ void IconItem::setSource(const QVariant &source)
|
||||
m_svgIcon = 0;
|
||||
m_icon = QIcon();
|
||||
emit validChanged();
|
||||
loadPixmap();
|
||||
schedulePixmapUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ void IconItem::setSource(const QVariant &source)
|
||||
//success?
|
||||
if (m_svgIcon->isValid() && m_svgIcon->hasElement(m_source.toString())) {
|
||||
m_icon = QIcon();
|
||||
connect(m_svgIcon, SIGNAL(repaintNeeded()), this, SLOT(loadPixmap()));
|
||||
connect(m_svgIcon, SIGNAL(repaintNeeded()), this, SLOT(schedulePixmapUpdate()));
|
||||
|
||||
//ok, svg not available from the plasma theme
|
||||
} else {
|
||||
@ -176,7 +176,7 @@ void IconItem::setSource(const QVariant &source)
|
||||
}
|
||||
|
||||
if (width() > 0 && height() > 0) {
|
||||
loadPixmap();
|
||||
schedulePixmapUpdate();
|
||||
}
|
||||
|
||||
emit sourceChanged();
|
||||
@ -221,7 +221,7 @@ void IconItem::setActive(bool active)
|
||||
|
||||
m_active = active;
|
||||
if (isComponentComplete()) {
|
||||
loadPixmap();
|
||||
schedulePixmapUpdate();
|
||||
}
|
||||
emit activeChanged();
|
||||
}
|
||||
@ -245,6 +245,12 @@ bool IconItem::isValid() const
|
||||
return !m_icon.isNull() || m_svgIcon || !m_pixmapIcon.isNull() || !m_imageIcon.isNull();
|
||||
}
|
||||
|
||||
void IconItem::updatePolish()
|
||||
{
|
||||
QQuickItem::updatePolish();
|
||||
loadPixmap();
|
||||
}
|
||||
|
||||
QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)
|
||||
{
|
||||
Q_UNUSED(updatePaintNodeData)
|
||||
@ -315,6 +321,11 @@ void IconItem::animationFinished()
|
||||
update();
|
||||
}
|
||||
|
||||
void IconItem::schedulePixmapUpdate()
|
||||
{
|
||||
polish();
|
||||
}
|
||||
|
||||
void IconItem::loadPixmap()
|
||||
{
|
||||
if (!isComponentComplete()) {
|
||||
@ -391,11 +402,10 @@ void IconItem::geometryChanged(const QRectF &newGeometry,
|
||||
{
|
||||
if (newGeometry.size() != oldGeometry.size()) {
|
||||
m_sizeChanged = true;
|
||||
update();
|
||||
if (newGeometry.width() > 0 && newGeometry.height() > 0) {
|
||||
if (isComponentComplete()) {
|
||||
loadPixmap();
|
||||
}
|
||||
schedulePixmapUpdate();
|
||||
} else {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -405,5 +415,5 @@ void IconItem::geometryChanged(const QRectF &newGeometry,
|
||||
void IconItem::componentComplete()
|
||||
{
|
||||
QQuickItem::componentComplete();
|
||||
loadPixmap();
|
||||
schedulePixmapUpdate();
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
void updatePolish() Q_DECL_OVERRIDE;
|
||||
QSGNode* updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) Q_DECL_OVERRIDE;
|
||||
|
||||
void geometryChanged(const QRectF &newGeometry,
|
||||
@ -79,11 +80,13 @@ Q_SIGNALS:
|
||||
void colorGroupChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void loadPixmap();
|
||||
void schedulePixmapUpdate();
|
||||
void animationFinished();
|
||||
void valueChanged(const QVariant &value);
|
||||
|
||||
private:
|
||||
void loadPixmap();
|
||||
|
||||
//all the ways we can set an source. Only one of them will be valid
|
||||
QIcon m_icon;
|
||||
Plasma::Svg *m_svgIcon;
|
||||
|
Loading…
x
Reference in New Issue
Block a user