LibWeb: Implement draw_glyph_run in PaintingCommandExecutorGPU

This commit is contained in:
Aliaksandr Kalenik 2023-11-05 00:59:53 +01:00 committed by Andreas Kling
parent ee28ba0c93
commit b6da9abfb2
5 changed files with 31 additions and 2 deletions

View file

@ -48,6 +48,9 @@ public:
bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override;
bool needs_prepare_glyphs_texture() const override { return false; }
void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const&) override {};
PaintingCommandExecutorCPU(Gfx::Bitmap& bitmap);
private:

View file

@ -18,9 +18,9 @@ PaintingCommandExecutorGPU::~PaintingCommandExecutorGPU()
m_painter.flush();
}
CommandResult PaintingCommandExecutorGPU::draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const&, Color const&)
CommandResult PaintingCommandExecutorGPU::draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color)
{
// FIXME
painter().draw_glyph_run(glyph_run, color);
return CommandResult::Continue;
}
@ -238,4 +238,9 @@ bool PaintingCommandExecutorGPU::would_be_fully_clipped_by_painter(Gfx::IntRect)
return false;
}
void PaintingCommandExecutorGPU::prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_glyphs)
{
m_painter.prepare_glyph_texture(unique_glyphs);
}
}

View file

@ -50,6 +50,9 @@ public:
bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override;
virtual bool needs_prepare_glyphs_texture() const override { return true; }
void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const&) override;
PaintingCommandExecutorGPU(AccelGfx::Painter& painter);
~PaintingCommandExecutorGPU() override;

View file

@ -417,6 +417,21 @@ static Optional<Gfx::IntRect> command_bounding_rectangle(PaintingCommand const&
void RecordingPainter::execute(PaintingCommandExecutor& executor)
{
if (executor.needs_prepare_glyphs_texture()) {
HashMap<Gfx::Font const*, HashTable<u32>> unique_glyphs;
for (auto& command : m_painting_commands) {
if (command.has<DrawGlyphRun>()) {
for (auto const& glyph_or_emoji : command.get<DrawGlyphRun>().glyph_run) {
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
auto const& glyph = glyph_or_emoji.get<Gfx::DrawGlyph>();
unique_glyphs.ensure(glyph.font, [] { return HashTable<u32> {}; }).set(glyph.code_point);
}
}
}
}
executor.prepare_glyph_texture(unique_glyphs);
}
size_t next_command_index = 0;
while (next_command_index < m_painting_commands.size()) {
auto& command = m_painting_commands[next_command_index++];

View file

@ -376,6 +376,9 @@ public:
virtual CommandResult blit_corner_clipping(BorderRadiusCornerClipper&) = 0;
virtual bool would_be_fully_clipped_by_painter(Gfx::IntRect) const = 0;
virtual bool needs_prepare_glyphs_texture() const { return false; }
virtual void prepare_glyph_texture(HashMap<Gfx::Font const*, HashTable<u32>> const& unique_glyphs) = 0;
};
class RecordingPainter {