mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 10:09:14 +00:00
LibWeb: Add support for CSS image-rendering property
Currently only "auto" and "pixelated" values are supported.
This commit is contained in:
parent
246b42b635
commit
3e1c1c0b16
Notes:
sideshowbarker
2024-07-17 18:32:59 +09:00
Author: https://github.com/sppmacd
Commit: 3e1c1c0b16
Pull-request: https://github.com/SerenityOS/serenity/pull/12620
Reviewed-by: https://github.com/AtkinsSJ ✅
11 changed files with 73 additions and 1 deletions
|
@ -7,6 +7,8 @@
|
|||
#include <LibGfx/FontDatabase.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/StylePainter.h>
|
||||
#include <LibWeb/CSS/StyleValue.h>
|
||||
#include <LibWeb/CSS/ValueID.h>
|
||||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/Layout/ImageBox.h>
|
||||
|
||||
|
@ -91,7 +93,9 @@ void ImageBox::paint(PaintContext& context, PaintPhase phase)
|
|||
alt = image_element.src();
|
||||
context.painter().draw_text(enclosing_int_rect(absolute_rect()), alt, Gfx::TextAlignment::Center, computed_values().color(), Gfx::TextElision::Right);
|
||||
} else if (auto bitmap = m_image_loader.bitmap(m_image_loader.current_frame_index())) {
|
||||
context.painter().draw_scaled_bitmap(rounded_int_rect(absolute_rect()), *bitmap, bitmap->rect(), 1.0f, Gfx::Painter::ScalingMode::BilinearBlend);
|
||||
// FIXME: Support 'crisp-edges', 'smooth' and 'high-quality'
|
||||
auto scaling_mode = computed_values().image_rendering() == CSS::ImageRendering::Pixelated ? Gfx::Painter::ScalingMode::NearestNeighbor : Gfx::Painter::ScalingMode::BilinearBlend;
|
||||
context.painter().draw_scaled_bitmap(rounded_int_rect(absolute_rect()), *bitmap, bitmap->rect(), 1.0f, scaling_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue