aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Nichols <nezticle@gmail.com>2024-08-19 15:25:43 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-08-23 08:44:22 +0000
commitc996d0fa2364d1a83cdf39927254fe787e2ad14e (patch)
tree5f5bef3adddcb241a8d94d8b89ad584a4a37d9f6
parent2bf8027effcf52a7dc6aa117371bef2c38ce4ce3 (diff)
2D Renderer: Make sure cachedMirroredPixmap is never dirty when painting
When using the software context for Qt Quick scene graph rendering, it was possible that Items using "layer.enabled: = true" would not be up to date if these sub-passes were updated while the tree using them was not visible (Due to update()/updatePaintNode() not being called). If the cachedMirrorPixmap doesn't get updated, then the previous image will be used when the item is painted, which is incorrect, and the update() method will not be called again until the next time the item is dirty. This change makes it where if the cache is still dirty when we start painting, we update it then, because spending a bit more time renderer is still better than rendering the wrong thing. Fixes: QTBUG-114984 Pick-to: 6.5 5.15 Change-Id: I70f9f6d1dfd46d6870a2bee2ae72294e8982b776 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 29a52df82397fd8a00308f7e34b08059d6affc91) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 57cdb43db40569faefef9e42d3ad42f3fc2bc4cd)
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp36
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h2
2 files changed, 22 insertions, 16 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
index ba9952e19d..09eae137bb 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
@@ -375,21 +375,7 @@ void QSGSoftwareInternalImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrap
void QSGSoftwareInternalImageNode::update()
{
- if (m_cachedMirroredPixmapIsDirty) {
- if (m_mirrorHorizontally || m_mirrorVertically || m_textureIsLayer) {
- QTransform transform(
- (m_mirrorHorizontally ? -1 : 1), 0,
- 0 , (m_textureIsLayer ? -1 : 1) * (m_mirrorVertically ? -1 : 1),
- 0 , 0
- );
- m_cachedMirroredPixmap = pixmap().transformed(transform);
- } else {
- //Cleanup cached pixmap if necessary
- if (!m_cachedMirroredPixmap.isNull())
- m_cachedMirroredPixmap = QPixmap();
- }
- m_cachedMirroredPixmapIsDirty = false;
- }
+ updateCachedMirroredPixmap();
}
void QSGSoftwareInternalImageNode::preprocess()
@@ -423,6 +409,7 @@ void QSGSoftwareInternalImageNode::paint(QPainter *painter)
// Disable antialiased clipping. It causes transformed tiles to have gaps.
painter->setRenderHint(QPainter::Antialiasing, false);
+ updateCachedMirroredPixmap();
const QPixmap &pm = m_mirrorHorizontally || m_mirrorVertically || m_textureIsLayer ? m_cachedMirroredPixmap : pixmap();
if (m_innerTargetRect != m_targetRect) {
@@ -468,4 +455,23 @@ const QPixmap &QSGSoftwareInternalImageNode::pixmap() const
return nullPixmap;
}
+void QSGSoftwareInternalImageNode::updateCachedMirroredPixmap()
+{
+ if (m_cachedMirroredPixmapIsDirty) {
+ if (m_mirrorHorizontally || m_mirrorVertically || m_textureIsLayer) {
+ QTransform transform(
+ (m_mirrorHorizontally ? -1 : 1), 0,
+ 0 , (m_textureIsLayer ? -1 : 1) * (m_mirrorVertically ? -1 : 1),
+ 0 , 0
+ );
+ m_cachedMirroredPixmap = pixmap().transformed(transform);
+ } else {
+ //Cleanup cached pixmap if necessary
+ if (!m_cachedMirroredPixmap.isNull())
+ m_cachedMirroredPixmap = QPixmap();
+ }
+ m_cachedMirroredPixmapIsDirty = false;
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
index bfbe8420d2..5b5de86708 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode_p.h
@@ -92,7 +92,7 @@ public:
const QPixmap &pixmap() const;
private:
-
+ void updateCachedMirroredPixmap();
QRectF m_targetRect;
QRectF m_innerTargetRect;
QRectF m_innerSourceRect;