mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibGfx+LibAccelGfx+LibWeb: Use RefPtr for font in DrawGlyphOrEmoji
This commit is contained in:
parent
451df70275
commit
0d03257e69
Notes:
sideshowbarker
2024-07-17 09:49:33 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/0d03257e69 Pull-request: https://github.com/SerenityOS/serenity/pull/22236 Issue: https://github.com/SerenityOS/serenity/issues/21213
5 changed files with 11 additions and 11 deletions
|
@ -399,18 +399,18 @@ void Painter::draw_glyph_run(Span<Gfx::DrawGlyphOrEmoji const> glyph_run, Color
|
|||
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
|
||||
auto const& glyph = glyph_or_emoji.get<Gfx::DrawGlyph>();
|
||||
|
||||
auto const* font = glyph.font;
|
||||
auto const& font = *glyph.font;
|
||||
auto code_point = glyph.code_point;
|
||||
auto point = glyph.position;
|
||||
|
||||
auto maybe_texture_rect = glyph_atlas.get_glyph_rect(font, code_point);
|
||||
auto maybe_texture_rect = glyph_atlas.get_glyph_rect(&font, code_point);
|
||||
if (!maybe_texture_rect.has_value()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto texture_rect = to_texture_space(maybe_texture_rect.value().to_type<float>(), *glyph_atlas.texture().size);
|
||||
|
||||
auto glyph_position = point + Gfx::FloatPoint(font->glyph_left_bearing(code_point), 0);
|
||||
auto glyph_position = point + Gfx::FloatPoint(font.glyph_left_bearing(code_point), 0);
|
||||
auto glyph_size = maybe_texture_rect->size().to_type<float>();
|
||||
auto glyph_rect = transform().map(Gfx::FloatRect { glyph_position, glyph_size });
|
||||
auto rect_in_clip_space = to_clip_space(glyph_rect);
|
||||
|
|
|
@ -224,7 +224,7 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
|
|||
return DrawGlyph {
|
||||
.position = point,
|
||||
.code_point = code_point,
|
||||
.font = &font,
|
||||
.font = font,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
|
|||
return DrawEmoji {
|
||||
.position = point,
|
||||
.emoji = emoji,
|
||||
.font = &font,
|
||||
.font = font,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
|
|||
return DrawGlyph {
|
||||
.position = point,
|
||||
.code_point = code_point,
|
||||
.font = &font,
|
||||
.font = font,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
|
|||
return DrawGlyph {
|
||||
.position = point,
|
||||
.code_point = 0xFFFD,
|
||||
.font = &font,
|
||||
.font = font,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -78,13 +78,13 @@ enum class IncludeLeftBearing {
|
|||
struct DrawGlyph {
|
||||
FloatPoint position;
|
||||
u32 code_point;
|
||||
Font const* font;
|
||||
NonnullRefPtr<Font const> font;
|
||||
};
|
||||
|
||||
struct DrawEmoji {
|
||||
FloatPoint position;
|
||||
Gfx::Bitmap const* emoji;
|
||||
Font const* font;
|
||||
NonnullRefPtr<Font const> font;
|
||||
};
|
||||
|
||||
using DrawGlyphOrEmoji = Variant<DrawGlyph, DrawEmoji>;
|
||||
|
|
|
@ -643,7 +643,7 @@ static void paint_text_fragment(PaintContext& context, Layout::TextNode const& t
|
|||
scaled_glyph_run.ensure_capacity(fragment.glyph_run().size());
|
||||
for (auto glyph : fragment.glyph_run()) {
|
||||
glyph.visit([&](auto& glyph) {
|
||||
glyph.font = &scaled_font;
|
||||
glyph.font = scaled_font;
|
||||
glyph.position = glyph.position.scaled(context.device_pixels_per_css_pixel());
|
||||
});
|
||||
scaled_glyph_run.append(move(glyph));
|
||||
|
|
|
@ -593,7 +593,7 @@ void paint_text_shadow(PaintContext& context, Layout::LineBoxFragment const& fra
|
|||
scaled_glyph_run.ensure_capacity(fragment.glyph_run().size());
|
||||
for (auto glyph : fragment.glyph_run()) {
|
||||
glyph.visit([&](auto& glyph) {
|
||||
glyph.font = &scaled_font;
|
||||
glyph.font = scaled_font;
|
||||
glyph.position = glyph.position.scaled(context.device_pixels_per_css_pixel());
|
||||
});
|
||||
scaled_glyph_run.append(move(glyph));
|
||||
|
|
Loading…
Add table
Reference in a new issue