1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

Revert "LibWeb: Use box sampling instead of bilinear scaling when downscaling"

This reverts commit b79fd3d1a9.
This commit is contained in:
Andreas Kling 2023-05-19 13:33:52 +02:00
parent fb1a151fe3
commit 77db621be5
5 changed files with 6 additions and 13 deletions

View file

@ -185,14 +185,12 @@ struct BorderRadiusData {
}; };
// FIXME: Find a better place for this helper. // FIXME: Find a better place for this helper.
inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value, Gfx::IntRect source, Gfx::IntRect target) inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value)
{ {
switch (css_value) { switch (css_value) {
case CSS::ImageRendering::Auto: case CSS::ImageRendering::Auto:
case CSS::ImageRendering::HighQuality: case CSS::ImageRendering::HighQuality:
case CSS::ImageRendering::Smooth: case CSS::ImageRendering::Smooth:
if (target.width() < source.width() || target.height() < source.height())
return Gfx::Painter::ScalingMode::BoxSampling;
return Gfx::Painter::ScalingMode::BilinearBlend; return Gfx::Painter::ScalingMode::BilinearBlend;
case CSS::ImageRendering::CrispEdges: case CSS::ImageRendering::CrispEdges:
return Gfx::Painter::ScalingMode::NearestNeighbor; return Gfx::Painter::ScalingMode::NearestNeighbor;

View file

@ -102,10 +102,8 @@ Optional<CSSPixels> ImageStyleValue::natural_height() const
void ImageStyleValue::paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const void ImageStyleValue::paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering image_rendering) const
{ {
if (auto* b = bitmap(m_current_frame_index); b != nullptr) { if (auto* b = bitmap(m_current_frame_index); b != nullptr)
auto scaling_mode = to_gfx_scaling_mode(image_rendering, bitmap(0)->rect(), dest_rect.to_type<int>()); context.painter().draw_scaled_bitmap(dest_rect.to_type<int>(), *b, bitmap(0)->rect(), 1.0f, to_gfx_scaling_mode(image_rendering));
context.painter().draw_scaled_bitmap(dest_rect.to_type<int>(), *b, bitmap(0)->rect(), 1.f, scaling_mode);
}
} }
} }

View file

@ -41,8 +41,7 @@ void CanvasPaintable::paint(PaintContext& context, PaintPhase phase) const
if (layout_box().dom_node().bitmap()) { if (layout_box().dom_node().bitmap()) {
// FIXME: Remove this const_cast. // FIXME: Remove this const_cast.
const_cast<HTML::HTMLCanvasElement&>(layout_box().dom_node()).present(); const_cast<HTML::HTMLCanvasElement&>(layout_box().dom_node()).present();
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), layout_box().dom_node().bitmap()->rect(), canvas_rect.to_type<int>()); context.painter().draw_scaled_bitmap(canvas_rect.to_type<int>(), *layout_box().dom_node().bitmap(), layout_box().dom_node().bitmap()->rect(), 1.0f, to_gfx_scaling_mode(computed_values().image_rendering()));
context.painter().draw_scaled_bitmap(canvas_rect.to_type<int>(), *layout_box().dom_node().bitmap(), layout_box().dom_node().bitmap()->rect(), 1.0f, scaling_mode);
} }
} }
} }

View file

@ -64,8 +64,7 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const
} else if (auto bitmap = layout_box().image_provider().current_image_bitmap()) { } else if (auto bitmap = layout_box().image_provider().current_image_bitmap()) {
auto image_rect = context.rounded_device_rect(absolute_rect()); auto image_rect = context.rounded_device_rect(absolute_rect());
ScopedCornerRadiusClip corner_clip { context, context.painter(), image_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) }; ScopedCornerRadiusClip corner_clip { context, context.painter(), image_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), bitmap->rect(), image_rect.to_type<int>()); context.painter().draw_scaled_bitmap(image_rect.to_type<int>(), *bitmap, bitmap->rect(), 1.0f, to_gfx_scaling_mode(computed_values().image_rendering()));
context.painter().draw_scaled_bitmap(image_rect.to_type<int>(), *bitmap, bitmap->rect(), 1.f, scaling_mode);
} }
} }
} }

View file

@ -135,8 +135,7 @@ void VideoPaintable::paint(PaintContext& context, PaintPhase phase) const
} }
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>()); context.painter().draw_scaled_bitmap(video_rect.to_type<int>(), *frame, frame->rect(), 1.0f, to_gfx_scaling_mode(computed_values().image_rendering()));
context.painter().draw_scaled_bitmap(video_rect.to_type<int>(), *frame, frame->rect(), 1.f, scaling_mode);
}; };
auto paint_transparent_black = [&]() { auto paint_transparent_black = [&]() {