mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibGfx: Add int overloads for (AntiAliasing)Painter float methods
Without this change, the upcoming LibWeb pixel types will require a silly doubled conversion in some places. eg: `some_rect.to_type<int>().to_type<float>()` With these overloads, we can get away with `some_rect.to_type<int>()`.
This commit is contained in:
parent
d2334957ba
commit
83f31cb4a7
Notes:
sideshowbarker
2024-07-17 03:39:11 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/83f31cb4a7 Pull-request: https://github.com/SerenityOS/serenity/pull/16366 Reviewed-by: https://github.com/MacDue Reviewed-by: https://github.com/awesomekling ✅
|
@ -201,6 +201,11 @@ void AntiAliasingPainter::draw_dotted_line(IntPoint point1, IntPoint point2, Col
|
|||
}
|
||||
}
|
||||
|
||||
void AntiAliasingPainter::draw_line(IntPoint actual_from, IntPoint actual_to, Color color, float thickness, Painter::LineStyle style, Color alternate_color, LineLengthMode line_length_mode)
|
||||
{
|
||||
draw_line(actual_from.to_type<float>(), actual_to.to_type<float>(), color, thickness, style, alternate_color, line_length_mode);
|
||||
}
|
||||
|
||||
void AntiAliasingPainter::draw_line(FloatPoint actual_from, FloatPoint actual_to, Color color, float thickness, Painter::LineStyle style, Color alternate_color, LineLengthMode line_length_mode)
|
||||
{
|
||||
if (style == Painter::LineStyle::Dotted)
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
Distance
|
||||
};
|
||||
|
||||
void draw_line(IntPoint, IntPoint, Color, float thickness = 1, Painter::LineStyle style = Painter::LineStyle::Solid, Color alternate_color = Color::Transparent, LineLengthMode line_length_mode = LineLengthMode::PointToPoint);
|
||||
void draw_line(FloatPoint, FloatPoint, Color, float thickness = 1, Painter::LineStyle style = Painter::LineStyle::Solid, Color alternate_color = Color::Transparent, LineLengthMode line_length_mode = LineLengthMode::PointToPoint);
|
||||
void draw_line_for_path(FloatPoint, FloatPoint, Color, float thickness = 1, Painter::LineStyle style = Painter::LineStyle::Solid, Color alternate_color = Color::Transparent, LineLengthMode line_length_mode = LineLengthMode::PointToPoint);
|
||||
void draw_line_for_fill_path(FloatPoint from, FloatPoint to, Color color, float thickness = 1)
|
||||
|
|
|
@ -2446,6 +2446,11 @@ void Gfx::Painter::draw_ui_text(Gfx::IntRect const& rect, StringView text, Gfx::
|
|||
}
|
||||
}
|
||||
|
||||
void Painter::draw_text_run(IntPoint baseline_start, Utf8View const& string, Font const& font, Color color)
|
||||
{
|
||||
draw_text_run(baseline_start.to_type<float>(), string, font, color);
|
||||
}
|
||||
|
||||
void Painter::draw_text_run(FloatPoint baseline_start, Utf8View const& string, Font const& font, Color color)
|
||||
{
|
||||
auto pixel_metrics = font.pixel_metrics();
|
||||
|
@ -2471,7 +2476,7 @@ void Painter::draw_text_run(FloatPoint baseline_start, Utf8View const& string, F
|
|||
}
|
||||
}
|
||||
|
||||
void Painter::draw_scaled_bitmap_with_transform(Gfx::IntRect const& dst_rect, Gfx::Bitmap const& bitmap, Gfx::FloatRect const& src_rect, Gfx::AffineTransform const& transform, float opacity, Gfx::Painter::ScalingMode scaling_mode)
|
||||
void Painter::draw_scaled_bitmap_with_transform(IntRect const& dst_rect, Bitmap const& bitmap, FloatRect const& src_rect, AffineTransform const& transform, float opacity, Painter::ScalingMode scaling_mode)
|
||||
{
|
||||
if (transform.is_identity_or_translation()) {
|
||||
translate(transform.e(), transform.f());
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
void draw_circle_arc_intersecting(IntRect const&, IntPoint, int radius, Color, int thickness);
|
||||
|
||||
// Streamlined text drawing routine that does no wrapping/elision/alignment.
|
||||
void draw_text_run(IntPoint baseline_start, Utf8View const&, Font const&, Color);
|
||||
void draw_text_run(FloatPoint baseline_start, Utf8View const&, Font const&, Color);
|
||||
|
||||
enum class CornerOrientation {
|
||||
|
|
Loading…
Reference in a new issue