aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/adaptations/software
diff options
context:
space:
mode:
authorAndy Nichols <[email protected]>2024-08-19 15:25:43 +0200
committerAndy Nichols <[email protected]>2024-08-22 21:35:38 +0200
commit29a52df82397fd8a00308f7e34b08059d6affc91 (patch)
tree662355efb0849100e74a5725a4db4e63f245f3c0 /src/quick/scenegraph/adaptations/software
parent643eefc5ae5ae124aec1ff21ecce406254ba7407 (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.8 6.7 6.5 5.15 Change-Id: I70f9f6d1dfd46d6870a2bee2ae72294e8982b776 Reviewed-by: Laszlo Agocs <[email protected]>
Diffstat (limited to 'src/quick/scenegraph/adaptations/software')
-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;