From 8b50a9f00f6f5b693d18c59ff15968e2b902ebf8 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 25 Jan 2013 21:00:15 -0600 Subject: Dereference the QImage once the corresponding texture is bound. We do not require a reference here, as the texture is only bound once. It is the texture factory that is reused (when QQuickWIndow::setPersistentSceneGraph(false) is set and the window is hidden and then re-exposed). With this patch it becomes trivial to create a custom QSGContextPlugin with a texture factory that does not retain the QImage, freeing up memory. This is useful in the case of an embedded system with only a single window that is never hidden or re-exposed. Change-Id: I1cfa6efc3a2e9e641b456bf90c55d563061757b8 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/util/qsgpainternode.cpp | 2 +- src/quick/scenegraph/util/qsgtexture.cpp | 3 +++ src/quick/scenegraph/util/qsgtexture_p.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/quick/scenegraph/util/qsgpainternode.cpp b/src/quick/scenegraph/util/qsgpainternode.cpp index 2d536ea547..a6b0c328e6 100644 --- a/src/quick/scenegraph/util/qsgpainternode.cpp +++ b/src/quick/scenegraph/util/qsgpainternode.cpp @@ -70,7 +70,7 @@ static inline int qt_next_power_of_two(int v) QSGPainterTexture::QSGPainterTexture() : QSGPlainTexture() { - + m_retain_image = true; } #ifdef QT_OPENGL_ES diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index c6a5672469..e06f075f1b 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -519,6 +519,7 @@ QSGPlainTexture::QSGPlainTexture() , m_dirty_bind_options(false) , m_owns_texture(true) , m_mipmaps_generated(false) + , m_retain_image(false) { } @@ -713,6 +714,8 @@ void QSGPlainTexture::bind() m_texture_rect = QRectF(0, 0, 1, 1); m_dirty_bind_options = false; + if (!m_retain_image) + m_image = QImage(); } diff --git a/src/quick/scenegraph/util/qsgtexture_p.h b/src/quick/scenegraph/util/qsgtexture_p.h index ed1d782c35..6430a93ed8 100644 --- a/src/quick/scenegraph/util/qsgtexture_p.h +++ b/src/quick/scenegraph/util/qsgtexture_p.h @@ -112,6 +112,7 @@ protected: uint m_dirty_bind_options : 1; uint m_owns_texture : 1; uint m_mipmaps_generated : 1; + uint m_retain_image: 1; }; QT_END_NAMESPACE -- cgit v1.2.3