1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:37:35 +00:00

LibGfx+LibWeb: Use ref-counted object to store glyph run

...to avoid allocating a copy of glyph run for painting commands. We
can't simply save pointers to a glyph run in layout/paintable tree
because it should be safe to deallocate layout and paintable trees
after painting commands are recorded, if in the future we decide to
move command execution to a separate thread.
This commit is contained in:
Aliaksandr Kalenik 2024-03-01 16:37:44 +01:00 committed by Andreas Kling
parent cf6999f5f3
commit 06c176bbfb
9 changed files with 32 additions and 15 deletions

View file

@ -100,6 +100,23 @@ struct DrawEmoji {
using DrawGlyphOrEmoji = Variant<DrawGlyph, DrawEmoji>;
class GlyphRun : public RefCounted<GlyphRun> {
public:
GlyphRun() = default;
GlyphRun(Vector<Gfx::DrawGlyphOrEmoji>&& glyphs)
: m_glyphs(move(glyphs))
{
}
[[nodiscard]] Vector<Gfx::DrawGlyphOrEmoji> const& glyphs() const { return m_glyphs; }
[[nodiscard]] bool is_empty() const { return m_glyphs.is_empty(); }
void append(Gfx::DrawGlyphOrEmoji glyph) { m_glyphs.append(glyph); }
private:
Vector<Gfx::DrawGlyphOrEmoji> m_glyphs;
};
Variant<DrawGlyph, DrawEmoji> prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIterator& it, Font const& font);
template<typename Callback>