From d7f2ecbc67337f67d497e01271c919766f202614 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 13 Jul 2021 20:11:15 +0200 Subject: Fix QQuickPaintedItem performance and memory usage Keep the existing QSGPainterTexture (QSGPlainTexture). This is what Qt 5 would do as well. Otherwise we silently get lots of unnecessary releasing and creating graphics resources underneath. Fixes: QTBUG-95132 Change-Id: I88e839793fedd8f2c6d00cd76cd9a653731865f4 Reviewed-by: Jonas Karlsson Reviewed-by: Eirik Aavitsland (cherry picked from commit 146f8cbf865e0061859dd9f1c7a477db91298052) Reviewed-by: Qt Cherry-pick Bot --- src/quick/scenegraph/util/qsgdefaultpainternode.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp index d97d48c78d..fc1b3aec24 100644 --- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp +++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp @@ -206,13 +206,11 @@ void QSGDefaultPainterNode::updateRenderTarget() m_image = QImage(m_textureSize, QImage::Format_ARGB32_Premultiplied); m_image.fill(Qt::transparent); - QSGPainterTexture *texture = new QSGPainterTexture; - texture->setOwnsTexture(true); - texture->setTextureSize(m_textureSize); - if (m_texture) - delete m_texture; - - m_texture = texture; + if (!m_texture) { + m_texture = new QSGPainterTexture; + m_texture->setOwnsTexture(true); + } + m_texture->setTextureSize(m_textureSize); } void QSGDefaultPainterNode::setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) -- cgit v1.2.3