diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-07-13 20:11:15 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-30 08:29:04 +0000 |
commit | d7f2ecbc67337f67d497e01271c919766f202614 (patch) | |
tree | 09d997192107b8bdebc545a0cd9c4dcd7063fd1b | |
parent | 76e7ed49818f849a7c2f9c61dd3d88697bf7b7d0 (diff) |
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 <jonas.karlsson@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 146f8cbf865e0061859dd9f1c7a477db91298052)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quick/scenegraph/util/qsgdefaultpainternode.cpp | 12 |
1 files 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) |