diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn index 1a353cb098c..83a889adcc1 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn @@ -17,6 +17,7 @@ source_set("Painting") { "Command.cpp", "CommandExecutorCPU.cpp", "DisplayList.cpp", + "DisplayListRecorder.cpp", "FilterPainting.cpp", "GradientPainting.cpp", "ImagePaintable.cpp", @@ -30,7 +31,6 @@ source_set("Painting") { "PaintableBox.cpp", "PaintableFragment.cpp", "RadioButtonPaintable.cpp", - "RecordingPainter.cpp", "SVGClipPaintable.cpp", "SVGForeignObjectPaintable.cpp", "SVGGraphicsPaintable.cpp", diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index cfa603cbf1f..55fe2e6d745 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -544,6 +544,7 @@ set(SOURCES Painting/CheckBoxPaintable.cpp Painting/ClippableAndScrollable.cpp Painting/DisplayList.cpp + Painting/DisplayListRecorder.cpp Painting/GradientPainting.cpp Painting/FilterPainting.cpp Painting/ImagePaintable.cpp @@ -558,7 +559,6 @@ set(SOURCES Painting/PaintableBox.cpp Painting/PaintableFragment.cpp Painting/RadioButtonPaintable.cpp - Painting/RecordingPainter.cpp Painting/SVGForeignObjectPaintable.cpp Painting/SVGPathPaintable.cpp Painting/SVGGraphicsPaintable.cpp diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp index e93a3fc588f..53ad12c6d59 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ConicGradientStyleValue.cpp @@ -47,7 +47,7 @@ void ConicGradientStyleValue::paint(PaintContext& context, DevicePixelRect const VERIFY(m_resolved.has_value()); auto destination_rect = dest_rect.to_type(); auto position = context.rounded_device_point(m_resolved->position).to_type(); - context.recording_painter().fill_rect_with_conic_gradient(destination_rect, m_resolved->data, position, clip_paths); + context.display_list_recorder().fill_rect_with_conic_gradient(destination_rect, m_resolved->data, position, clip_paths); } bool ConicGradientStyleValue::equals(StyleValue const& other) const diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp index 9c7d9c6e368..389f2dd690a 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/ImageStyleValue.cpp @@ -14,8 +14,8 @@ #include #include #include +#include #include -#include #include namespace Web::CSS { @@ -137,7 +137,7 @@ void ImageStyleValue::paint(PaintContext& context, DevicePixelRect const& dest_r { if (auto const* b = bitmap(m_current_frame_index, dest_rect.size().to_type()); b != nullptr) { auto scaling_mode = to_gfx_scaling_mode(image_rendering, b->rect(), dest_rect.to_type()); - context.recording_painter().draw_scaled_immutable_bitmap(dest_rect.to_type(), *b, b->rect(), scaling_mode, clip_paths); + context.display_list_recorder().draw_scaled_immutable_bitmap(dest_rect.to_type(), *b, b->rect(), scaling_mode, clip_paths); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp index f6c62f0d625..2786b9de32c 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/LinearGradientStyleValue.cpp @@ -112,7 +112,7 @@ void LinearGradientStyleValue::resolve_for_size(Layout::NodeWithStyleAndBoxModel void LinearGradientStyleValue::paint(PaintContext& context, DevicePixelRect const& dest_rect, CSS::ImageRendering, Vector const& clip_paths) const { VERIFY(m_resolved.has_value()); - context.recording_painter().fill_rect_with_linear_gradient(dest_rect.to_type(), m_resolved->data, clip_paths); + context.display_list_recorder().fill_rect_with_linear_gradient(dest_rect.to_type(), m_resolved->data, clip_paths); } } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp index 8105874f1e0..99a7a93ddca 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/RadialGradientStyleValue.cpp @@ -212,7 +212,7 @@ void RadialGradientStyleValue::paint(PaintContext& context, DevicePixelRect cons VERIFY(m_resolved.has_value()); auto center = context.rounded_device_point(m_resolved->center).to_type(); auto size = context.rounded_device_size(m_resolved->gradient_size).to_type(); - context.recording_painter().fill_rect_with_radial_gradient(dest_rect.to_type(), m_resolved->data, center, size, clip_paths); + context.display_list_recorder().fill_rect_with_radial_gradient(dest_rect.to_type(), m_resolved->data, center, size, clip_paths); } } diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index 43ac60b0be6..fe0ffee7feb 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -24,7 +24,7 @@ class XMLDocumentBuilder; } namespace Web::Painting { -class RecordingPainter; +class DisplayListRecorder; class SVGGradientPaintStyle; using PaintStyle = RefPtr; } diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp index 781e6dd4f1c..edb468260fd 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp @@ -2092,7 +2092,7 @@ void Navigable::inform_the_navigation_api_about_aborting_navigation() })); } -void Navigable::record_display_list(Painting::RecordingPainter& recording_painter, PaintConfig config) +void Navigable::record_display_list(Painting::DisplayListRecorder& display_list_recorder, PaintConfig config) { auto document = active_document(); if (!document) @@ -2104,12 +2104,12 @@ void Navigable::record_display_list(Painting::RecordingPainter& recording_painte auto background_color = document->background_color(); - recording_painter.fill_rect(bitmap_rect, background_color); + display_list_recorder.fill_rect(bitmap_rect, background_color); if (!document->paintable()) { VERIFY_NOT_REACHED(); } - Web::PaintContext context(recording_painter, page.palette(), page.client().device_pixels_per_css_pixel()); + Web::PaintContext context(display_list_recorder, page.palette(), page.client().device_pixels_per_css_pixel()); context.set_device_viewport_rect(viewport_rect); context.set_should_show_line_box_borders(config.should_show_line_box_borders); context.set_should_paint_overlay(config.paint_overlay); @@ -2136,8 +2136,8 @@ void Navigable::record_display_list(Painting::RecordingPainter& recording_painte auto scroll_offset = context.rounded_device_point(scrollable_frame->offset).to_type(); scroll_offsets_by_frame_id[scrollable_frame->id] = scroll_offset; } - recording_painter.display_list().apply_scroll_offsets(scroll_offsets_by_frame_id); - recording_painter.display_list().mark_unnecessary_commands(); + display_list_recorder.display_list().apply_scroll_offsets(scroll_offsets_by_frame_id); + display_list_recorder.display_list().mark_unnecessary_commands(); } m_needs_repaint = false; diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h index ffaec209e29..fc7d7bae602 100644 --- a/Userland/Libraries/LibWeb/HTML/Navigable.h +++ b/Userland/Libraries/LibWeb/HTML/Navigable.h @@ -183,7 +183,7 @@ public: bool should_show_line_box_borders { false }; bool has_focus { false }; }; - void record_display_list(Painting::RecordingPainter& recording_painter, PaintConfig); + void record_display_list(Painting::DisplayListRecorder& display_list_recorder, PaintConfig); Page& page() { return m_page; } Page const& page() const { return m_page; } diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 487d9633e9a..96c93340b8c 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -1177,16 +1177,16 @@ JS::GCPtr TraversableNavigable::currently_focused_area() void TraversableNavigable::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& target, Web::PaintOptions paint_options) { Painting::DisplayList display_list; - Painting::RecordingPainter recording_painter(display_list); + Painting::DisplayListRecorder display_list_recorder(display_list); Gfx::IntRect bitmap_rect { {}, content_rect.size().to_type() }; - recording_painter.fill_rect(bitmap_rect, Web::CSS::SystemColor::canvas()); + display_list_recorder.fill_rect(bitmap_rect, Web::CSS::SystemColor::canvas()); Web::HTML::Navigable::PaintConfig paint_config; paint_config.paint_overlay = paint_options.paint_overlay == Web::PaintOptions::PaintOverlay::Yes; paint_config.should_show_line_box_borders = paint_options.should_show_line_box_borders; paint_config.has_focus = paint_options.has_focus; - record_display_list(recording_painter, paint_config); + record_display_list(display_list_recorder, paint_config); auto painting_command_executor_type = page().client().painting_command_executor_type(); if (painting_command_executor_type == PaintingCommandExecutorType::GPU) { diff --git a/Userland/Libraries/LibWeb/Painting/AudioPaintable.cpp b/Userland/Libraries/LibWeb/Painting/AudioPaintable.cpp index d46004840ed..91db701bbb4 100644 --- a/Userland/Libraries/LibWeb/Painting/AudioPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/AudioPaintable.cpp @@ -49,10 +49,10 @@ void AudioPaintable::paint(PaintContext& context, PaintPhase phase) const if (phase != PaintPhase::Foreground) return; - RecordingPainterStateSaver saver { context.recording_painter() }; + DisplayListRecorderStateSaver saver { context.display_list_recorder() }; auto audio_rect = context.rounded_device_rect(absolute_rect()); - context.recording_painter().add_clip_rect(audio_rect.to_type()); + context.display_list_recorder().add_clip_rect(audio_rect.to_type()); ScopedCornerRadiusClip corner_clip { context, audio_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) }; diff --git a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp index 2a456e8f7e8..26e21a91071 100644 --- a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp @@ -126,7 +126,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet clip_paths = compute_text_clip_paths(context, *layout_node.paintable()); } - auto& painter = context.recording_painter(); + auto& display_list_recorder = context.display_list_recorder(); struct BackgroundBox { CSSPixelRect rect; @@ -181,7 +181,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet } } - painter.fill_rect_with_rounded_corners( + display_list_recorder.fill_rect_with_rounded_corners( context.rounded_device_rect(color_box.rect).to_type(), background_color, color_box.radii.top_left.as_corner(context), @@ -217,14 +217,14 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet for (auto& layer : background_layers->in_reverse()) { if (!layer_is_paintable(layer)) continue; - RecordingPainterStateSaver state { painter }; + DisplayListRecorderStateSaver state { display_list_recorder }; // Clip auto clip_box = get_box(layer.clip); CSSPixelRect const& css_clip_rect = clip_box.rect; auto clip_rect = context.rounded_device_rect(css_clip_rect); - painter.add_clip_rect(clip_rect.to_type()); + display_list_recorder.add_clip_rect(clip_rect.to_type()); ScopedCornerRadiusClip corner_clip { context, clip_rect, clip_box.radii }; if (layer.clip == CSS::BackgroundBox::BorderBox) { @@ -452,7 +452,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet fill_rect = fill_rect->united(image_device_rect); } }); - painter.fill_rect(fill_rect->to_type(), color.value(), clip_paths); + display_list_recorder.fill_rect(fill_rect->to_type(), color.value(), clip_paths); } else { for_each_image_device_rect([&](auto const& image_device_rect) { image.paint(context, image_device_rect, image_rendering, clip_paths); diff --git a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp index ba5978f2945..9d2e332bec4 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp @@ -61,7 +61,7 @@ Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_ return border_data.color; } -void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last) +void paint_border(DisplayListRecorder& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last) { auto const& border_data = [&] { switch (edge) { @@ -491,7 +491,7 @@ void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect co } } -void paint_all_borders(RecordingPainter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data) +void paint_all_borders(DisplayListRecorder& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const& borders_data) { if (borders_data.top.width <= 0 && borders_data.right.width <= 0 && borders_data.left.width <= 0 && borders_data.bottom.width <= 0) return; diff --git a/Userland/Libraries/LibWeb/Painting/BorderPainting.h b/Userland/Libraries/LibWeb/Painting/BorderPainting.h index 196641d0a56..0b417215e04 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderPainting.h +++ b/Userland/Libraries/LibWeb/Painting/BorderPainting.h @@ -26,8 +26,8 @@ enum class BorderEdge { // Returns OptionalNone if there is no outline to paint. Optional borders_data_for_outline(Layout::Node const&, Color outline_color, CSS::OutlineStyle outline_style, CSSPixels outline_width); -void paint_border(RecordingPainter& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last); -void paint_all_borders(RecordingPainter& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const&); +void paint_border(DisplayListRecorder& painter, BorderEdge edge, DevicePixelRect const& rect, Gfx::AntiAliasingPainter::CornerRadius const& radius, Gfx::AntiAliasingPainter::CornerRadius const& opposite_radius, BordersDataDevicePixels const& borders_data, Gfx::Path& path, bool last); +void paint_all_borders(DisplayListRecorder& painter, DevicePixelRect const& border_rect, CornerRadii const& corner_radii, BordersDataDevicePixels const&); Gfx::Color border_color(BorderEdge edge, BordersDataDevicePixels const& borders_data); diff --git a/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp b/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp index 9e665b5c1de..3ac2d0a413c 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp +++ b/Userland/Libraries/LibWeb/Painting/BorderRadiusCornerClipper.cpp @@ -128,14 +128,14 @@ ScopedCornerRadiusClip::ScopedCornerRadiusClip(PaintContext& context, DevicePixe m_has_radius = corner_radii.has_any_radius(); if (!m_has_radius) return; - m_context.recording_painter().sample_under_corners(m_id, corner_radii, border_rect.to_type(), corner_clip); + m_context.display_list_recorder().sample_under_corners(m_id, corner_radii, border_rect.to_type(), corner_clip); } ScopedCornerRadiusClip::~ScopedCornerRadiusClip() { if (!m_has_radius) return; - m_context.recording_painter().blit_corner_clipping(m_id); + m_context.display_list_recorder().blit_corner_clipping(m_id); } } diff --git a/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp b/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp index 92f15298e6d..eade794b974 100644 --- a/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp @@ -40,7 +40,7 @@ void CanvasPaintable::paint(PaintContext& context, PaintPhase phase) const // FIXME: Remove this const_cast. const_cast(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()); - context.recording_painter().draw_scaled_bitmap(canvas_rect.to_type(), *layout_box().dom_node().bitmap(), layout_box().dom_node().bitmap()->rect(), scaling_mode); + context.display_list_recorder().draw_scaled_bitmap(canvas_rect.to_type(), *layout_box().dom_node().bitmap(), layout_box().dom_node().bitmap()->rect(), scaling_mode); } } } diff --git a/Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.cpp b/Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.cpp index f5600e23089..a43fd773f4c 100644 --- a/Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/CheckBoxPaintable.cpp @@ -99,11 +99,11 @@ void CheckBoxPaintable::paint(PaintContext& context, PaintPhase phase) const // Little heuristic that smaller things look better with more smoothness. if (checkbox.checked() && !checkbox.indeterminate()) { auto background_color = enabled ? input_colors.accent : input_colors.mid_gray; - context.recording_painter().fill_rect_with_rounded_corners(checkbox_rect, modify_color(background_color), checkbox_radius); + context.display_list_recorder().fill_rect_with_rounded_corners(checkbox_rect, modify_color(background_color), checkbox_radius); auto tick_color = increase_contrast(input_colors.base, background_color); if (!enabled) tick_color = shade(tick_color, 0.5f); - context.recording_painter().fill_path({ + context.display_list_recorder().fill_path({ .path = check_mark_path(checkbox_rect), .color = tick_color, .translation = checkbox_rect.location().to_type(), @@ -111,14 +111,14 @@ void CheckBoxPaintable::paint(PaintContext& context, PaintPhase phase) const } else { auto background_color = input_colors.background_color(enabled); auto border_thickness = max(1, checkbox_rect.width() / 10); - context.recording_painter().fill_rect_with_rounded_corners(checkbox_rect, modify_color(input_colors.border_color(enabled)), checkbox_radius); - context.recording_painter().fill_rect_with_rounded_corners(checkbox_rect.shrunken(border_thickness, border_thickness, border_thickness, border_thickness), + context.display_list_recorder().fill_rect_with_rounded_corners(checkbox_rect, modify_color(input_colors.border_color(enabled)), checkbox_radius); + context.display_list_recorder().fill_rect_with_rounded_corners(checkbox_rect.shrunken(border_thickness, border_thickness, border_thickness, border_thickness), background_color, max(0, checkbox_radius - border_thickness)); if (checkbox.indeterminate()) { int radius = 0.05 * checkbox_rect.width(); auto dash_color = increase_contrast(input_colors.dark_gray, background_color); auto dash_rect = checkbox_rect.inflated(-0.4 * checkbox_rect.width(), -0.8 * checkbox_rect.height()); - context.recording_painter().fill_rect_with_rounded_corners(dash_rect, dash_color, radius, radius, radius, radius); + context.display_list_recorder().fill_rect_with_rounded_corners(dash_rect, dash_color, radius, radius, radius, radius); } } } diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp index 87c925efe77..29634cb37f6 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp @@ -9,8 +9,8 @@ #include #include #include +#include #include -#include #include namespace Web::Painting { diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h index 4458584ec9a..e22dc1b758c 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace Web::Painting { diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h b/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h index f0939018900..32187f3be66 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorGPU.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace Web::Painting { diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorSkia.h b/Userland/Libraries/LibWeb/Painting/CommandExecutorSkia.h index 86ae0495df1..b1e14e251a2 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorSkia.h +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorSkia.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include namespace Web::Painting { diff --git a/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp b/Userland/Libraries/LibWeb/Painting/DisplayListRecorder.cpp similarity index 70% rename from Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp rename to Userland/Libraries/LibWeb/Painting/DisplayListRecorder.cpp index 6e5b9dfb147..ab212050466 100644 --- a/Userland/Libraries/LibWeb/Painting/RecordingPainter.cpp +++ b/Userland/Libraries/LibWeb/Painting/DisplayListRecorder.cpp @@ -4,28 +4,28 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include namespace Web::Painting { -RecordingPainter::RecordingPainter(DisplayList& command_list) +DisplayListRecorder::DisplayListRecorder(DisplayList& command_list) : m_command_list(command_list) { m_state_stack.append(State()); } -RecordingPainter::~RecordingPainter() +DisplayListRecorder::~DisplayListRecorder() { VERIFY(m_corner_clip_state_stack.is_empty()); } -void RecordingPainter::append(Command&& command) +void DisplayListRecorder::append(Command&& command) { m_command_list.append(move(command), state().scroll_frame_id); } -void RecordingPainter::sample_under_corners(u32 id, CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip) +void DisplayListRecorder::sample_under_corners(u32 id, CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip) { m_corner_clip_state_stack.append({ id, border_rect }); if (m_corner_clip_state_stack.size() > display_list().corner_clip_max_depth()) @@ -37,14 +37,14 @@ void RecordingPainter::sample_under_corners(u32 id, CornerRadii corner_radii, Gf corner_clip }); } -void RecordingPainter::blit_corner_clipping(u32 id) +void DisplayListRecorder::blit_corner_clipping(u32 id) { auto clip_state = m_corner_clip_state_stack.take_last(); VERIFY(clip_state.id == id); append(BlitCornerClipping { id, state().translation.map(clip_state.rect) }); } -void RecordingPainter::fill_rect(Gfx::IntRect const& rect, Color color, Vector const& clip_paths) +void DisplayListRecorder::fill_rect(Gfx::IntRect const& rect, Color color, Vector const& clip_paths) { if (rect.is_empty()) return; @@ -55,7 +55,7 @@ void RecordingPainter::fill_rect(Gfx::IntRect const& rect, Color color, Vector(); @@ -70,7 +70,7 @@ void RecordingPainter::fill_path(FillPathUsingColorParams params) }); } -void RecordingPainter::fill_path(FillPathUsingPaintStyleParams params) +void DisplayListRecorder::fill_path(FillPathUsingPaintStyleParams params) { auto aa_translation = state().translation.map(params.translation.value_or(Gfx::FloatPoint {})); auto path_bounding_rect = params.path.bounding_box().translated(aa_translation).to_type(); @@ -86,7 +86,7 @@ void RecordingPainter::fill_path(FillPathUsingPaintStyleParams params) }); } -void RecordingPainter::stroke_path(StrokePathUsingColorParams params) +void DisplayListRecorder::stroke_path(StrokePathUsingColorParams params) { auto aa_translation = state().translation.map(params.translation.value_or(Gfx::FloatPoint {})); auto path_bounding_rect = params.path.bounding_box().translated(aa_translation).to_type(); @@ -103,7 +103,7 @@ void RecordingPainter::stroke_path(StrokePathUsingColorParams params) }); } -void RecordingPainter::stroke_path(StrokePathUsingPaintStyleParams params) +void DisplayListRecorder::stroke_path(StrokePathUsingPaintStyleParams params) { auto aa_translation = state().translation.map(params.translation.value_or(Gfx::FloatPoint {})); auto path_bounding_rect = params.path.bounding_box().translated(aa_translation).to_type(); @@ -121,7 +121,7 @@ void RecordingPainter::stroke_path(StrokePathUsingPaintStyleParams params) }); } -void RecordingPainter::draw_ellipse(Gfx::IntRect const& a_rect, Color color, int thickness) +void DisplayListRecorder::draw_ellipse(Gfx::IntRect const& a_rect, Color color, int thickness) { if (a_rect.is_empty()) return; @@ -132,7 +132,7 @@ void RecordingPainter::draw_ellipse(Gfx::IntRect const& a_rect, Color color, int }); } -void RecordingPainter::fill_ellipse(Gfx::IntRect const& a_rect, Color color) +void DisplayListRecorder::fill_ellipse(Gfx::IntRect const& a_rect, Color color) { if (a_rect.is_empty()) return; @@ -142,7 +142,7 @@ void RecordingPainter::fill_ellipse(Gfx::IntRect const& a_rect, Color color) }); } -void RecordingPainter::fill_rect_with_linear_gradient(Gfx::IntRect const& gradient_rect, LinearGradientData const& data, Vector const& clip_paths) +void DisplayListRecorder::fill_rect_with_linear_gradient(Gfx::IntRect const& gradient_rect, LinearGradientData const& data, Vector const& clip_paths) { if (gradient_rect.is_empty()) return; @@ -152,7 +152,7 @@ void RecordingPainter::fill_rect_with_linear_gradient(Gfx::IntRect const& gradie .clip_paths = clip_paths }); } -void RecordingPainter::fill_rect_with_conic_gradient(Gfx::IntRect const& rect, ConicGradientData const& data, Gfx::IntPoint const& position, Vector const& clip_paths) +void DisplayListRecorder::fill_rect_with_conic_gradient(Gfx::IntRect const& rect, ConicGradientData const& data, Gfx::IntPoint const& position, Vector const& clip_paths) { if (rect.is_empty()) return; @@ -163,7 +163,7 @@ void RecordingPainter::fill_rect_with_conic_gradient(Gfx::IntRect const& rect, C .clip_paths = clip_paths }); } -void RecordingPainter::fill_rect_with_radial_gradient(Gfx::IntRect const& rect, RadialGradientData const& data, Gfx::IntPoint center, Gfx::IntSize size, Vector const& clip_paths) +void DisplayListRecorder::fill_rect_with_radial_gradient(Gfx::IntRect const& rect, RadialGradientData const& data, Gfx::IntPoint center, Gfx::IntSize size, Vector const& clip_paths) { if (rect.is_empty()) return; @@ -175,7 +175,7 @@ void RecordingPainter::fill_rect_with_radial_gradient(Gfx::IntRect const& rect, .clip_paths = clip_paths }); } -void RecordingPainter::draw_rect(Gfx::IntRect const& rect, Color color, bool rough) +void DisplayListRecorder::draw_rect(Gfx::IntRect const& rect, Color color, bool rough) { if (rect.is_empty()) return; @@ -185,7 +185,7 @@ void RecordingPainter::draw_rect(Gfx::IntRect const& rect, Color color, bool rou .rough = rough }); } -void RecordingPainter::draw_scaled_bitmap(Gfx::IntRect const& dst_rect, Gfx::Bitmap const& bitmap, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode) +void DisplayListRecorder::draw_scaled_bitmap(Gfx::IntRect const& dst_rect, Gfx::Bitmap const& bitmap, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode) { if (dst_rect.is_empty()) return; @@ -197,7 +197,7 @@ void RecordingPainter::draw_scaled_bitmap(Gfx::IntRect const& dst_rect, Gfx::Bit }); } -void RecordingPainter::draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_rect, Gfx::ImmutableBitmap const& bitmap, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode, Vector const& clip_paths) +void DisplayListRecorder::draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_rect, Gfx::ImmutableBitmap const& bitmap, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode, Vector const& clip_paths) { if (dst_rect.is_empty()) return; @@ -210,7 +210,7 @@ void RecordingPainter::draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_rect }); } -void RecordingPainter::draw_line(Gfx::IntPoint from, Gfx::IntPoint to, Color color, int thickness, Gfx::LineStyle style, Color alternate_color) +void DisplayListRecorder::draw_line(Gfx::IntPoint from, Gfx::IntPoint to, Color color, int thickness, Gfx::LineStyle style, Color alternate_color) { append(DrawLine { .color = color, @@ -222,7 +222,7 @@ void RecordingPainter::draw_line(Gfx::IntPoint from, Gfx::IntPoint to, Color col }); } -void RecordingPainter::draw_text(Gfx::IntRect const& rect, String raw_text, Gfx::Font const& font, Gfx::TextAlignment alignment, Color color) +void DisplayListRecorder::draw_text(Gfx::IntRect const& rect, String raw_text, Gfx::Font const& font, Gfx::TextAlignment alignment, Color color) { if (rect.is_empty()) return; @@ -254,7 +254,7 @@ void RecordingPainter::draw_text(Gfx::IntRect const& rect, String raw_text, Gfx: draw_text_run(Gfx::IntPoint(roundf(baseline_x), roundf(baseline_y)), *glyph_run, color, rect, 1.0); } -void RecordingPainter::draw_text_run(Gfx::IntPoint baseline_start, Gfx::GlyphRun const& glyph_run, Color color, Gfx::IntRect const& rect, double scale) +void DisplayListRecorder::draw_text_run(Gfx::IntPoint baseline_start, Gfx::GlyphRun const& glyph_run, Color color, Gfx::IntRect const& rect, double scale) { if (rect.is_empty()) return; @@ -268,28 +268,28 @@ void RecordingPainter::draw_text_run(Gfx::IntPoint baseline_start, Gfx::GlyphRun }); } -void RecordingPainter::add_clip_rect(Gfx::IntRect const& rect) +void DisplayListRecorder::add_clip_rect(Gfx::IntRect const& rect) { append(AddClipRect { .rect = state().translation.map(rect) }); } -void RecordingPainter::translate(int dx, int dy) +void DisplayListRecorder::translate(int dx, int dy) { m_state_stack.last().translation.translate(dx, dy); } -void RecordingPainter::translate(Gfx::IntPoint delta) +void DisplayListRecorder::translate(Gfx::IntPoint delta) { m_state_stack.last().translation.translate(delta.to_type()); } -void RecordingPainter::save() +void DisplayListRecorder::save() { append(Save {}); m_state_stack.append(m_state_stack.last()); } -void RecordingPainter::restore() +void DisplayListRecorder::restore() { append(Restore {}); @@ -297,7 +297,7 @@ void RecordingPainter::restore() m_state_stack.take_last(); } -void RecordingPainter::push_stacking_context(PushStackingContextParams params) +void DisplayListRecorder::push_stacking_context(PushStackingContextParams params) { append(PushStackingContext { .opacity = params.opacity, @@ -316,13 +316,13 @@ void RecordingPainter::push_stacking_context(PushStackingContextParams params) m_state_stack.append(State()); } -void RecordingPainter::pop_stacking_context() +void DisplayListRecorder::pop_stacking_context() { m_state_stack.take_last(); append(PopStackingContext {}); } -void RecordingPainter::apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, CSS::ResolvedBackdropFilter const& backdrop_filter) +void DisplayListRecorder::apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, CSS::ResolvedBackdropFilter const& backdrop_filter) { if (backdrop_region.is_empty()) return; @@ -333,18 +333,18 @@ void RecordingPainter::apply_backdrop_filter(Gfx::IntRect const& backdrop_region }); } -void RecordingPainter::paint_outer_box_shadow_params(PaintBoxShadowParams params) +void DisplayListRecorder::paint_outer_box_shadow_params(PaintBoxShadowParams params) { params.device_content_rect = state().translation.map(params.device_content_rect); append(PaintOuterBoxShadow { .box_shadow_params = params }); } -void RecordingPainter::paint_inner_box_shadow_params(PaintBoxShadowParams params) +void DisplayListRecorder::paint_inner_box_shadow_params(PaintBoxShadowParams params) { append(PaintInnerBoxShadow { .box_shadow_params = params }); } -void RecordingPainter::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Span glyph_run, Color color, int fragment_baseline, Gfx::IntPoint draw_location) +void DisplayListRecorder::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Span glyph_run, Color color, int fragment_baseline, Gfx::IntPoint draw_location) { append(PaintTextShadow { .blur_radius = blur_radius, @@ -356,7 +356,7 @@ void RecordingPainter::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_ .draw_location = state().translation.map(draw_location) }); } -void RecordingPainter::fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, Gfx::AntiAliasingPainter::CornerRadius top_left_radius, Gfx::AntiAliasingPainter::CornerRadius top_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_left_radius, Vector const& clip_paths) +void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& rect, Color color, Gfx::AntiAliasingPainter::CornerRadius top_left_radius, Gfx::AntiAliasingPainter::CornerRadius top_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_right_radius, Gfx::AntiAliasingPainter::CornerRadius bottom_left_radius, Vector const& clip_paths) { if (rect.is_empty()) return; @@ -377,14 +377,14 @@ void RecordingPainter::fill_rect_with_rounded_corners(Gfx::IntRect const& rect, }); } -void RecordingPainter::fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int radius, Vector const& clip_paths) +void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int radius, Vector const& clip_paths) { if (a_rect.is_empty()) return; fill_rect_with_rounded_corners(a_rect, color, radius, radius, radius, radius, clip_paths); } -void RecordingPainter::fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius, Vector const& clip_paths) +void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int top_left_radius, int top_right_radius, int bottom_right_radius, int bottom_left_radius, Vector const& clip_paths) { if (a_rect.is_empty()) return; @@ -396,7 +396,7 @@ void RecordingPainter::fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect clip_paths); } -void RecordingPainter::draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a_p2, Color color, int amplitude, int thickness = 1) +void DisplayListRecorder::draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a_p2, Color color, int amplitude, int thickness = 1) { append(DrawTriangleWave { .p1 = state().translation.map(a_p1), diff --git a/Userland/Libraries/LibWeb/Painting/RecordingPainter.h b/Userland/Libraries/LibWeb/Painting/DisplayListRecorder.h similarity index 94% rename from Userland/Libraries/LibWeb/Painting/RecordingPainter.h rename to Userland/Libraries/LibWeb/Painting/DisplayListRecorder.h index e894649db30..90965b39b06 100644 --- a/Userland/Libraries/LibWeb/Painting/RecordingPainter.h +++ b/Userland/Libraries/LibWeb/Painting/DisplayListRecorder.h @@ -35,9 +35,9 @@ namespace Web::Painting { -class RecordingPainter { - AK_MAKE_NONCOPYABLE(RecordingPainter); - AK_MAKE_NONMOVABLE(RecordingPainter); +class DisplayListRecorder { + AK_MAKE_NONCOPYABLE(DisplayListRecorder); + AK_MAKE_NONMOVABLE(DisplayListRecorder); public: void fill_rect(Gfx::IntRect const& rect, Color color, Vector const& clip_paths = {}); @@ -135,8 +135,8 @@ public: void draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a_p2, Color color, int amplitude, int thickness); - RecordingPainter(DisplayList&); - ~RecordingPainter(); + DisplayListRecorder(DisplayList&); + ~DisplayListRecorder(); DisplayList& display_list() { return m_command_list; } @@ -161,21 +161,21 @@ private: DisplayList& m_command_list; }; -class RecordingPainterStateSaver { +class DisplayListRecorderStateSaver { public: - explicit RecordingPainterStateSaver(RecordingPainter& painter) + explicit DisplayListRecorderStateSaver(DisplayListRecorder& painter) : m_painter(painter) { m_painter.save(); } - ~RecordingPainterStateSaver() + ~DisplayListRecorderStateSaver() { m_painter.restore(); } private: - RecordingPainter& m_painter; + DisplayListRecorder& m_painter; }; } diff --git a/Userland/Libraries/LibWeb/Painting/FilterPainting.cpp b/Userland/Libraries/LibWeb/Painting/FilterPainting.cpp index 5cf5e9d8766..3f241193e08 100644 --- a/Userland/Libraries/LibWeb/Painting/FilterPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/FilterPainting.cpp @@ -103,7 +103,7 @@ void apply_backdrop_filter(PaintContext& context, CSSPixelRect const& backdrop_r auto backdrop_region = context.rounded_device_rect(backdrop_rect); ScopedCornerRadiusClip corner_clipper { context, backdrop_region, border_radii_data }; - context.recording_painter().apply_backdrop_filter(backdrop_region.to_type(), border_radii_data, backdrop_filter); + context.display_list_recorder().apply_backdrop_filter(backdrop_region.to_type(), border_radii_data, backdrop_filter); } } diff --git a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp index e5be9444c09..175cec699e9 100644 --- a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp @@ -65,8 +65,8 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const auto image_rect = context.rounded_device_rect(absolute_rect()); if (m_renders_as_alt_text) { auto enclosing_rect = context.enclosing_device_rect(absolute_rect()).to_type(); - context.recording_painter().draw_rect(enclosing_rect, Gfx::Color::Black); - context.recording_painter().draw_text(enclosing_rect, m_alt_text, Platform::FontPlugin::the().default_font(), Gfx::TextAlignment::Center, computed_values().color()); + context.display_list_recorder().draw_rect(enclosing_rect, Gfx::Color::Black); + context.display_list_recorder().draw_text(enclosing_rect, m_alt_text, Platform::FontPlugin::the().default_font(), Gfx::TextAlignment::Center, computed_values().color()); } else if (auto bitmap = m_image_provider.current_image_bitmap(image_rect.size().to_type())) { ScopedCornerRadiusClip corner_clip { context, image_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) }; auto image_int_rect = image_rect.to_type(); @@ -150,7 +150,7 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const (int)scaled_bitmap_height }; - context.recording_painter().draw_scaled_immutable_bitmap(draw_rect.intersected(image_int_rect), *bitmap, bitmap_rect.intersected(bitmap_intersect), scaling_mode); + context.display_list_recorder().draw_scaled_immutable_bitmap(draw_rect.intersected(image_int_rect), *bitmap, bitmap_rect.intersected(bitmap_intersect), scaling_mode); } } } diff --git a/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp b/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp index 4f230494cd6..ae5a2beb5f0 100644 --- a/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/InlinePaintable.cpp @@ -33,26 +33,26 @@ Layout::InlineNode const& InlinePaintable::layout_node() const void InlinePaintable::before_paint(PaintContext& context, PaintPhase) const { if (scroll_frame_id().has_value()) { - context.recording_painter().save(); - context.recording_painter().set_scroll_frame_id(scroll_frame_id().value()); + context.display_list_recorder().save(); + context.display_list_recorder().set_scroll_frame_id(scroll_frame_id().value()); } if (clip_rect().has_value()) { - context.recording_painter().save(); - context.recording_painter().add_clip_rect(context.enclosing_device_rect(*clip_rect()).to_type()); + context.display_list_recorder().save(); + context.display_list_recorder().add_clip_rect(context.enclosing_device_rect(*clip_rect()).to_type()); } } void InlinePaintable::after_paint(PaintContext& context, PaintPhase) const { if (clip_rect().has_value()) - context.recording_painter().restore(); + context.display_list_recorder().restore(); if (scroll_frame_id().has_value()) - context.recording_painter().restore(); + context.display_list_recorder().restore(); } void InlinePaintable::paint(PaintContext& context, PaintPhase phase) const { - auto& painter = context.recording_painter(); + auto& display_list_recorder = context.display_list_recorder(); if (phase == PaintPhase::Background) { auto containing_block_position_in_absolute_coordinates = containing_block()->absolute_position(); @@ -141,9 +141,9 @@ void InlinePaintable::paint(PaintContext& context, PaintPhase phase) const border_radii_data.inflate(outline_data->top.width + outline_offset_y, outline_data->right.width + outline_offset_x, outline_data->bottom.width + outline_offset_y, outline_data->left.width + outline_offset_x); borders_rect.inflate(outline_data->top.width + outline_offset_y, outline_data->right.width + outline_offset_x, outline_data->bottom.width + outline_offset_y, outline_data->left.width + outline_offset_x); - paint_all_borders(context.recording_painter(), context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), outline_data->to_device_pixels(context)); + paint_all_borders(context.display_list_recorder(), context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), outline_data->to_device_pixels(context)); } else { - paint_all_borders(context.recording_painter(), context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), borders_data.to_device_pixels(context)); + paint_all_borders(context.display_list_recorder(), context.rounded_device_rect(borders_rect), border_radii_data.as_corners(context), borders_data.to_device_pixels(context)); } return IterationDecision::Continue; @@ -172,7 +172,7 @@ void InlinePaintable::paint(PaintContext& context, PaintPhase phase) const // would be none. Once we implement non-rectangular outlines for the `outline` CSS // property, we can use that here instead. for_each_fragment([&](auto const& fragment, bool, bool) { - painter.draw_rect(context.enclosing_device_rect(fragment.absolute_rect()).template to_type(), Color::Magenta); + display_list_recorder.draw_rect(context.enclosing_device_rect(fragment.absolute_rect()).template to_type(), Color::Magenta); return IterationDecision::Continue; }); } diff --git a/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp b/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp index 65246a277aa..739c759ee5f 100644 --- a/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp @@ -69,13 +69,13 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const switch (layout_box().list_style_type()) { case CSS::ListStyleType::Square: - context.recording_painter().fill_rect(device_marker_rect.to_type(), color); + context.display_list_recorder().fill_rect(device_marker_rect.to_type(), color); break; case CSS::ListStyleType::Circle: - context.recording_painter().draw_ellipse(device_marker_rect.to_type(), color, 1); + context.display_list_recorder().draw_ellipse(device_marker_rect.to_type(), color, 1); break; case CSS::ListStyleType::Disc: - context.recording_painter().fill_ellipse(device_marker_rect.to_type(), color); + context.display_list_recorder().fill_ellipse(device_marker_rect.to_type(), color); break; case CSS::ListStyleType::DisclosureClosed: { // https://drafts.csswg.org/css-counter-styles-3/#disclosure-closed @@ -88,7 +88,7 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const path.line_to({ left + sin_60_deg * (right - left), (top + bottom) / 2 }); path.line_to({ left, bottom }); path.close(); - context.recording_painter().fill_path({ .path = path, .color = color, .winding_rule = Gfx::WindingRule::EvenOdd }); + context.display_list_recorder().fill_path({ .path = path, .color = color, .winding_rule = Gfx::WindingRule::EvenOdd }); break; } case CSS::ListStyleType::DisclosureOpen: { @@ -102,7 +102,7 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const path.line_to({ right, top }); path.line_to({ (left + right) / 2, top + sin_60_deg * (bottom - top) }); path.close(); - context.recording_painter().fill_path({ .path = path, .color = color, .winding_rule = Gfx::WindingRule::EvenOdd }); + context.display_list_recorder().fill_path({ .path = path, .color = color, .winding_rule = Gfx::WindingRule::EvenOdd }); break; } case CSS::ListStyleType::Decimal: @@ -118,7 +118,7 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const break; // FIXME: This should use proper text layout logic! // This does not line up with the text in the
  • element which looks very sad :( - context.recording_painter().draw_text(device_enclosing.to_type(), MUST(String::from_byte_string(*text)), layout_box().scaled_font(context), Gfx::TextAlignment::Center, color); + context.display_list_recorder().draw_text(device_enclosing.to_type(), MUST(String::from_byte_string(*text)), layout_box().scaled_font(context), Gfx::TextAlignment::Center, color); break; } case CSS::ListStyleType::None: diff --git a/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp b/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp index aa30370708f..422bb0d7d69 100644 --- a/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/MediaPaintable.cpp @@ -44,7 +44,7 @@ Optional MediaPaintable::mouse_position(PaintContext& context, return {}; } -void MediaPaintable::fill_triangle(RecordingPainter& painter, Gfx::IntPoint location, Array coordinates, Color color) +void MediaPaintable::fill_triangle(DisplayListRecorder& painter, Gfx::IntPoint location, Array coordinates, Color color) { Gfx::Path path; path.move_to((coordinates[0] + location).to_type()); @@ -61,7 +61,7 @@ void MediaPaintable::fill_triangle(RecordingPainter& painter, Gfx::IntPoint loca void MediaPaintable::paint_media_controls(PaintContext& context, HTML::HTMLMediaElement const& media_element, DevicePixelRect media_rect, Optional const& mouse_position) const { auto components = compute_control_bar_components(context, media_element, media_rect); - context.recording_painter().fill_rect(components.control_box_rect.to_type(), control_box_color.with_alpha(0xd0)); + context.display_list_recorder().fill_rect(components.control_box_rect.to_type(), control_box_color.with_alpha(0xd0)); paint_control_bar_playback_button(context, media_element, components, mouse_position); paint_control_bar_timeline(context, media_element, components); @@ -155,7 +155,7 @@ void MediaPaintable::paint_control_bar_playback_button(PaintContext& context, HT { 0, static_cast(playback_button_size) }, } }; - fill_triangle(context.recording_painter(), playback_button_location.to_type(), play_button_coordinates, playback_button_color); + fill_triangle(context.display_list_recorder(), playback_button_location.to_type(), play_button_coordinates, playback_button_color); } else { DevicePixelRect pause_button_left_rect { playback_button_location, @@ -166,8 +166,8 @@ void MediaPaintable::paint_control_bar_playback_button(PaintContext& context, HT { playback_button_size / 3, playback_button_size } }; - context.recording_painter().fill_rect(pause_button_left_rect.to_type(), playback_button_color); - context.recording_painter().fill_rect(pause_button_right_rect.to_type(), playback_button_color); + context.display_list_recorder().fill_rect(pause_button_left_rect.to_type(), playback_button_color); + context.display_list_recorder().fill_rect(pause_button_right_rect.to_type(), playback_button_color); } } @@ -182,11 +182,11 @@ void MediaPaintable::paint_control_bar_timeline(PaintContext& context, HTML::HTM auto timeline_past_rect = components.timeline_rect; timeline_past_rect.set_width(timeline_button_offset_x); - context.recording_painter().fill_rect(timeline_past_rect.to_type(), control_highlight_color.lightened()); + context.display_list_recorder().fill_rect(timeline_past_rect.to_type(), control_highlight_color.lightened()); auto timeline_future_rect = components.timeline_rect; timeline_future_rect.take_from_left(timeline_button_offset_x); - context.recording_painter().fill_rect(timeline_future_rect.to_type(), Color::Black); + context.display_list_recorder().fill_rect(timeline_future_rect.to_type(), Color::Black); } void MediaPaintable::paint_control_bar_timestamp(PaintContext& context, Components const& components) @@ -194,7 +194,7 @@ void MediaPaintable::paint_control_bar_timestamp(PaintContext& context, Componen if (components.timestamp_rect.is_empty()) return; - context.recording_painter().draw_text(components.timestamp_rect.to_type(), components.timestamp, *components.timestamp_font, Gfx::TextAlignment::CenterLeft, Color::White); + context.display_list_recorder().draw_text(components.timestamp_rect.to_type(), components.timestamp, *components.timestamp_font, Gfx::TextAlignment::CenterLeft, Color::White); } void MediaPaintable::paint_control_bar_speaker(PaintContext& context, HTML::HTMLMediaElement const& media_element, Components const& components, Optional const& mouse_position) @@ -227,18 +227,18 @@ void MediaPaintable::paint_control_bar_speaker(PaintContext& context, HTML::HTML path.line_to(device_point(0, 11)); path.line_to(device_point(0, 4)); path.close(); - context.recording_painter().fill_path({ .path = path, .color = speaker_button_color, .winding_rule = Gfx::WindingRule::EvenOdd }); + context.display_list_recorder().fill_path({ .path = path, .color = speaker_button_color, .winding_rule = Gfx::WindingRule::EvenOdd }); path.clear(); path.move_to(device_point(13, 3)); path.quadratic_bezier_curve_to(device_point(16, 7.5), device_point(13, 12)); path.move_to(device_point(14, 0)); path.quadratic_bezier_curve_to(device_point(20, 7.5), device_point(14, 15)); - context.recording_painter().stroke_path({ .path = path, .color = speaker_button_color, .thickness = 1 }); + context.display_list_recorder().stroke_path({ .path = path, .color = speaker_button_color, .thickness = 1 }); if (media_element.muted()) { - context.recording_painter().draw_line(device_point(0, 0).to_type(), device_point(20, 15).to_type(), Color::Red, 2); - context.recording_painter().draw_line(device_point(0, 15).to_type(), device_point(20, 0).to_type(), Color::Red, 2); + context.display_list_recorder().draw_line(device_point(0, 0).to_type(), device_point(20, 15).to_type(), Color::Red, 2); + context.display_list_recorder().draw_line(device_point(0, 15).to_type(), device_point(20, 0).to_type(), Color::Red, 2); } } @@ -252,11 +252,11 @@ void MediaPaintable::paint_control_bar_volume(PaintContext& context, HTML::HTMLM auto volume_lower_rect = components.volume_scrub_rect; volume_lower_rect.set_width(volume_button_offset_x); - context.recording_painter().fill_rect_with_rounded_corners(volume_lower_rect.to_type(), control_highlight_color.lightened(), 4); + context.display_list_recorder().fill_rect_with_rounded_corners(volume_lower_rect.to_type(), control_highlight_color.lightened(), 4); auto volume_higher_rect = components.volume_scrub_rect; volume_higher_rect.take_from_left(volume_button_offset_x); - context.recording_painter().fill_rect_with_rounded_corners(volume_higher_rect.to_type(), Color::Black, 4); + context.display_list_recorder().fill_rect_with_rounded_corners(volume_higher_rect.to_type(), Color::Black, 4); auto volume_button_rect = components.volume_scrub_rect; volume_button_rect.shrink(components.volume_scrub_rect.width() - components.volume_button_size, components.volume_scrub_rect.height() - components.volume_button_size); @@ -264,7 +264,7 @@ void MediaPaintable::paint_control_bar_volume(PaintContext& context, HTML::HTMLM auto volume_is_hovered = rect_is_hovered(media_element, components.volume_rect, mouse_position, HTML::HTMLMediaElement::MouseTrackingComponent::Volume); auto volume_color = control_button_color(volume_is_hovered); - context.recording_painter().fill_ellipse(volume_button_rect.to_type(), volume_color); + context.display_list_recorder().fill_ellipse(volume_button_rect.to_type(), volume_color); } MediaPaintable::DispatchEventOfSameName MediaPaintable::handle_mousedown(Badge, CSSPixelPoint position, unsigned button, unsigned) diff --git a/Userland/Libraries/LibWeb/Painting/MediaPaintable.h b/Userland/Libraries/LibWeb/Painting/MediaPaintable.h index eecabf57192..d4efc4eb973 100644 --- a/Userland/Libraries/LibWeb/Painting/MediaPaintable.h +++ b/Userland/Libraries/LibWeb/Painting/MediaPaintable.h @@ -20,7 +20,7 @@ protected: explicit MediaPaintable(Layout::ReplacedBox const&); static Optional mouse_position(PaintContext&, HTML::HTMLMediaElement const&); - static void fill_triangle(RecordingPainter& painter, Gfx::IntPoint location, Array coordinates, Color color); + static void fill_triangle(DisplayListRecorder& painter, Gfx::IntPoint location, Array coordinates, Color color); void paint_media_controls(PaintContext&, HTML::HTMLMediaElement const&, DevicePixelRect media_rect, Optional const& mouse_position) const; diff --git a/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp b/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp index 0be606ecd37..84e6722f765 100644 --- a/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/NestedBrowsingContextPaintable.cpp @@ -50,23 +50,23 @@ void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase pha if (!hosted_paint_tree) return; - context.recording_painter().save(); + context.display_list_recorder().save(); - context.recording_painter().add_clip_rect(clip_rect.to_type()); + context.display_list_recorder().add_clip_rect(clip_rect.to_type()); auto absolute_device_rect = context.enclosing_device_rect(absolute_rect); - context.recording_painter().translate(absolute_device_rect.x().value(), absolute_device_rect.y().value()); + context.display_list_recorder().translate(absolute_device_rect.x().value(), absolute_device_rect.y().value()); HTML::Navigable::PaintConfig paint_config; paint_config.paint_overlay = context.should_paint_overlay(); paint_config.should_show_line_box_borders = context.should_show_line_box_borders(); paint_config.has_focus = context.has_focus(); - const_cast(hosted_document)->navigable()->record_display_list(context.recording_painter(), paint_config); + const_cast(hosted_document)->navigable()->record_display_list(context.display_list_recorder(), paint_config); - context.recording_painter().restore(); + context.display_list_recorder().restore(); if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) { if (layout_box().dom_node().content_navigable()->is_focused()) { - context.recording_painter().draw_rect(clip_rect.to_type(), Color::Cyan); + context.display_list_recorder().draw_rect(clip_rect.to_type(), Color::Cyan); } } } diff --git a/Userland/Libraries/LibWeb/Painting/PaintContext.cpp b/Userland/Libraries/LibWeb/Painting/PaintContext.cpp index e99363c9e38..d9753c55411 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintContext.cpp @@ -11,8 +11,8 @@ namespace Web { static u64 s_next_paint_generation_id = 0; -PaintContext::PaintContext(Painting::RecordingPainter& recording_painter, Palette const& palette, double device_pixels_per_css_pixel) - : m_recording_painter(recording_painter) +PaintContext::PaintContext(Painting::DisplayListRecorder& display_list_recorder, Palette const& palette, double device_pixels_per_css_pixel) + : m_display_list_recorder(display_list_recorder) , m_palette(palette) , m_device_pixels_per_css_pixel(device_pixels_per_css_pixel) , m_paint_generation_id(s_next_paint_generation_id++) diff --git a/Userland/Libraries/LibWeb/Painting/PaintContext.h b/Userland/Libraries/LibWeb/Painting/PaintContext.h index 0cf0157eba5..51dfdd9882b 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintContext.h +++ b/Userland/Libraries/LibWeb/Painting/PaintContext.h @@ -11,16 +11,16 @@ #include #include #include -#include +#include #include namespace Web { class PaintContext { public: - PaintContext(Painting::RecordingPainter& painter, Palette const& palette, double device_pixels_per_css_pixel); + PaintContext(Painting::DisplayListRecorder& painter, Palette const& palette, double device_pixels_per_css_pixel); - Painting::RecordingPainter& recording_painter() const { return m_recording_painter; } + Painting::DisplayListRecorder& display_list_recorder() const { return m_display_list_recorder; } Palette const& palette() const { return m_palette; } bool should_show_line_box_borders() const { return m_should_show_line_box_borders; } @@ -70,7 +70,7 @@ public: CSSPixelSize scale_to_css_size(DevicePixelSize) const; CSSPixelRect scale_to_css_rect(DevicePixelRect) const; - PaintContext clone(Painting::RecordingPainter& painter) const + PaintContext clone(Painting::DisplayListRecorder& painter) const { auto clone = PaintContext(painter, m_palette, m_device_pixels_per_css_pixel); clone.m_device_viewport_rect = m_device_viewport_rect; @@ -87,7 +87,7 @@ public: u64 paint_generation_id() const { return m_paint_generation_id; } private: - Painting::RecordingPainter& m_recording_painter; + Painting::DisplayListRecorder& m_display_list_recorder; Palette m_palette; double m_device_pixels_per_css_pixel { 0 }; DevicePixelRect m_device_viewport_rect; diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 641138eef32..70fc9765dbc 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -333,7 +333,7 @@ void PaintableBox::paint(PaintContext& context, PaintPhase phase) const border_radius_data.inflate(outline_data->top.width + outline_offset_y, outline_data->right.width + outline_offset_x, outline_data->bottom.width + outline_offset_y, outline_data->left.width + outline_offset_x); borders_rect.inflate(outline_data->top.width + outline_offset_y, outline_data->right.width + outline_offset_x, outline_data->bottom.width + outline_offset_y, outline_data->left.width + outline_offset_x); - paint_all_borders(context.recording_painter(), context.rounded_device_rect(borders_rect), border_radius_data.as_corners(context), outline_data->to_device_pixels(context)); + paint_all_borders(context.display_list_recorder(), context.rounded_device_rect(borders_rect), border_radius_data.as_corners(context), outline_data->to_device_pixels(context)); } } @@ -343,11 +343,11 @@ void PaintableBox::paint(PaintContext& context, PaintPhase phase) const int thumb_corner_radius = static_cast(context.rounded_device_pixels(scrollbar_thumb_thickness / 2)); if (auto thumb_rect = scroll_thumb_rect(ScrollDirection::Horizontal); thumb_rect.has_value()) { auto thumb_device_rect = context.enclosing_device_rect(thumb_rect.value()); - context.recording_painter().fill_rect_with_rounded_corners(thumb_device_rect.to_type(), color, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius); + context.display_list_recorder().fill_rect_with_rounded_corners(thumb_device_rect.to_type(), color, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius); } if (auto thumb_rect = scroll_thumb_rect(ScrollDirection::Vertical); thumb_rect.has_value()) { auto thumb_device_rect = context.enclosing_device_rect(thumb_rect.value()); - context.recording_painter().fill_rect_with_rounded_corners(thumb_device_rect.to_type(), color, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius); + context.display_list_recorder().fill_rect_with_rounded_corners(thumb_device_rect.to_type(), color, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius, thumb_corner_radius); } } @@ -366,8 +366,8 @@ void PaintableBox::paint(PaintContext& context, PaintPhase phase) const auto paint_inspector_rect = [&](CSSPixelRect const& rect, Color color) { auto device_rect = context.enclosing_device_rect(rect).to_type(); - context.recording_painter().fill_rect(device_rect, Color(color).with_alpha(100)); - context.recording_painter().draw_rect(device_rect, Color(color)); + context.display_list_recorder().fill_rect(device_rect, Color(color).with_alpha(100)); + context.display_list_recorder().draw_rect(device_rect, Color(color)); }; paint_inspector_rect(margin_rect, Color::Yellow); @@ -390,9 +390,9 @@ void PaintableBox::paint(PaintContext& context, PaintPhase phase) const size_text_rect.set_width(CSSPixels::nearest_value_for(font.width(size_text)) + 4); size_text_rect.set_height(CSSPixels::nearest_value_for(font.pixel_size()) + 4); auto size_text_device_rect = context.enclosing_device_rect(size_text_rect).to_type(); - context.recording_painter().fill_rect(size_text_device_rect, context.palette().color(Gfx::ColorRole::Tooltip)); - context.recording_painter().draw_rect(size_text_device_rect, context.palette().threed_shadow1()); - context.recording_painter().draw_text(size_text_device_rect, size_text, font, Gfx::TextAlignment::Center, context.palette().color(Gfx::ColorRole::TooltipText)); + context.display_list_recorder().fill_rect(size_text_device_rect, context.palette().color(Gfx::ColorRole::Tooltip)); + context.display_list_recorder().draw_rect(size_text_device_rect, context.palette().threed_shadow1()); + context.display_list_recorder().draw_text(size_text_device_rect, size_text, font, Gfx::TextAlignment::Center, context.palette().color(Gfx::ColorRole::TooltipText)); } } @@ -414,7 +414,7 @@ void PaintableBox::paint_border(PaintContext& context) const .bottom = box_model().border.bottom == 0 ? CSS::BorderData() : computed_values().border_bottom(), .left = box_model().border.left == 0 ? CSS::BorderData() : computed_values().border_left(), }; - paint_all_borders(context.recording_painter(), context.rounded_device_rect(absolute_border_box_rect()), normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); + paint_all_borders(context.display_list_recorder(), context.rounded_device_rect(absolute_border_box_rect()), normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); } void PaintableBox::paint_backdrop_filter(PaintContext& context) const @@ -482,15 +482,15 @@ BorderRadiiData PaintableBox::normalized_border_radii_data(ShrinkRadiiForBorders void PaintableBox::apply_scroll_offset(PaintContext& context, PaintPhase) const { if (scroll_frame_id().has_value()) { - context.recording_painter().save(); - context.recording_painter().set_scroll_frame_id(scroll_frame_id().value()); + context.display_list_recorder().save(); + context.display_list_recorder().set_scroll_frame_id(scroll_frame_id().value()); } } void PaintableBox::reset_scroll_offset(PaintContext& context, PaintPhase) const { if (scroll_frame_id().has_value()) - context.recording_painter().restore(); + context.display_list_recorder().restore(); } void PaintableBox::apply_clip_overflow_rect(PaintContext& context, PaintPhase phase) const @@ -501,8 +501,8 @@ void PaintableBox::apply_clip_overflow_rect(PaintContext& context, PaintPhase ph if (clip_rect().has_value()) { auto overflow_clip_rect = clip_rect().value(); m_clipping_overflow = true; - context.recording_painter().save(); - context.recording_painter().add_clip_rect(context.enclosing_device_rect(overflow_clip_rect).to_type()); + context.display_list_recorder().save(); + context.display_list_recorder().add_clip_rect(context.enclosing_device_rect(overflow_clip_rect).to_type()); auto const& border_radii_clips = this->border_radii_clips(); m_corner_clipper_ids.resize(border_radii_clips.size()); auto const& combined_transform = combined_css_transform(); @@ -514,7 +514,7 @@ void PaintableBox::apply_clip_overflow_rect(PaintContext& context, PaintPhase ph auto corner_clipper_id = context.allocate_corner_clipper_id(); m_corner_clipper_ids[corner_clip_index] = corner_clipper_id; auto rect = corner_clip.rect.translated(-combined_transform.translation().to_type()); - context.recording_painter().sample_under_corners(corner_clipper_id, corner_clip.radii.as_corners(context), context.rounded_device_rect(rect).to_type(), CornerClip::Outside); + context.display_list_recorder().sample_under_corners(corner_clipper_id, corner_clip.radii.as_corners(context), context.rounded_device_rect(rect).to_type(), CornerClip::Outside); } } } @@ -534,9 +534,9 @@ void PaintableBox::clear_clip_overflow_rect(PaintContext& context, PaintPhase ph continue; auto corner_clipper_id = m_corner_clipper_ids[corner_clip_index]; m_corner_clipper_ids[corner_clip_index] = corner_clipper_id; - context.recording_painter().blit_corner_clipping(corner_clipper_id); + context.display_list_recorder().blit_corner_clipping(corner_clipper_id); } - context.recording_painter().restore(); + context.display_list_recorder().restore(); } } @@ -572,12 +572,12 @@ void paint_cursor_if_needed(PaintContext& context, TextPaintable const& paintabl auto cursor_device_rect = context.rounded_device_rect(cursor_rect).to_type(); - context.recording_painter().draw_rect(cursor_device_rect, paintable.computed_values().color()); + context.display_list_recorder().draw_rect(cursor_device_rect, paintable.computed_values().color()); } void paint_text_decoration(PaintContext& context, TextPaintable const& paintable, PaintableFragment const& fragment) { - auto& painter = context.recording_painter(); + auto& painter = context.display_list_recorder(); auto& font = fragment.layout_node().first_available_font(); auto fragment_box = fragment.absolute_rect(); CSSPixels glyph_height = CSSPixels::nearest_value_for(font.pixel_size()); @@ -652,14 +652,14 @@ void paint_text_decoration(PaintContext& context, TextPaintable const& paintable void paint_text_fragment(PaintContext& context, TextPaintable const& paintable, PaintableFragment const& fragment, PaintPhase phase) { - auto& painter = context.recording_painter(); + auto& painter = context.display_list_recorder(); if (phase == PaintPhase::Foreground) { auto fragment_absolute_rect = fragment.absolute_rect(); auto fragment_absolute_device_rect = context.enclosing_device_rect(fragment_absolute_rect); if (paintable.document().inspected_layout_node() == &paintable.layout_node()) - context.recording_painter().draw_rect(fragment_absolute_device_rect.to_type(), Color::Magenta); + context.display_list_recorder().draw_rect(fragment_absolute_device_rect.to_type(), Color::Magenta); auto text = paintable.text_for_rendering(); @@ -670,7 +670,7 @@ void paint_text_fragment(PaintContext& context, TextPaintable const& paintable, auto selection_rect = context.enclosing_device_rect(fragment.selection_rect(paintable.layout_node().first_available_font())).to_type(); if (!selection_rect.is_empty()) { painter.fill_rect(selection_rect, CSS::SystemColor::highlight()); - RecordingPainterStateSaver saver(painter); + DisplayListRecorderStateSaver saver(painter); painter.add_clip_rect(selection_rect); painter.draw_text_run(baseline_start.to_type(), fragment.glyph_run(), CSS::SystemColor::highlight_text(), fragment_absolute_device_rect.to_type(), scale); } @@ -699,12 +699,12 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const should_clip_overflow = true; } if (should_clip_overflow) { - context.recording_painter().save(); + context.display_list_recorder().save(); // FIXME: Handle overflow-x and overflow-y being different values. auto clip_box_with_enclosing_scroll_frame_offset = clip_box; if (enclosing_scroll_frame_offset().has_value()) clip_box_with_enclosing_scroll_frame_offset.translate_by(enclosing_scroll_frame_offset().value()); - context.recording_painter().add_clip_rect(context.rounded_device_rect(clip_box_with_enclosing_scroll_frame_offset).to_type()); + context.display_list_recorder().add_clip_rect(context.rounded_device_rect(clip_box_with_enclosing_scroll_frame_offset).to_type()); auto border_radii = normalized_border_radii_data(ShrinkRadiiForBorders::Yes); CornerRadii corner_radii { @@ -715,12 +715,12 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const }; if (corner_radii.has_any_radius()) { corner_clip_id = context.allocate_corner_clipper_id(); - context.recording_painter().sample_under_corners(*corner_clip_id, corner_radii, context.rounded_device_rect(clip_box).to_type(), CornerClip::Outside); + context.display_list_recorder().sample_under_corners(*corner_clip_id, corner_radii, context.rounded_device_rect(clip_box).to_type(), CornerClip::Outside); } - context.recording_painter().save(); + context.display_list_recorder().save(); auto scroll_offset = context.rounded_device_point(this->scroll_offset()); - context.recording_painter().translate(-scroll_offset.to_type()); + context.display_list_recorder().translate(-scroll_offset.to_type()); } // Text shadows @@ -737,8 +737,8 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const auto fragment_absolute_rect = fragment.absolute_rect(); auto fragment_absolute_device_rect = context.enclosing_device_rect(fragment_absolute_rect); if (context.should_show_line_box_borders()) { - context.recording_painter().draw_rect(fragment_absolute_device_rect.to_type(), Color::Green); - context.recording_painter().draw_line( + context.display_list_recorder().draw_rect(fragment_absolute_device_rect.to_type(), Color::Green); + context.display_list_recorder().draw_line( context.rounded_device_point(fragment_absolute_rect.top_left().translated(0, fragment.baseline())).to_type(), context.rounded_device_point(fragment_absolute_rect.top_right().translated(-1, fragment.baseline())).to_type(), Color::Red); } @@ -747,12 +747,12 @@ void PaintableWithLines::paint(PaintContext& context, PaintPhase phase) const } if (should_clip_overflow) { - context.recording_painter().restore(); + context.display_list_recorder().restore(); if (corner_clip_id.has_value()) { - context.recording_painter().blit_corner_clipping(*corner_clip_id); + context.display_list_recorder().blit_corner_clipping(*corner_clip_id); corner_clip_id = {}; } - context.recording_painter().restore(); + context.display_list_recorder().restore(); } } diff --git a/Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.cpp b/Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.cpp index 8f25ee9a722..70b88b63792 100644 --- a/Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/RadioButtonPaintable.cpp @@ -40,7 +40,7 @@ void RadioButtonPaintable::paint(PaintContext& context, PaintPhase phase) const auto draw_circle = [&](auto const& rect, Color color) { // Note: Doing this is a bit more forgiving than draw_circle() which will round to the nearset even radius. // This will fudge it (which works better here). - context.recording_painter().fill_rect_with_rounded_corners(rect, color, rect.width() / 2); + context.display_list_recorder().fill_rect_with_rounded_corners(rect, color, rect.width() / 2); }; auto shrink_all = [&](auto const& rect, int amount) { diff --git a/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp b/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp index 6e50cebbc01..75c4f665f6e 100644 --- a/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp +++ b/Userland/Libraries/LibWeb/Painting/SVGMaskable.cpp @@ -82,9 +82,9 @@ RefPtr SVGMaskable::calculate_mask_of_svg(PaintContext& context, CS return {}; mask_bitmap = mask_bitmap_or_error.release_value(); DisplayList display_list; - RecordingPainter recording_painter(display_list); - recording_painter.translate(-mask_rect.location().to_type()); - auto paint_context = context.clone(recording_painter); + DisplayListRecorder display_list_recorder(display_list); + display_list_recorder.translate(-mask_rect.location().to_type()); + auto paint_context = context.clone(display_list_recorder); paint_context.set_svg_transform(graphics_element.get_transform()); paint_context.set_draw_svg_geometry_for_clip_path(is(paintable)); StackingContext::paint_node_as_stacking_context(paintable, paint_context); diff --git a/Userland/Libraries/LibWeb/Painting/SVGPathPaintable.cpp b/Userland/Libraries/LibWeb/Painting/SVGPathPaintable.cpp index cde608905bf..b532c27bdc5 100644 --- a/Userland/Libraries/LibWeb/Painting/SVGPathPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/SVGPathPaintable.cpp @@ -66,7 +66,7 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const auto svg_element_rect = svg_node->paintable_box()->absolute_rect(); // FIXME: This should not be trucated to an int. - RecordingPainterStateSaver save_painter { context.recording_painter() }; + DisplayListRecorderStateSaver save_painter { context.display_list_recorder() }; auto offset = context.floored_device_point(svg_element_rect.location()).to_type().to_type(); auto maybe_view_box = svg_node->dom_node().view_box(); @@ -98,7 +98,7 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const // The raw geometry of each child element exclusive of rendering properties such as fill, stroke, stroke-width // within a clipPath conceptually defines a 1-bit mask (with the possible exception of anti-aliasing along // the edge of the geometry) which represents the silhouette of the graphics associated with that element. - context.recording_painter().fill_path({ + context.display_list_recorder().fill_path({ .path = closed_path(), .color = Color::Black, .winding_rule = to_gfx_winding_rule(graphics_element.clip_rule().value_or(SVG::ClipRule::Nonzero)), @@ -116,7 +116,7 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const auto fill_opacity = graphics_element.fill_opacity().value_or(1); auto winding_rule = to_gfx_winding_rule(graphics_element.fill_rule().value_or(SVG::FillRule::Nonzero)); if (auto paint_style = graphics_element.fill_paint_style(paint_context); paint_style.has_value()) { - context.recording_painter().fill_path({ + context.display_list_recorder().fill_path({ .path = closed_path(), .paint_style = *paint_style, .winding_rule = winding_rule, @@ -124,7 +124,7 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const .translation = offset, }); } else if (auto fill_color = graphics_element.fill_color(); fill_color.has_value()) { - context.recording_painter().fill_path({ + context.display_list_recorder().fill_path({ .path = closed_path(), .color = fill_color->with_opacity(fill_opacity), .winding_rule = winding_rule, @@ -138,7 +138,7 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const float stroke_thickness = graphics_element.stroke_width().value_or(1) * viewbox_scale; if (auto paint_style = graphics_element.stroke_paint_style(paint_context); paint_style.has_value()) { - context.recording_painter().stroke_path({ + context.display_list_recorder().stroke_path({ .path = path, .paint_style = *paint_style, .thickness = stroke_thickness, @@ -146,7 +146,7 @@ void SVGPathPaintable::paint(PaintContext& context, PaintPhase phase) const .translation = offset, }); } else if (auto stroke_color = graphics_element.stroke_color(); stroke_color.has_value()) { - context.recording_painter().stroke_path({ + context.display_list_recorder().stroke_path({ .path = path, .color = stroke_color->with_opacity(stroke_opacity), .thickness = stroke_thickness, diff --git a/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp b/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp index 78146d373e0..5d749b99802 100644 --- a/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/SVGSVGPaintable.cpp @@ -31,10 +31,10 @@ void SVGSVGPaintable::before_children_paint(PaintContext& context, PaintPhase ph PaintableBox::before_children_paint(context, phase); if (phase != PaintPhase::Foreground) return; - context.recording_painter().save(); + context.display_list_recorder().save(); auto clip_rect = absolute_rect(); clip_rect.translate_by(enclosing_scroll_frame_offset().value_or({})); - context.recording_painter().add_clip_rect(context.enclosing_device_rect(clip_rect).to_type()); + context.display_list_recorder().add_clip_rect(context.enclosing_device_rect(clip_rect).to_type()); } void SVGSVGPaintable::after_children_paint(PaintContext& context, PaintPhase phase) const @@ -42,7 +42,7 @@ void SVGSVGPaintable::after_children_paint(PaintContext& context, PaintPhase pha PaintableBox::after_children_paint(context, phase); if (phase != PaintPhase::Foreground) return; - context.recording_painter().restore(); + context.display_list_recorder().restore(); } } diff --git a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp index 86d3822ed76..49f3bd60ca3 100644 --- a/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/ShadowPainting.cpp @@ -569,10 +569,10 @@ void paint_box_shadow(PaintContext& context, auto shrinked_border_radii = border_radii; shrinked_border_radii.shrink(borders_data.top.width, borders_data.right.width, borders_data.bottom.width, borders_data.left.width); ScopedCornerRadiusClip corner_clipper { context, device_content_rect, shrinked_border_radii, CornerClip::Outside }; - context.recording_painter().paint_inner_box_shadow_params(params); + context.display_list_recorder().paint_inner_box_shadow_params(params); } else { ScopedCornerRadiusClip corner_clipper { context, device_content_rect, border_radii, CornerClip::Inside }; - context.recording_painter().paint_outer_box_shadow_params(params); + context.display_list_recorder().paint_outer_box_shadow_params(params); } } } @@ -620,7 +620,7 @@ void paint_text_shadow(PaintContext& context, PaintableFragment const& fragment, draw_rect.y() + offset_y - margin }; - context.recording_painter().paint_text_shadow(blur_radius, bounding_rect, text_rect, scaled_glyph_run, layer.color, fragment_baseline, draw_location); + context.display_list_recorder().paint_text_shadow(blur_radius, bounding_rect, text_rect, scaled_glyph_run, layer.color, fragment_baseline, draw_location); } } diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 820b3448807..8a1cb27a2a0 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -276,7 +276,7 @@ void StackingContext::paint(PaintContext& context) const if (opacity == 0.0f) return; - RecordingPainterStateSaver saver(context.recording_painter()); + DisplayListRecorderStateSaver saver(context.display_list_recorder()); auto to_device_pixels_scale = float(context.device_pixels_per_css_pixel()); Gfx::IntRect source_paintable_rect; @@ -295,7 +295,7 @@ void StackingContext::paint(PaintContext& context) const transform_origin = paintable_box().transform_origin().to_type(); } - RecordingPainter::PushStackingContextParams push_stacking_context_params { + DisplayListRecorder::PushStackingContextParams push_stacking_context_params { .opacity = opacity, .is_fixed_position = paintable().is_fixed_position(), .source_paintable_rect = source_paintable_rect, @@ -322,13 +322,13 @@ void StackingContext::paint(PaintContext& context) const } } - context.recording_painter().save(); + context.display_list_recorder().save(); if (paintable().is_paintable_box() && paintable_box().scroll_frame_id().has_value()) - context.recording_painter().set_scroll_frame_id(*paintable_box().scroll_frame_id()); - context.recording_painter().push_stacking_context(push_stacking_context_params); + context.display_list_recorder().set_scroll_frame_id(*paintable_box().scroll_frame_id()); + context.display_list_recorder().push_stacking_context(push_stacking_context_params); paint_internal(context); - context.recording_painter().pop_stacking_context(); - context.recording_painter().restore(); + context.display_list_recorder().pop_stacking_context(); + context.display_list_recorder().restore(); } TraversalDecision StackingContext::hit_test(CSSPixelPoint position, HitTestType type, Function const& callback) const diff --git a/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp b/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp index 0ab45c66759..6b7cde0d4b5 100644 --- a/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/TableBordersPainting.cpp @@ -284,12 +284,12 @@ static void paint_collected_edges(PaintContext& context, Vector(), p2.to_type(), color, width.value(), Gfx::LineStyle::Dotted); + context.display_list_recorder().draw_line(p1.to_type(), p2.to_type(), color, width.value(), Gfx::LineStyle::Dotted); } else if (border_style == CSS::LineStyle::Dashed) { - context.recording_painter().draw_line(p1.to_type(), p2.to_type(), color, width.value(), Gfx::LineStyle::Dashed); + context.display_list_recorder().draw_line(p1.to_type(), p2.to_type(), color, width.value(), Gfx::LineStyle::Dashed); } else { // FIXME: Support the remaining line styles instead of rendering them as solid. - context.recording_painter().fill_rect(Gfx::IntRect(border_edge_painting_info.rect.location(), border_edge_painting_info.rect.size()), color); + context.display_list_recorder().fill_rect(Gfx::IntRect(border_edge_painting_info.rect.location(), border_edge_painting_info.rect.size()), color); } } } @@ -351,7 +351,7 @@ static void paint_separate_cell_borders(PaintableBox const& cell_box, HashMaprow_index, cell_box.table_cell_coordinates()->column_index }).value(); - paint_all_borders(context.recording_painter(), cell_rect, cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); + paint_all_borders(context.display_list_recorder(), cell_rect, cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); } void paint_table_borders(PaintContext& context, PaintableBox const& table_paintable) @@ -436,7 +436,7 @@ void paint_table_borders(PaintContext& context, PaintableBox const& table_painta .bottom = cell_box.box_model().border.bottom == 0 ? CSS::BorderData() : cell_box.computed_values().border_bottom(), .left = cell_box.box_model().border.left == 0 ? CSS::BorderData() : cell_box.computed_values().border_left(), }; - paint_all_borders(context.recording_painter(), context.rounded_device_rect(cell_box.absolute_border_box_rect()), cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); + paint_all_borders(context.display_list_recorder(), context.rounded_device_rect(cell_box.absolute_border_box_rect()), cell_box.normalized_border_radii_data().as_corners(context), borders_data.to_device_pixels(context)); } } } diff --git a/Userland/Libraries/LibWeb/Painting/VideoPaintable.cpp b/Userland/Libraries/LibWeb/Painting/VideoPaintable.cpp index ad467d8a5b4..9059006cd8d 100644 --- a/Userland/Libraries/LibWeb/Painting/VideoPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/VideoPaintable.cpp @@ -58,10 +58,10 @@ void VideoPaintable::paint(PaintContext& context, PaintPhase phase) const if (phase != PaintPhase::Foreground) return; - RecordingPainterStateSaver saver { context.recording_painter() }; + DisplayListRecorderStateSaver saver { context.display_list_recorder() }; auto video_rect = context.rounded_device_rect(absolute_rect()); - context.recording_painter().add_clip_rect(video_rect.to_type()); + context.display_list_recorder().add_clip_rect(video_rect.to_type()); ScopedCornerRadiusClip corner_clip { context, video_rect, normalized_border_radii_data(ShrinkRadiiForBorders::Yes) }; @@ -130,12 +130,12 @@ void VideoPaintable::paint(PaintContext& context, PaintPhase phase) const auto paint_frame = [&](auto const& frame) { auto scaling_mode = to_gfx_scaling_mode(computed_values().image_rendering(), frame->rect(), video_rect.to_type()); - context.recording_painter().draw_scaled_bitmap(video_rect.to_type(), *frame, frame->rect(), scaling_mode); + context.display_list_recorder().draw_scaled_bitmap(video_rect.to_type(), *frame, frame->rect(), scaling_mode); }; auto paint_transparent_black = [&]() { static constexpr auto transparent_black = Gfx::Color::from_argb(0x00'00'00'00); - context.recording_painter().fill_rect(video_rect.to_type(), transparent_black); + context.display_list_recorder().fill_rect(video_rect.to_type(), transparent_black); }; auto paint_loaded_video_controls = [&]() { @@ -211,8 +211,8 @@ void VideoPaintable::paint_placeholder_video_controls(PaintContext& context, Dev auto playback_button_is_hovered = mouse_position.has_value() && control_box_rect.contains(*mouse_position); auto playback_button_color = control_button_color(playback_button_is_hovered); - context.recording_painter().fill_ellipse(control_box_rect.to_type(), control_box_color); - fill_triangle(context.recording_painter(), playback_button_location.to_type(), play_button_coordinates, playback_button_color); + context.display_list_recorder().fill_ellipse(control_box_rect.to_type(), control_box_color); + fill_triangle(context.display_list_recorder(), playback_button_location.to_type(), play_button_coordinates, playback_button_color); } } diff --git a/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp b/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp index 405ce5b50b9..75ab3bd70cc 100644 --- a/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/ViewportPaintable.cpp @@ -63,7 +63,7 @@ void ViewportPaintable::build_stacking_context_tree() void ViewportPaintable::paint_all_phases(PaintContext& context) { build_stacking_context_tree_if_needed(); - context.recording_painter().translate(-context.device_viewport_rect().location().to_type()); + context.display_list_recorder().translate(-context.device_viewport_rect().location().to_type()); stacking_context()->paint(context); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 6c10b572431..52ede856b0a 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -94,9 +94,9 @@ RefPtr SVGDecodedImageData::render(Gfx::IntSize size) const m_document->update_layout(); Painting::DisplayList display_list; - Painting::RecordingPainter recording_painter(display_list); + Painting::DisplayListRecorder display_list_recorder(display_list); - m_document->navigable()->record_display_list(recording_painter, {}); + m_document->navigable()->record_display_list(display_list_recorder, {}); auto painting_command_executor_type = m_page_client->painting_command_executor_type(); switch (painting_command_executor_type) {