mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
LibWeb: Use box sampling instead of bilinear scaling when downscaling
As a heuristic, either the width or height of the scaled image should decrease for box sampling to be used. Otherwise, we use bilinear scaling.
This commit is contained in:
parent
81b30ec372
commit
b79fd3d1a9
5 changed files with 13 additions and 6 deletions
|
@ -41,7 +41,8 @@ void CanvasPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
if (layout_box().dom_node().bitmap()) {
|
||||
// FIXME: Remove this const_cast.
|
||||
const_cast<HTML::HTMLCanvasElement&>(layout_box().dom_node()).present();
|
||||
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()));
|
||||
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, scaling_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
} else if (auto bitmap = layout_box().image_provider().current_image_bitmap()) {
|
||||
auto image_rect = context.rounded_device_rect(absolute_rect());
|
||||
ScopedCornerRadiusClip corner_clip { context, context.painter(), image_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) };
|
||||
context.painter().draw_scaled_bitmap(image_rect.to_type<int>(), *bitmap, bitmap->rect(), 1.0f, to_gfx_scaling_mode(computed_values().image_rendering()));
|
||||
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.f, scaling_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,8 @@ void VideoPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
}
|
||||
|
||||
auto paint_frame = [&](auto const& frame) {
|
||||
context.painter().draw_scaled_bitmap(video_rect.to_type<int>(), *frame, frame->rect(), 1.0f, to_gfx_scaling_mode(computed_values().image_rendering()));
|
||||
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.f, scaling_mode);
|
||||
};
|
||||
|
||||
auto paint_transparent_black = [&]() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue