diff --git a/core/src/text/fontContext.cpp b/core/src/text/fontContext.cpp index 540fe63889..d8608cba42 100644 --- a/core/src/text/fontContext.cpp +++ b/core/src/text/fontContext.cpp @@ -98,13 +98,7 @@ void FontContext::releaseAtlas(std::bitset _refs) { if (!_refs.any()) { return; } std::lock_guard lock(m_textureMutex); for (size_t i = 0; i < m_textures.size(); i++) { - if (!_refs[i]) { continue; } - - if (--m_atlasRefCount[i] == 0) { - LOGD("CLEAR ATLAS %d", i); - m_atlas.clear(i); - m_textures[i].texData.assign(GlyphTexture::size * GlyphTexture::size, 0); - } + if (_refs[i]) { m_atlasRefCount[i] -= 1; } } } @@ -216,7 +210,6 @@ bool FontContext::layoutText(TextStyle::Parameters& _params, const std::string& glm::vec2 offset((metrics.aabb.x + width * 0.5) * TextVertex::position_scale, (metrics.aabb.y + height * 0.5) * TextVertex::position_scale); - { std::lock_guard lock(m_textureMutex); for (; it != _quads.end(); ++it) { @@ -231,6 +224,15 @@ bool FontContext::layoutText(TextStyle::Parameters& _params, const std::string& it->quad[2].pos -= offset; it->quad[3].pos -= offset; } + + // Clear unused textures + for (size_t i = 0; i < m_textures.size(); i++) { + if (m_atlasRefCount[i] == 0) { + m_atlas.clear(i); + m_textures[i].texData.assign(GlyphTexture::size * + GlyphTexture::size, 0); + } + } } return true;