LibWeb: Separate device pixel conversion helpers from PaintContext

In the upcoming change, device pixel conversion of ClipFrame will
happen during display list replay, where PaintContext is not available,
so let’s move it out of PaintContext.
This commit is contained in:
Aliaksandr Kalenik 2025-07-13 03:54:55 +02:00 committed by Jelle Raaijmakers
commit 7e333cdcf7
Notes: github-actions[bot] 2025-07-14 13:49:44 +00:00
12 changed files with 150 additions and 74 deletions

View file

@ -11,6 +11,7 @@
#include <LibGfx/Palette.h>
#include <LibGfx/Rect.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Painting/DevicePixelConverter.h>
#include <LibWeb/PixelUnits.h>
namespace Web {
@ -68,21 +69,22 @@ public:
PaintContext clone(Painting::DisplayListRecorder& painter) const
{
auto clone = PaintContext(painter, m_palette, m_device_pixels_per_css_pixel);
auto clone = PaintContext(painter, m_palette, m_device_pixel_converter.device_pixels_per_css_pixel());
clone.m_device_viewport_rect = m_device_viewport_rect;
clone.m_should_show_line_box_borders = m_should_show_line_box_borders;
clone.m_should_paint_overlay = m_should_paint_overlay;
return clone;
}
double device_pixels_per_css_pixel() const { return m_device_pixels_per_css_pixel; }
Painting::DevicePixelConverter const& device_pixel_converter() const { return m_device_pixel_converter; }
double device_pixels_per_css_pixel() const { return m_device_pixel_converter.device_pixels_per_css_pixel(); }
u64 paint_generation_id() const { return m_paint_generation_id; }
private:
Painting::DisplayListRecorder& m_display_list_recorder;
Palette m_palette;
double m_device_pixels_per_css_pixel { 0 };
Painting::DevicePixelConverter m_device_pixel_converter;
DevicePixelRect m_device_viewport_rect;
bool m_should_show_line_box_borders { false };
bool m_should_paint_overlay { true };