mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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
@ -399,18 +399,18 @@ void Painter::draw_glyph_run(Span<Gfx::DrawGlyphOrEmoji const> glyph_run, Color
|
|||||||
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
|
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
|
||||||
auto const& glyph = glyph_or_emoji.get<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 code_point = glyph.code_point;
|
||||||
auto point = glyph.position;
|
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()) {
|
if (!maybe_texture_rect.has_value()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto texture_rect = to_texture_space(maybe_texture_rect.value().to_type<float>(), *glyph_atlas.texture().size);
|
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_size = maybe_texture_rect->size().to_type<float>();
|
||||||
auto glyph_rect = transform().map(Gfx::FloatRect { glyph_position, glyph_size });
|
auto glyph_rect = transform().map(Gfx::FloatRect { glyph_position, glyph_size });
|
||||||
auto rect_in_clip_space = to_clip_space(glyph_rect);
|
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 {
|
return DrawGlyph {
|
||||||
.position = point,
|
.position = point,
|
||||||
.code_point = code_point,
|
.code_point = code_point,
|
||||||
.font = &font,
|
.font = font,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
|
|||||||
return DrawEmoji {
|
return DrawEmoji {
|
||||||
.position = point,
|
.position = point,
|
||||||
.emoji = emoji,
|
.emoji = emoji,
|
||||||
.font = &font,
|
.font = font,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
|
|||||||
return DrawGlyph {
|
return DrawGlyph {
|
||||||
.position = point,
|
.position = point,
|
||||||
.code_point = code_point,
|
.code_point = code_point,
|
||||||
.font = &font,
|
.font = font,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ DrawGlyphOrEmoji prepare_draw_glyph_or_emoji(FloatPoint point, Utf8CodePointIter
|
|||||||
return DrawGlyph {
|
return DrawGlyph {
|
||||||
.position = point,
|
.position = point,
|
||||||
.code_point = 0xFFFD,
|
.code_point = 0xFFFD,
|
||||||
.font = &font,
|
.font = font,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,13 +78,13 @@ enum class IncludeLeftBearing {
|
|||||||
struct DrawGlyph {
|
struct DrawGlyph {
|
||||||
FloatPoint position;
|
FloatPoint position;
|
||||||
u32 code_point;
|
u32 code_point;
|
||||||
Font const* font;
|
NonnullRefPtr<Font const> font;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DrawEmoji {
|
struct DrawEmoji {
|
||||||
FloatPoint position;
|
FloatPoint position;
|
||||||
Gfx::Bitmap const* emoji;
|
Gfx::Bitmap const* emoji;
|
||||||
Font const* font;
|
NonnullRefPtr<Font const> font;
|
||||||
};
|
};
|
||||||
|
|
||||||
using DrawGlyphOrEmoji = Variant<DrawGlyph, DrawEmoji>;
|
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());
|
scaled_glyph_run.ensure_capacity(fragment.glyph_run().size());
|
||||||
for (auto glyph : fragment.glyph_run()) {
|
for (auto glyph : fragment.glyph_run()) {
|
||||||
glyph.visit([&](auto& glyph) {
|
glyph.visit([&](auto& glyph) {
|
||||||
glyph.font = &scaled_font;
|
glyph.font = scaled_font;
|
||||||
glyph.position = glyph.position.scaled(context.device_pixels_per_css_pixel());
|
glyph.position = glyph.position.scaled(context.device_pixels_per_css_pixel());
|
||||||
});
|
});
|
||||||
scaled_glyph_run.append(move(glyph));
|
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());
|
scaled_glyph_run.ensure_capacity(fragment.glyph_run().size());
|
||||||
for (auto glyph : fragment.glyph_run()) {
|
for (auto glyph : fragment.glyph_run()) {
|
||||||
glyph.visit([&](auto& glyph) {
|
glyph.visit([&](auto& glyph) {
|
||||||
glyph.font = &scaled_font;
|
glyph.font = scaled_font;
|
||||||
glyph.position = glyph.position.scaled(context.device_pixels_per_css_pixel());
|
glyph.position = glyph.position.scaled(context.device_pixels_per_css_pixel());
|
||||||
});
|
});
|
||||||
scaled_glyph_run.append(move(glyph));
|
scaled_glyph_run.append(move(glyph));
|
||||||
|
Loading…
Reference in New Issue
Block a user