(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 enum ModicationCode
{ {
ModificationCode_AtlasChanged,
ModificationCode_GlyphCacheCleared, ModificationCode_GlyphCacheCleared,
ModificationCode_KerningCacheCleared, ModificationCode_KerningCacheCleared,
ModificationCode_SizeInfoCacheCleared ModificationCode_SizeInfoCacheCleared

View File

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