Properly mark image node as dirty on size update

This commit is contained in:
Nicolas Werner 2022-05-11 12:28:27 +02:00
parent 90da39313f
commit 908f62159a
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -162,6 +162,8 @@ MxcAnimatedImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGe
QSizeF r = movie.scaledSize(); QSizeF r = movie.scaledSize();
r.scale(newGeometry.size(), Qt::KeepAspectRatio); r.scale(newGeometry.size(), Qt::KeepAspectRatio);
movie.setScaledSize(r.toSize()); movie.setScaledSize(r.toSize());
imageDirty = true;
update();
} }
} }
} }
@ -182,7 +184,6 @@ MxcAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeD
n->setFlags(QSGNode::OwnedByParent); n->setFlags(QSGNode::OwnedByParent);
} }
// n->setTexture(nullptr);
auto img = movie.currentImage(); auto img = movie.currentImage();
n->setSourceRect(img.rect()); n->setSourceRect(img.rect());
if (!img.isNull()) if (!img.isNull())
@ -193,7 +194,6 @@ MxcAnimatedImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeD
} }
QSizeF r = img.size(); QSizeF r = img.size();
if (height() != 0 || width() != 0)
r.scale(size(), Qt::KeepAspectRatio); r.scale(size(), Qt::KeepAspectRatio);
n->setRect((width() - r.width()) / 2, (height() - r.height()) / 2, r.width(), r.height()); n->setRect((width() - r.width()) / 2, (height() - r.height()) / 2, r.width(), r.height());