summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopengltextureglyphcache.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-02-14 01:26:25 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-02-15 20:14:27 +0000
commit04d6495bf773a6bb0d4fa6980df22d3b81a605b0 (patch)
tree3372ff44c12f502402f80704c058082d1d27257b /src/gui/opengl/qopengltextureglyphcache.cpp
parenta5febadac55741b4b48f25463a310835cc8bde19 (diff)
Make some atomic counters zero-based
A variable of static storage duration that is not zero-initialized takes up space in the DATA segment of the executable. By making the counters start at zero and adding the initial value afterwards, we move them over to the BSS segment, which does not take up space in the executable. Wrap atomics used across function boundaries into small functions, to avoid code duplication and to increase readability. Change-Id: Ida6ed316ecb8fe20da62a9577161349e14de5aed Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/opengl/qopengltextureglyphcache.cpp')
-rw-r--r--src/gui/opengl/qopengltextureglyphcache.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index 62b069a1d0..9a4527b4e6 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -47,7 +47,11 @@
QT_BEGIN_NAMESPACE
-QBasicAtomicInt qopengltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
+static int next_qopengltextureglyphcache_serial_number()
+{
+ static QBasicAtomicInt serial;
+ return 1 + serial.fetchAndAddRelaxed(1);
+}
QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix)
: QImageTextureGlyphCache(format, matrix)
@@ -55,7 +59,7 @@ QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat form
, pex(0)
, m_blitProgram(0)
, m_filterMode(Nearest)
- , m_serialNumber(qopengltextureglyphcache_serial_number.fetchAndAddRelaxed(1))
+ , m_serialNumber(next_qopengltextureglyphcache_serial_number())
, m_buffer(QOpenGLBuffer::VertexBuffer)
{
#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG