Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/rendering/StarFontTextureGroup.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-04 06:01:29 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-04 06:01:29 +1000
commita45d16b4ed2698361ff68c5502bcabfc908099a7 (patch)
tree58de4cdff77ed7d99ae354be711c7ec6843a058e /source/rendering/StarFontTextureGroup.cpp
parent1d04c689ba3e9d8bb3602a7289fe5756aa8fb3fd (diff)
Cache font directives
Diffstat (limited to 'source/rendering/StarFontTextureGroup.cpp')
-rw-r--r--source/rendering/StarFontTextureGroup.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/source/rendering/StarFontTextureGroup.cpp b/source/rendering/StarFontTextureGroup.cpp
index 6a33d32..a951358 100644
--- a/source/rendering/StarFontTextureGroup.cpp
+++ b/source/rendering/StarFontTextureGroup.cpp
@@ -39,23 +39,21 @@ void FontTextureGroup::clearFonts() {
m_font = m_defaultFont;
}
-const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Char c, unsigned size, String const& processingDirectives)
+const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Char c, unsigned size, Directives const* processingDirectives)
{
- auto res = m_glyphs.insert(GlyphDescriptor{c, size, processingDirectives, m_font.get() }, GlyphTexture());
+ auto res = m_glyphs.insert(GlyphDescriptor{c, size, processingDirectives ? processingDirectives->hash() : 0, m_font.get()}, GlyphTexture());
if (res.second) {
m_font->setPixelSize(size);
auto pair = m_font->render(c);
Image& image = pair.first;
- if (!processingDirectives.empty()) {
+ if (processingDirectives && *processingDirectives) {
try {
Vec2F preSize = Vec2F(image.size());
- auto imageOperations = parseImageOperations(processingDirectives);
- for (auto& imageOp : imageOperations) {
- if (auto border = imageOp.ptr<BorderImageOperation>())
- border->includeTransparent = true;
- }
- image = processImageOperations(imageOperations, image);
+
+ for (auto& entry : processingDirectives->shared->entries)
+ processImageOperation(entry.operation, image);
+
res.first->second.offset = (preSize - Vec2F(image.size())) / 2;
}
catch (StarException&) {
@@ -76,10 +74,10 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha
}
TexturePtr FontTextureGroup::glyphTexturePtr(String::Char c, unsigned size) {
- return glyphTexture(c, size, "").texture;
+ return glyphTexture(c, size, nullptr).texture;
}
-TexturePtr FontTextureGroup::glyphTexturePtr(String::Char c, unsigned size, String const& processingDirectives) {
+TexturePtr FontTextureGroup::glyphTexturePtr(String::Char c, unsigned size, Directives const* processingDirectives) {
return glyphTexture(c, size, processingDirectives).texture;
}