From 57264a56501baec1e122f67cb66d8c36ceca391c Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 22 Apr 2019 17:05:15 +0200 Subject: [PATCH] SimpleTextDrawer: Don't regenerate glyphs on outline color update --- src/Nazara/Utility/SimpleTextDrawer.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index 17c2a9b6d..86ba50764 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -177,7 +177,7 @@ namespace Nz { m_outlineColor = color; - m_glyphUpdated = false; + m_colorUpdated = false; } void SimpleTextDrawer::SetOutlineThickness(float thickness) @@ -430,7 +430,7 @@ namespace Nz } m_lines.back().bounds.ExtendTo(glyph.bounds); - + switch (character) { case '\n': @@ -515,8 +515,22 @@ namespace Nz void SimpleTextDrawer::UpdateGlyphColor() const { - for (Glyph& glyph : m_glyphs) - glyph.color = m_color; + if (m_outlineThickness > 0.f) + { + for (std::size_t glyphIndex = 0; glyphIndex < m_glyphs.size(); ++glyphIndex) + { + Glyph& glyph = m_glyphs[glyphIndex]; + if (glyphIndex % 2 == 0) + glyph.color = m_outlineColor; + else + glyph.color = m_color; + } + } + else + { + for (Glyph& glyph : m_glyphs) + glyph.color = m_color; + } m_colorUpdated = true; }