|
@@ -4,28 +4,28 @@
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
*/
|
|
|
|
|
|
-#include <LibWeb/Painting/RecordingPainter.h>
|
|
|
+#include <LibWeb/Painting/DisplayListRecorder.h>
|
|
|
#include <LibWeb/Painting/ShadowPainting.h>
|
|
|
|
|
|
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<Gfx::Path> const& clip_paths)
|
|
|
+void DisplayListRecorder::fill_rect(Gfx::IntRect const& rect, Color color, Vector<Gfx::Path> const& clip_paths)
|
|
|
{
|
|
|
if (rect.is_empty())
|
|
|
return;
|
|
@@ -55,7 +55,7 @@ void RecordingPainter::fill_rect(Gfx::IntRect const& rect, Color color, Vector<G
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-void RecordingPainter::fill_path(FillPathUsingColorParams params)
|
|
|
+void DisplayListRecorder::fill_path(FillPathUsingColorParams 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<int>();
|
|
@@ -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<int>();
|
|
@@ -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<int>();
|
|
@@ -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<int>();
|
|
@@ -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<Gfx::Path> const& clip_paths)
|
|
|
+void DisplayListRecorder::fill_rect_with_linear_gradient(Gfx::IntRect const& gradient_rect, LinearGradientData const& data, Vector<Gfx::Path> 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<Gfx::Path> const& clip_paths)
|
|
|
+void DisplayListRecorder::fill_rect_with_conic_gradient(Gfx::IntRect const& rect, ConicGradientData const& data, Gfx::IntPoint const& position, Vector<Gfx::Path> 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<Gfx::Path> const& clip_paths)
|
|
|
+void DisplayListRecorder::fill_rect_with_radial_gradient(Gfx::IntRect const& rect, RadialGradientData const& data, Gfx::IntPoint center, Gfx::IntSize size, Vector<Gfx::Path> 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<Gfx::Path> 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<Gfx::Path> 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<float>());
|
|
|
}
|
|
|
|
|
|
-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<Gfx::DrawGlyphOrEmoji const> 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<Gfx::DrawGlyphOrEmoji const> 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<Gfx::Path> 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<Gfx::Path> 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<Gfx::Path> const& clip_paths)
|
|
|
+void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& a_rect, Color color, int radius, Vector<Gfx::Path> 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<Gfx::Path> 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<Gfx::Path> 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),
|