diff --git a/Libraries/LibWeb/CSS/ComputedValues.h b/Libraries/LibWeb/CSS/ComputedValues.h index a666ef5c6db..b1f8c5f45dc 100644 --- a/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Libraries/LibWeb/CSS/ComputedValues.h @@ -453,9 +453,9 @@ struct TextDecorationThickness { }; // 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; switch (css_value) { diff --git a/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp index 5dac7a86289..e2cb897f327 100644 --- a/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp @@ -156,9 +156,9 @@ void ImageStyleValue::paint(DisplayListRecordingContext& context, DevicePixelRec if (!image_data) return; - auto rect = image_data->frame_rect(m_current_frame_index).value_or(dest_rect.to_type()); - auto scaling_mode = to_gfx_scaling_mode(image_rendering, rect, dest_rect.to_type()); auto dest_int_rect = dest_rect.to_type(); + 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); } diff --git a/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Libraries/LibWeb/Painting/BackgroundPainting.cpp index 8ff4c19267e..2dae07d77a4 100644 --- a/Libraries/LibWeb/Painting/BackgroundPainting.cpp +++ b/Libraries/LibWeb/Painting/BackgroundPainting.cpp @@ -322,7 +322,7 @@ void paint_background(DisplayListRecordingContext& context, PaintableBox const& dest_rect.set_height(1); auto const* bitmap = static_cast(image).current_frame_bitmap(dest_rect); - auto scaling_mode = to_gfx_scaling_mode(image_rendering, bitmap->rect(), dest_rect.to_type()); + auto scaling_mode = to_gfx_scaling_mode(image_rendering, bitmap->size(), dest_rect.size().to_type()); context.display_list_recorder().draw_repeated_immutable_bitmap(dest_rect.to_type(), clip_rect.to_type(), *bitmap, scaling_mode, repeat_x, repeat_y); } else { for_each_image_device_rect([&](auto const& image_device_rect) { diff --git a/Libraries/LibWeb/Painting/CanvasPaintable.cpp b/Libraries/LibWeb/Painting/CanvasPaintable.cpp index 5e6a529d7de..e1301573a68 100644 --- a/Libraries/LibWeb/Painting/CanvasPaintable.cpp +++ b/Libraries/LibWeb/Painting/CanvasPaintable.cpp @@ -36,8 +36,9 @@ void CanvasPaintable::paint(DisplayListRecordingContext& context, PaintPhase pha if (auto surface = canvas_element.surface()) { // FIXME: Remove this const_cast. const_cast(canvas_element).present(); - auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), surface->rect(), canvas_rect.to_type()); - context.display_list_recorder().draw_painting_surface(canvas_rect.to_type(), *surface, surface->rect(), scaling_mode); + auto canvas_int_rect = canvas_rect.to_type(); + 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); } } } diff --git a/Libraries/LibWeb/Painting/ImagePaintable.cpp b/Libraries/LibWeb/Painting/ImagePaintable.cpp index 3009552d01a..7784f865c4e 100644 --- a/Libraries/LibWeb/Painting/ImagePaintable.cpp +++ b/Libraries/LibWeb/Painting/ImagePaintable.cpp @@ -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) }; auto image_int_rect_device_pixels = image_rect_device_pixels.to_type(); 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 image_aspect_ratio = (float)image_rect.height() / (float)image_rect.width(); diff --git a/Libraries/LibWeb/Painting/VideoPaintable.cpp b/Libraries/LibWeb/Painting/VideoPaintable.cpp index 0a4ce06ae5e..2cdad135cb0 100644 --- a/Libraries/LibWeb/Painting/VideoPaintable.cpp +++ b/Libraries/LibWeb/Painting/VideoPaintable.cpp @@ -127,8 +127,8 @@ void VideoPaintable::paint(DisplayListRecordingContext& context, PaintPhase phas }(); auto paint_frame = [&](auto const& frame) { - auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), frame->rect(), video_rect.to_type()); auto dst_rect = video_rect.to_type(); + 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); }; diff --git a/Libraries/LibWeb/SVG/SVGFilterElement.cpp b/Libraries/LibWeb/SVG/SVGFilterElement.cpp index bb8dd394b30..339a49ed0cd 100644 --- a/Libraries/LibWeb/SVG/SVGFilterElement.cpp +++ b/Libraries/LibWeb/SVG/SVGFilterElement.cpp @@ -272,7 +272,7 @@ Optional SVGFilterElement::gfx_filter(Layout::NodeWithStyle const& return IterationDecision::Continue; auto dest_rect = Gfx::enclosing_int_rect(paintable_box->absolute_rect().to_type()); - 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); update_result_map(*image_primitive); } else if (auto* merge_primitive = as_if(node)) {