diff options
author | Michael Brasser <mbrasser@ford.com> | 2016-03-22 07:24:47 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2016-04-19 22:33:16 +0000 |
commit | 26ff8f9029107877bfbfdc2f099f9b11861183ed (patch) | |
tree | 8095a8161dbe9abaa2011eaa0d65aa0d3ba1e1f5 /src/quick/scenegraph/util/qsgatlastexture.cpp | |
parent | e1400b5b4d8311769ad3b9f631479ee2b0271197 (diff) |
Allow more control over memory/speed tradeoff in the atlas.
QSG_ATLAS_TRANSIENT_IMAGE_THRESHOLD can be used to define a threshold
for retaining the QImage associated with an atlas texture. This gives
more control to the developer on platforms where removing a texture
from the atlas (e.g. for use in a ShaderEffect) can be prohibitively
expensive.
Change-Id: I13fd01ebbe94dd960fdcb3ee20b4ff40dcc5694f
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/scenegraph/util/qsgatlastexture.cpp')
-rw-r--r-- | src/quick/scenegraph/util/qsgatlastexture.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/quick/scenegraph/util/qsgatlastexture.cpp b/src/quick/scenegraph/util/qsgatlastexture.cpp index 8e8e870505..832510148c 100644 --- a/src/quick/scenegraph/util/qsgatlastexture.cpp +++ b/src/quick/scenegraph/util/qsgatlastexture.cpp @@ -121,6 +121,7 @@ Atlas::Atlas(const QSize &size) : m_allocator(size) , m_texture_id(0) , m_size(size) + , m_atlas_transient_image_threshold(0) , m_allocated(false) { @@ -170,6 +171,11 @@ Atlas::Atlas(const QSize &size) m_use_bgra_fallback = qEnvironmentVariableIsSet("QSG_ATLAS_USE_BGRA_FALLBACK"); m_debug_overlay = qEnvironmentVariableIsSet("QSG_ATLAS_OVERLAY"); + + // images smaller than this will retain their QImage. + // by default no images are retained (favoring memory) + // set to a very large value to retain all images (allowing quick removal from the atlas) + m_atlas_transient_image_threshold = qt_sg_envInt("QSG_ATLAS_TRANSIENT_IMAGE_THRESHOLD", 0); } Atlas::~Atlas() @@ -392,7 +398,10 @@ void Atlas::bind(QSGTexture::Filtering filtering) } else { upload(t); } - t->releaseImage(); + const QSize textureSize = t->textureSize(); + if (textureSize.width() > m_atlas_transient_image_threshold || + textureSize.height() > m_atlas_transient_image_threshold) + t->releaseImage(); qCDebug(QSG_LOG_TIME_TEXTURE).nospace() << "atlastexture uploaded in: " << qsg_renderer_timer.elapsed() << "ms (" << t->textureSize().width() << "x" |