mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Pass sizes instead of rects to to_gfx_scaling_mode()
Position is irrelevant when determining the right scaling mode. No functional changes.
This commit is contained in:
parent
3f6cbeb87e
commit
d352c4673c
Notes:
github-actions[bot]
2025-11-12 15:00:11 +00:00
Author: https://github.com/gmta
Commit: d352c4673c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6792
Reviewed-by: https://github.com/kalenikaliaksandr ✅
7 changed files with 11 additions and 10 deletions
|
|
@ -453,9 +453,9 @@ struct TextDecorationThickness {
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Find a better place for this helper.
|
// FIXME: Find a better place for this helper.
|
||||||
inline Gfx::ScalingMode to_gfx_scaling_mode(ImageRendering css_value, Gfx::IntRect source, Gfx::IntRect target)
|
inline Gfx::ScalingMode to_gfx_scaling_mode(ImageRendering css_value, Gfx::IntSize source, Gfx::IntSize target)
|
||||||
{
|
{
|
||||||
if (source.size() == target.size())
|
if (source == target)
|
||||||
return Gfx::ScalingMode::None;
|
return Gfx::ScalingMode::None;
|
||||||
|
|
||||||
switch (css_value) {
|
switch (css_value) {
|
||||||
|
|
|
||||||
|
|
@ -156,9 +156,9 @@ void ImageStyleValue::paint(DisplayListRecordingContext& context, DevicePixelRec
|
||||||
if (!image_data)
|
if (!image_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto rect = image_data->frame_rect(m_current_frame_index).value_or(dest_rect.to_type<int>());
|
|
||||||
auto scaling_mode = to_gfx_scaling_mode(image_rendering, rect, dest_rect.to_type<int>());
|
|
||||||
auto dest_int_rect = dest_rect.to_type<int>();
|
auto dest_int_rect = dest_rect.to_type<int>();
|
||||||
|
auto rect = image_data->frame_rect(m_current_frame_index).value_or(dest_int_rect);
|
||||||
|
auto scaling_mode = to_gfx_scaling_mode(image_rendering, rect.size(), dest_int_rect.size());
|
||||||
image_data->paint(context, m_current_frame_index, dest_int_rect, dest_int_rect, scaling_mode);
|
image_data->paint(context, m_current_frame_index, dest_int_rect, dest_int_rect, scaling_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ void paint_background(DisplayListRecordingContext& context, PaintableBox const&
|
||||||
dest_rect.set_height(1);
|
dest_rect.set_height(1);
|
||||||
|
|
||||||
auto const* bitmap = static_cast<CSS::ImageStyleValue const&>(image).current_frame_bitmap(dest_rect);
|
auto const* bitmap = static_cast<CSS::ImageStyleValue const&>(image).current_frame_bitmap(dest_rect);
|
||||||
auto scaling_mode = to_gfx_scaling_mode(image_rendering, bitmap->rect(), dest_rect.to_type<int>());
|
auto scaling_mode = to_gfx_scaling_mode(image_rendering, bitmap->size(), dest_rect.size().to_type<int>());
|
||||||
context.display_list_recorder().draw_repeated_immutable_bitmap(dest_rect.to_type<int>(), clip_rect.to_type<int>(), *bitmap, scaling_mode, repeat_x, repeat_y);
|
context.display_list_recorder().draw_repeated_immutable_bitmap(dest_rect.to_type<int>(), clip_rect.to_type<int>(), *bitmap, scaling_mode, repeat_x, repeat_y);
|
||||||
} else {
|
} else {
|
||||||
for_each_image_device_rect([&](auto const& image_device_rect) {
|
for_each_image_device_rect([&](auto const& image_device_rect) {
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,9 @@ void CanvasPaintable::paint(DisplayListRecordingContext& context, PaintPhase pha
|
||||||
if (auto surface = canvas_element.surface()) {
|
if (auto surface = canvas_element.surface()) {
|
||||||
// FIXME: Remove this const_cast.
|
// FIXME: Remove this const_cast.
|
||||||
const_cast<HTML::HTMLCanvasElement&>(canvas_element).present();
|
const_cast<HTML::HTMLCanvasElement&>(canvas_element).present();
|
||||||
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), surface->rect(), canvas_rect.to_type<int>());
|
auto canvas_int_rect = canvas_rect.to_type<int>();
|
||||||
context.display_list_recorder().draw_painting_surface(canvas_rect.to_type<int>(), *surface, surface->rect(), scaling_mode);
|
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), surface->size(), canvas_int_rect.size());
|
||||||
|
context.display_list_recorder().draw_painting_surface(canvas_int_rect, *surface, surface->rect(), scaling_mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ void ImagePaintable::paint(DisplayListRecordingContext& context, PaintPhase phas
|
||||||
ScopedCornerRadiusClip corner_clip { context, image_rect_device_pixels, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
|
ScopedCornerRadiusClip corner_clip { context, image_rect_device_pixels, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
|
||||||
auto image_int_rect_device_pixels = image_rect_device_pixels.to_type<int>();
|
auto image_int_rect_device_pixels = image_rect_device_pixels.to_type<int>();
|
||||||
auto bitmap_rect = decoded_image_data->frame_rect(m_image_provider.current_frame_index()).value_or(image_int_rect_device_pixels);
|
auto bitmap_rect = decoded_image_data->frame_rect(m_image_provider.current_frame_index()).value_or(image_int_rect_device_pixels);
|
||||||
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), bitmap_rect, image_int_rect_device_pixels);
|
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), bitmap_rect.size(), image_int_rect_device_pixels.size());
|
||||||
auto bitmap_aspect_ratio = (float)bitmap_rect.height() / bitmap_rect.width();
|
auto bitmap_aspect_ratio = (float)bitmap_rect.height() / bitmap_rect.width();
|
||||||
auto image_aspect_ratio = (float)image_rect.height() / (float)image_rect.width();
|
auto image_aspect_ratio = (float)image_rect.height() / (float)image_rect.width();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,8 +127,8 @@ void VideoPaintable::paint(DisplayListRecordingContext& context, PaintPhase phas
|
||||||
}();
|
}();
|
||||||
|
|
||||||
auto paint_frame = [&](auto const& frame) {
|
auto paint_frame = [&](auto const& frame) {
|
||||||
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), frame->rect(), video_rect.to_type<int>());
|
|
||||||
auto dst_rect = video_rect.to_type<int>();
|
auto dst_rect = video_rect.to_type<int>();
|
||||||
|
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), frame->rect().size(), dst_rect.size());
|
||||||
context.display_list_recorder().draw_scaled_immutable_bitmap(dst_rect, dst_rect, Gfx::ImmutableBitmap::create(*frame), scaling_mode);
|
context.display_list_recorder().draw_scaled_immutable_bitmap(dst_rect, dst_rect, Gfx::ImmutableBitmap::create(*frame), scaling_mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ Optional<Gfx::Filter> SVGFilterElement::gfx_filter(Layout::NodeWithStyle const&
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
|
|
||||||
auto dest_rect = Gfx::enclosing_int_rect(paintable_box->absolute_rect().to_type<float>());
|
auto dest_rect = Gfx::enclosing_int_rect(paintable_box->absolute_rect().to_type<float>());
|
||||||
auto scaling_mode = CSS::to_gfx_scaling_mode(paintable_box->computed_values().image_rendering(), *src_rect, dest_rect);
|
auto scaling_mode = CSS::to_gfx_scaling_mode(paintable_box->computed_values().image_rendering(), src_rect->size(), dest_rect.size());
|
||||||
root_filter = Gfx::Filter::image(*bitmap, *src_rect, dest_rect, scaling_mode);
|
root_filter = Gfx::Filter::image(*bitmap, *src_rect, dest_rect, scaling_mode);
|
||||||
update_result_map(*image_primitive);
|
update_result_map(*image_primitive);
|
||||||
} else if (auto* merge_primitive = as_if<SVGFEMergeElement>(node)) {
|
} else if (auto* merge_primitive = as_if<SVGFEMergeElement>(node)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue