mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibWeb: Keep harfbuzz hb_buffer instead of reallocating every time
Easy 1% speed-up on Speedometer 3.
This commit is contained in:
parent
5df3838a80
commit
ed5ad267c7
Notes:
github-actions[bot]
2025-04-18 23:15:00 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/ed5ad267c70 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4400
1 changed files with 3 additions and 4 deletions
|
@ -14,8 +14,7 @@ namespace Gfx {
|
|||
|
||||
RefPtr<GlyphRun> shape_text(FloatPoint baseline_start, float letter_spacing, Utf8View string, Gfx::Font const& font, GlyphRun::TextType text_type, ShapeFeatures const& features)
|
||||
{
|
||||
hb_buffer_t* buffer = hb_buffer_create();
|
||||
ScopeGuard destroy_buffer = [&]() { hb_buffer_destroy(buffer); };
|
||||
static hb_buffer_t* buffer = hb_buffer_create();
|
||||
hb_buffer_add_utf8(buffer, reinterpret_cast<char const*>(string.bytes()), string.byte_length(), 0, -1);
|
||||
hb_buffer_guess_segment_properties(buffer);
|
||||
|
||||
|
@ -60,9 +59,9 @@ RefPtr<GlyphRun> shape_text(FloatPoint baseline_start, float letter_spacing, Utf
|
|||
point.translate_by(letter_spacing, 0);
|
||||
}
|
||||
|
||||
auto run = adopt_ref(*new Gfx::GlyphRun(move(glyph_run), font, text_type, point.x()));
|
||||
hb_buffer_reset(buffer);
|
||||
|
||||
return adopt_ref(*new Gfx::GlyphRun(move(glyph_run), font, text_type, point.x()));
|
||||
return run;
|
||||
}
|
||||
|
||||
float measure_text_width(Utf8View const& string, Gfx::Font const& font, ShapeFeatures const& features)
|
||||
|
|
Loading…
Add table
Reference in a new issue