(Font) Added notification on atlas change

Will only clear glyphes when setting differents parameters


Former-commit-id: b16a289742c0f23fa5066d3c52ce35b4abc626c6
This commit is contained in:
Lynix 2015-01-16 18:57:09 +01:00
parent cd5399459d
commit 77347c8582
2 changed files with 22 additions and 10 deletions

View File

@ -79,6 +79,7 @@ class NAZARA_API NzFont : public NzResource, NzAbstractAtlas::Listener, NzNonCop
enum ModicationCode
{
ModificationCode_AtlasChanged,
ModificationCode_GlyphCacheCleared,
ModificationCode_KerningCacheCleared,
ModificationCode_SizeInfoCacheCleared

View File

@ -276,20 +276,28 @@ bool NzFont::OpenFromStream(NzInputStream& stream, const NzFontParams& params)
void NzFont::SetAtlas(std::shared_ptr<NzAbstractAtlas> atlas)
{
ClearGlyphCache();
if (m_atlas != atlas)
{
ClearGlyphCache();
if (m_atlas)
m_atlas->RemoveListener(this);
if (m_atlas)
m_atlas->RemoveListener(this);
m_atlas = atlas;
if (m_atlas)
m_atlas->AddListener(this);
m_atlas = atlas;
if (m_atlas)
m_atlas->AddListener(this);
NotifyModified(ModificationCode_AtlasChanged);
}
}
void NzFont::SetGlyphBorder(unsigned int borderSize)
{
m_glyphBorder = borderSize;
ClearGlyphCache();
if (m_glyphBorder != borderSize)
{
m_glyphBorder = borderSize;
ClearGlyphCache();
}
}
void NzFont::SetMinimumStepSize(unsigned int minimumStepSize)
@ -302,8 +310,11 @@ void NzFont::SetMinimumStepSize(unsigned int minimumStepSize)
}
#endif
m_minimumSizeStep = minimumStepSize;
ClearGlyphCache();
if (m_minimumSizeStep != minimumStepSize)
{
m_minimumSizeStep = minimumStepSize;
ClearGlyphCache();
}
}
nzUInt64 NzFont::ComputeKey(unsigned int characterSize, nzUInt32 style) const