Renamed AbstractFontAtlas to AbstractAtlas
Former-commit-id: 2908a05a7d2d6d44e2e29e96c52cafe962382b71
This commit is contained in:
parent
e3de7e6f3c
commit
1781e93462
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ABSTRACTFONTATLAS_HPP
|
||||
#define NAZARA_ABSTRACTFONTATLAS_HPP
|
||||
#ifndef NAZARA_ABSTRACTATLAS_HPP
|
||||
#define NAZARA_ABSTRACTATLAS_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/SparsePtr.hpp>
|
||||
|
|
@ -15,13 +15,13 @@
|
|||
class NzAbstractImage;
|
||||
class NzImage;
|
||||
|
||||
class NAZARA_API NzAbstractFontAtlas
|
||||
class NAZARA_API NzAbstractAtlas
|
||||
{
|
||||
public:
|
||||
class Listener;
|
||||
|
||||
NzAbstractFontAtlas();
|
||||
virtual ~NzAbstractFontAtlas();
|
||||
NzAbstractAtlas();
|
||||
virtual ~NzAbstractAtlas();
|
||||
|
||||
void AddListener(Listener* font, void* userdata = nullptr) const;
|
||||
|
||||
|
|
@ -39,8 +39,8 @@ class NAZARA_API NzAbstractFontAtlas
|
|||
Listener() = default;
|
||||
virtual ~Listener();
|
||||
|
||||
virtual bool OnAtlasCleared(const NzAbstractFontAtlas* atlas, void* userdata);
|
||||
virtual void OnAtlasReleased(const NzAbstractFontAtlas* atlas, void* userdata);
|
||||
virtual bool OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata);
|
||||
virtual void OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata);
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
@ -51,4 +51,4 @@ class NAZARA_API NzAbstractFontAtlas
|
|||
bool m_listenersLocked;
|
||||
};
|
||||
|
||||
#endif // NAZARA_ABSTRACTFONTATLAS_HPP
|
||||
#endif // NAZARA_ABSTRACTATLAS_HPP
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Utility/AbstractFontAtlas.hpp>
|
||||
#include <Nazara/Utility/AbstractAtlas.hpp>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
|
|
@ -29,9 +29,8 @@ using NzFontConstRef = NzResourceRef<const NzFont>;
|
|||
using NzFontLoader = NzResourceLoader<NzFont, NzFontParams>;
|
||||
using NzFontRef = NzResourceRef<NzFont>;
|
||||
|
||||
class NAZARA_API NzFont : public NzResource, NzAbstractFontAtlas::Listener, NzNonCopyable
|
||||
class NAZARA_API NzFont : public NzResource, NzAbstractAtlas::Listener, NzNonCopyable
|
||||
{
|
||||
friend NzAbstractFontAtlas;
|
||||
friend NzFontLoader;
|
||||
|
||||
public:
|
||||
|
|
@ -51,7 +50,7 @@ class NAZARA_API NzFont : public NzResource, NzAbstractFontAtlas::Listener, NzNo
|
|||
|
||||
bool ExtractGlyph(unsigned int characterSize, char32_t character, nzUInt32 style, NzFontGlyph* glyph) const;
|
||||
|
||||
const NzAbstractFontAtlas* GetAtlas() const;
|
||||
const NzAbstractAtlas* GetAtlas() const;
|
||||
unsigned int GetCachedGlyphCount(unsigned int characterSize, nzUInt32 style) const;
|
||||
unsigned int GetCachedGlyphCount() const;
|
||||
NzString GetFamilyName() const;
|
||||
|
|
@ -72,7 +71,7 @@ class NAZARA_API NzFont : public NzResource, NzAbstractFontAtlas::Listener, NzNo
|
|||
bool OpenFromMemory(const void* data, std::size_t size, const NzFontParams& params = NzFontParams());
|
||||
bool OpenFromStream(NzInputStream& stream, const NzFontParams& params = NzFontParams());
|
||||
|
||||
void SetAtlas(std::shared_ptr<NzAbstractFontAtlas> atlas);
|
||||
void SetAtlas(std::shared_ptr<NzAbstractAtlas> atlas);
|
||||
void SetGlyphBorder(unsigned int borderSize);
|
||||
void SetMinimumStepSize(unsigned int minimumSizeStep);
|
||||
|
||||
|
|
@ -108,11 +107,11 @@ class NAZARA_API NzFont : public NzResource, NzAbstractFontAtlas::Listener, NzNo
|
|||
using GlyphMap = std::unordered_map<char32_t, Glyph>;
|
||||
|
||||
nzUInt64 ComputeKey(unsigned int characterSize, nzUInt32 style) const;
|
||||
bool OnAtlasCleared(const NzAbstractFontAtlas* atlas, void* userdata) override;
|
||||
void OnAtlasReleased(const NzAbstractFontAtlas* atlas, void* userdata) override;
|
||||
bool OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata) override;
|
||||
void OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata) override;
|
||||
const Glyph& PrecacheGlyph(GlyphMap& glyphMap, unsigned int characterSize, nzUInt32 style, char32_t character) const;
|
||||
|
||||
std::shared_ptr<NzAbstractFontAtlas> m_atlas;
|
||||
std::shared_ptr<NzAbstractAtlas> m_atlas;
|
||||
std::unique_ptr<NzFontData> m_data;
|
||||
mutable std::unordered_map<nzUInt64, std::unordered_map<nzUInt64, int>> m_kerningCache;
|
||||
mutable std::unordered_map<nzUInt64, GlyphMap> m_glyphes;
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/GuillotineBinPack.hpp>
|
||||
#include <Nazara/Utility/AbstractFontAtlas.hpp>
|
||||
#include <Nazara/Utility/AbstractAtlas.hpp>
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class NAZARA_API NzGuillotineImageAtlas : public NzAbstractFontAtlas
|
||||
class NAZARA_API NzGuillotineImageAtlas : public NzAbstractAtlas
|
||||
{
|
||||
public:
|
||||
NzGuillotineImageAtlas();
|
||||
|
|
|
|||
|
|
@ -2,35 +2,34 @@
|
|||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Utility/AbstractFontAtlas.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <Nazara/Utility/AbstractAtlas.hpp>
|
||||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
NzAbstractFontAtlas::NzAbstractFontAtlas() :
|
||||
NzAbstractAtlas::NzAbstractAtlas() :
|
||||
m_listenersLocked(false)
|
||||
{
|
||||
}
|
||||
|
||||
NzAbstractFontAtlas::~NzAbstractFontAtlas()
|
||||
NzAbstractAtlas::~NzAbstractAtlas()
|
||||
{
|
||||
m_listenersLocked = true;
|
||||
for (auto& pair : m_listeners)
|
||||
pair.first->OnAtlasReleased(this, pair.second);
|
||||
}
|
||||
|
||||
void NzAbstractFontAtlas::AddListener(Listener* listener, void* userdata) const
|
||||
void NzAbstractAtlas::AddListener(Listener* listener, void* userdata) const
|
||||
{
|
||||
if (!m_listenersLocked)
|
||||
m_listeners.insert(std::make_pair(listener, userdata));
|
||||
}
|
||||
|
||||
void NzAbstractFontAtlas::RemoveListener(Listener* listener) const
|
||||
void NzAbstractAtlas::RemoveListener(Listener* listener) const
|
||||
{
|
||||
if (!m_listenersLocked)
|
||||
m_listeners.erase(listener);
|
||||
}
|
||||
|
||||
void NzAbstractFontAtlas::NotifyCleared()
|
||||
void NzAbstractAtlas::NotifyCleared()
|
||||
{
|
||||
m_listenersLocked = true;
|
||||
|
||||
|
|
@ -46,9 +45,9 @@ void NzAbstractFontAtlas::NotifyCleared()
|
|||
m_listenersLocked = false;
|
||||
}
|
||||
|
||||
NzAbstractFontAtlas::Listener::~Listener() = default;
|
||||
NzAbstractAtlas::Listener::~Listener() = default;
|
||||
|
||||
bool NzAbstractFontAtlas::Listener::OnAtlasCleared(const NzAbstractFontAtlas* atlas, void* userdata)
|
||||
bool NzAbstractAtlas::Listener::OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata)
|
||||
{
|
||||
NazaraUnused(atlas);
|
||||
NazaraUnused(userdata);
|
||||
|
|
@ -56,7 +55,7 @@ bool NzAbstractFontAtlas::Listener::OnAtlasCleared(const NzAbstractFontAtlas* at
|
|||
return true;
|
||||
}
|
||||
|
||||
void NzAbstractFontAtlas::Listener::OnAtlasReleased(const NzAbstractFontAtlas* atlas, void* userdata)
|
||||
void NzAbstractAtlas::Listener::OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata)
|
||||
{
|
||||
NazaraUnused(atlas);
|
||||
NazaraUnused(userdata);
|
||||
|
|
@ -101,7 +101,7 @@ bool NzFont::ExtractGlyph(unsigned int characterSize, char32_t character, nzUInt
|
|||
return m_data->ExtractGlyph(characterSize, character, style, glyph);
|
||||
}
|
||||
|
||||
const NzAbstractFontAtlas* NzFont::GetAtlas() const
|
||||
const NzAbstractAtlas* NzFont::GetAtlas() const
|
||||
{
|
||||
return m_atlas.get();
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ bool NzFont::OpenFromStream(NzInputStream& stream, const NzFontParams& params)
|
|||
return NzFontLoader::LoadFromStream(this, stream, params);
|
||||
}
|
||||
|
||||
void NzFont::SetAtlas(std::shared_ptr<NzAbstractFontAtlas> atlas)
|
||||
void NzFont::SetAtlas(std::shared_ptr<NzAbstractAtlas> atlas)
|
||||
{
|
||||
ClearGlyphCache();
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ nzUInt64 NzFont::ComputeKey(unsigned int characterSize, nzUInt32 style) const
|
|||
return (stylePart << 32) | sizePart;
|
||||
}
|
||||
|
||||
bool NzFont::OnAtlasCleared(const NzAbstractFontAtlas* atlas, void* userdata)
|
||||
bool NzFont::OnAtlasCleared(const NzAbstractAtlas* atlas, void* userdata)
|
||||
{
|
||||
NazaraUnused(atlas);
|
||||
NazaraUnused(userdata);
|
||||
|
|
@ -335,7 +335,7 @@ bool NzFont::OnAtlasCleared(const NzAbstractFontAtlas* atlas, void* userdata)
|
|||
return true;
|
||||
}
|
||||
|
||||
void NzFont::OnAtlasReleased(const NzAbstractFontAtlas* atlas, void* userdata)
|
||||
void NzFont::OnAtlasReleased(const NzAbstractAtlas* atlas, void* userdata)
|
||||
{
|
||||
NazaraUnused(atlas);
|
||||
NazaraUnused(userdata);
|
||||
|
|
|
|||
Loading…
Reference in New Issue