LibWeb: Rearrange code such that a lot less files include Command.h
Some checks failed
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Build Dev Container Image / build (push) Has been cancelled

With this change number of recompiled files after modification of
`Command.h` goes down from >1000 to <100.
This commit is contained in:
Aliaksandr Kalenik 2025-07-10 19:24:30 +02:00 committed by Alexander Kalenik
commit 410e82c9fd
Notes: github-actions[bot] 2025-07-11 15:38:35 +00:00
17 changed files with 95 additions and 73 deletions

View file

@ -149,6 +149,7 @@
#include <LibWeb/Layout/Viewport.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Namespace.h> #include <LibWeb/Namespace.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/ViewportPaintable.h> #include <LibWeb/Painting/ViewportPaintable.h>
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h> #include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
#include <LibWeb/ResizeObserver/ResizeObserver.h> #include <LibWeb/ResizeObserver/ResizeObserver.h>

View file

@ -35,7 +35,9 @@ AK_TYPEDEF_DISTINCT_NUMERIC_GENERAL(i64, UniqueNodeID, Comparison, Increment, Ca
namespace Web::Painting { namespace Web::Painting {
class BackingStore; class BackingStore;
class DisplayList; class DisplayList;
class DisplayListPlayerSkia;
class DisplayListRecorder; class DisplayListRecorder;
class SVGGradientPaintStyle; class SVGGradientPaintStyle;
using PaintStyle = RefPtr<SVGGradientPaintStyle>; using PaintStyle = RefPtr<SVGGradientPaintStyle>;
@ -840,6 +842,7 @@ class MediaPaintable;
class Paintable; class Paintable;
class PaintableBox; class PaintableBox;
class PaintableWithLines; class PaintableWithLines;
class ScrollStateSnapshot;
class StackingContext; class StackingContext;
class TextPaintable; class TextPaintable;
class VideoPaintable; class VideoPaintable;

View file

@ -45,6 +45,7 @@
#include <LibWeb/Layout/Viewport.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Loader/GeneratedPagesLoader.h> #include <LibWeb/Loader/GeneratedPagesLoader.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
#include <LibWeb/Painting/Paintable.h> #include <LibWeb/Painting/Paintable.h>
#include <LibWeb/Painting/ViewportPaintable.h> #include <LibWeb/Painting/ViewportPaintable.h>
#include <LibWeb/Platform/EventLoopPlugin.h> #include <LibWeb/Platform/EventLoopPlugin.h>
@ -2620,4 +2621,9 @@ void Navigable::start_display_list_rendering(Gfx::PaintingSurface& painting_surf
m_rendering_thread.enqueue_rendering_task(*display_list, move(scroll_state_snapshot), painting_surface, move(callback)); m_rendering_thread.enqueue_rendering_task(*display_list, move(scroll_state_snapshot), painting_surface, move(callback));
} }
RefPtr<Gfx::SkiaBackendContext> Navigable::skia_backend_context() const
{
return m_skia_backend_context;
}
} }

View file

@ -213,7 +213,7 @@ public:
bool needs_repaint() const { return m_needs_repaint; } bool needs_repaint() const { return m_needs_repaint; }
void set_needs_repaint() { m_needs_repaint = true; } void set_needs_repaint() { m_needs_repaint = true; }
RefPtr<Gfx::SkiaBackendContext> skia_backend_context() const { return m_skia_backend_context; } RefPtr<Gfx::SkiaBackendContext> skia_backend_context() const;
void set_pending_set_browser_zoom_request(bool value) { m_pending_set_browser_zoom_request = value; } void set_pending_set_browser_zoom_request(bool value) { m_pending_set_browser_zoom_request = value; }
bool pending_set_browser_zoom_request() const { return m_pending_set_browser_zoom_request; } bool pending_set_browser_zoom_request() const { return m_pending_set_browser_zoom_request; }

View file

@ -7,6 +7,7 @@
#include <LibCore/EventLoop.h> #include <LibCore/EventLoop.h>
#include <LibWeb/HTML/RenderingThread.h> #include <LibWeb/HTML/RenderingThread.h>
#include <LibWeb/HTML/TraversableNavigable.h> #include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
namespace Web::HTML { namespace Web::HTML {
@ -43,6 +44,11 @@ void RenderingThread::start(DisplayListPlayerType display_list_player_type)
m_thread->start(); m_thread->start();
} }
void RenderingThread::set_skia_player(OwnPtr<Painting::DisplayListPlayerSkia>&& player)
{
m_skia_player = move(player);
}
void RenderingThread::rendering_thread_loop() void RenderingThread::rendering_thread_loop()
{ {
while (true) { while (true) {

View file

@ -14,7 +14,7 @@
#include <LibThreading/Thread.h> #include <LibThreading/Thread.h>
#include <LibWeb/Forward.h> #include <LibWeb/Forward.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/DisplayListPlayerSkia.h> #include <LibWeb/Painting/ScrollState.h>
namespace Web::HTML { namespace Web::HTML {
@ -27,7 +27,7 @@ public:
~RenderingThread(); ~RenderingThread();
void start(DisplayListPlayerType); void start(DisplayListPlayerType);
void set_skia_player(OwnPtr<Painting::DisplayListPlayerSkia>&& player) { m_skia_player = move(player); } void set_skia_player(OwnPtr<Painting::DisplayListPlayerSkia>&& player);
void enqueue_rendering_task(NonnullRefPtr<Painting::DisplayList>, Painting::ScrollStateSnapshot&&, NonnullRefPtr<Gfx::PaintingSurface>, Function<void()>&& callback); void enqueue_rendering_task(NonnullRefPtr<Painting::DisplayList>, Painting::ScrollStateSnapshot&&, NonnullRefPtr<Gfx::PaintingSurface>, Function<void()>&& callback);
private: private:

View file

@ -12,11 +12,9 @@
#include <LibWeb/Geolocation/Geolocation.h> #include <LibWeb/Geolocation/Geolocation.h>
#include <LibWeb/HTML/Navigable.h> #include <LibWeb/HTML/Navigable.h>
#include <LibWeb/HTML/NavigationType.h> #include <LibWeb/HTML/NavigationType.h>
#include <LibWeb/HTML/RenderingThread.h>
#include <LibWeb/HTML/SessionHistoryTraversalQueue.h> #include <LibWeb/HTML/SessionHistoryTraversalQueue.h>
#include <LibWeb/HTML/VisibilityState.h> #include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/Page/Page.h> #include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
#include <LibWeb/StorageAPI/StorageShed.h> #include <LibWeb/StorageAPI/StorageShed.h>
#ifdef AK_OS_MACOS #ifdef AK_OS_MACOS

View file

@ -12,6 +12,7 @@
#include <LibWeb/Layout/Viewport.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/BackgroundPainting.h> #include <LibWeb/Painting/BackgroundPainting.h>
#include <LibWeb/Painting/Blending.h> #include <LibWeb/Painting/Blending.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/DisplayListRecorder.h> #include <LibWeb/Painting/DisplayListRecorder.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
@ -325,7 +326,7 @@ void paint_background(PaintContext& context, PaintableBox const& paintable_box,
auto const* bitmap = static_cast<CSS::ImageStyleValue const&>(image).current_frame_bitmap(dest_rect); auto const* bitmap = static_cast<CSS::ImageStyleValue const&>(image).current_frame_bitmap(dest_rect);
auto scaling_mode = to_gfx_scaling_mode(image_rendering, bitmap->rect(), dest_rect.to_type<int>()); auto scaling_mode = to_gfx_scaling_mode(image_rendering, bitmap->rect(), dest_rect.to_type<int>());
context.display_list_recorder().draw_repeated_immutable_bitmap(dest_rect.to_type<int>(), clip_rect.to_type<int>(), *bitmap, scaling_mode, { .x = repeat_x, .y = repeat_y }); context.display_list_recorder().draw_repeated_immutable_bitmap(dest_rect.to_type<int>(), clip_rect.to_type<int>(), *bitmap, scaling_mode, repeat_x, repeat_y);
} else { } else {
for_each_image_device_rect([&](auto const& image_device_rect) { for_each_image_device_rect([&](auto const& image_device_rect) {
image.paint(context, image_device_rect, image_rendering); image.paint(context, image_device_rect, image_rendering);

View file

@ -5,6 +5,7 @@
*/ */
#include <LibCore/Timer.h> #include <LibCore/Timer.h>
#include <LibGfx/PaintingSurface.h>
#include <LibWeb/HTML/TraversableNavigable.h> #include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/Painting/BackingStoreManager.h> #include <LibWeb/Painting/BackingStoreManager.h>
#include <WebContent/PageClient.h> #include <WebContent/PageClient.h>
@ -46,6 +47,15 @@ void BackingStoreManager::restart_resize_timer()
m_backing_store_shrink_timer->restart(); m_backing_store_shrink_timer->restart();
} }
BackingStoreManager::BackingStore BackingStoreManager::acquire_store_for_next_frame()
{
BackingStore backing_store;
backing_store.bitmap_id = m_back_bitmap_id;
backing_store.store = m_back_store;
swap_back_and_front();
return backing_store;
}
void BackingStoreManager::reallocate_backing_stores(Gfx::IntSize size) void BackingStoreManager::reallocate_backing_stores(Gfx::IntSize size)
{ {
auto skia_backend_context = m_navigable->skia_backend_context(); auto skia_backend_context = m_navigable->skia_backend_context();

View file

@ -32,14 +32,7 @@ public:
RefPtr<Gfx::PaintingSurface> store; RefPtr<Gfx::PaintingSurface> store;
}; };
BackingStore acquire_store_for_next_frame() BackingStore acquire_store_for_next_frame();
{
BackingStore backing_store;
backing_store.bitmap_id = m_back_bitmap_id;
backing_store.store = m_back_store;
swap_back_and_front();
return backing_store;
}
virtual void visit_edges(Cell::Visitor& visitor) override; virtual void visit_edges(Cell::Visitor& visitor) override;

View file

@ -6,6 +6,7 @@
#include <LibWeb/HTML/TraversableNavigable.h> #include <LibWeb/HTML/TraversableNavigable.h>
#include <LibWeb/Painting/CanvasPaintable.h> #include <LibWeb/Painting/CanvasPaintable.h>
#include <LibWeb/Painting/DisplayListRecorder.h>
namespace Web::Painting { namespace Web::Painting {

View file

@ -29,6 +29,7 @@
#include <LibWeb/CSS/Enums.h> #include <LibWeb/CSS/Enums.h>
#include <LibWeb/Painting/BorderRadiiData.h> #include <LibWeb/Painting/BorderRadiiData.h>
#include <LibWeb/Painting/BorderRadiusCornerClipper.h> #include <LibWeb/Painting/BorderRadiusCornerClipper.h>
#include <LibWeb/Painting/DisplayListRecorder.h>
#include <LibWeb/Painting/GradientData.h> #include <LibWeb/Painting/GradientData.h>
#include <LibWeb/Painting/PaintBoxShadowParams.h> #include <LibWeb/Painting/PaintBoxShadowParams.h>
#include <LibWeb/Painting/PaintStyle.h> #include <LibWeb/Painting/PaintStyle.h>
@ -114,11 +115,6 @@ struct AddClipRect {
void translate_by(Gfx::IntPoint const& offset) { rect.translate_by(offset); } void translate_by(Gfx::IntPoint const& offset) { rect.translate_by(offset); }
}; };
struct StackingContextTransform {
Gfx::FloatPoint origin;
Gfx::FloatMatrix4x4 matrix;
};
struct PushStackingContext { struct PushStackingContext {
float opacity; float opacity;
Gfx::CompositingAndBlendingOperator compositing_and_blending_operator; Gfx::CompositingAndBlendingOperator compositing_and_blending_operator;

View file

@ -6,8 +6,9 @@
#pragma once #pragma once
#include <LibGfx/PaintingSurface.h>
#include <LibGfx/SkiaBackendContext.h> #include <LibGfx/SkiaBackendContext.h>
#include <LibWeb/Painting/Command.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/DisplayListRecorder.h> #include <LibWeb/Painting/DisplayListRecorder.h>
class GrDirectContext; class GrDirectContext;

View file

@ -4,6 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <LibWeb/Painting/Command.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/DisplayListRecorder.h> #include <LibWeb/Painting/DisplayListRecorder.h>
#include <LibWeb/Painting/ShadowPainting.h> #include <LibWeb/Painting/ShadowPainting.h>
@ -16,34 +18,34 @@ DisplayListRecorder::DisplayListRecorder(DisplayList& command_list)
DisplayListRecorder::~DisplayListRecorder() = default; DisplayListRecorder::~DisplayListRecorder() = default;
void DisplayListRecorder::append(Command&& command) #define APPEND(...) \
{ do { \
Optional<i32> scroll_frame_id; Optional<i32> _scroll_frame_id; \
if (!m_scroll_frame_id_stack.is_empty()) if (!m_scroll_frame_id_stack.is_empty()) \
scroll_frame_id = m_scroll_frame_id_stack.last(); _scroll_frame_id = m_scroll_frame_id_stack.last(); \
m_command_list.append(move(command), scroll_frame_id); m_command_list.append(__VA_ARGS__, _scroll_frame_id); \
} } while (false)
void DisplayListRecorder::paint_nested_display_list(RefPtr<DisplayList> display_list, ScrollStateSnapshot&& scroll_state_snapshot, Gfx::IntRect rect) void DisplayListRecorder::paint_nested_display_list(RefPtr<DisplayList> display_list, ScrollStateSnapshot&& scroll_state_snapshot, Gfx::IntRect rect)
{ {
append(PaintNestedDisplayList { move(display_list), move(scroll_state_snapshot), rect }); APPEND(PaintNestedDisplayList { move(display_list), move(scroll_state_snapshot), rect });
} }
void DisplayListRecorder::add_rounded_rect_clip(CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip) void DisplayListRecorder::add_rounded_rect_clip(CornerRadii corner_radii, Gfx::IntRect border_rect, CornerClip corner_clip)
{ {
append(AddRoundedRectClip { corner_radii, border_rect, corner_clip }); APPEND(AddRoundedRectClip { corner_radii, border_rect, corner_clip });
} }
void DisplayListRecorder::add_mask(RefPtr<DisplayList> display_list, Gfx::IntRect rect) void DisplayListRecorder::add_mask(RefPtr<DisplayList> display_list, Gfx::IntRect rect)
{ {
append(AddMask { move(display_list), rect }); APPEND(AddMask { move(display_list), rect });
} }
void DisplayListRecorder::fill_rect(Gfx::IntRect const& rect, Color color) void DisplayListRecorder::fill_rect(Gfx::IntRect const& rect, Color color)
{ {
if (rect.is_empty() || color.alpha() == 0) if (rect.is_empty() || color.alpha() == 0)
return; return;
append(FillRect { rect, color }); APPEND(FillRect { rect, color });
} }
void DisplayListRecorder::fill_path(FillPathUsingColorParams params) void DisplayListRecorder::fill_path(FillPathUsingColorParams params)
@ -55,7 +57,7 @@ void DisplayListRecorder::fill_path(FillPathUsingColorParams params)
auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect); auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect);
if (path_bounding_int_rect.is_empty()) if (path_bounding_int_rect.is_empty())
return; return;
append(FillPathUsingColor { APPEND(FillPathUsingColor {
.path_bounding_rect = path_bounding_int_rect, .path_bounding_rect = path_bounding_int_rect,
.path = move(params.path), .path = move(params.path),
.color = params.color, .color = params.color,
@ -71,7 +73,7 @@ void DisplayListRecorder::fill_path(FillPathUsingPaintStyleParams params)
auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect); auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect);
if (path_bounding_int_rect.is_empty()) if (path_bounding_int_rect.is_empty())
return; return;
append(FillPathUsingPaintStyle { APPEND(FillPathUsingPaintStyle {
.path_bounding_rect = path_bounding_int_rect, .path_bounding_rect = path_bounding_int_rect,
.path = move(params.path), .path = move(params.path),
.paint_style = params.paint_style, .paint_style = params.paint_style,
@ -92,7 +94,7 @@ void DisplayListRecorder::stroke_path(StrokePathUsingColorParams params)
auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect); auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect);
if (path_bounding_int_rect.is_empty()) if (path_bounding_int_rect.is_empty())
return; return;
append(StrokePathUsingColor { APPEND(StrokePathUsingColor {
.cap_style = params.cap_style, .cap_style = params.cap_style,
.join_style = params.join_style, .join_style = params.join_style,
.miter_limit = params.miter_limit, .miter_limit = params.miter_limit,
@ -115,7 +117,7 @@ void DisplayListRecorder::stroke_path(StrokePathUsingPaintStyleParams params)
auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect); auto path_bounding_int_rect = enclosing_int_rect(path_bounding_rect);
if (path_bounding_int_rect.is_empty()) if (path_bounding_int_rect.is_empty())
return; return;
append(StrokePathUsingPaintStyle { APPEND(StrokePathUsingPaintStyle {
.cap_style = params.cap_style, .cap_style = params.cap_style,
.join_style = params.join_style, .join_style = params.join_style,
.miter_limit = params.miter_limit, .miter_limit = params.miter_limit,
@ -134,7 +136,7 @@ void DisplayListRecorder::draw_ellipse(Gfx::IntRect const& a_rect, Color color,
{ {
if (a_rect.is_empty() || color.alpha() == 0) if (a_rect.is_empty() || color.alpha() == 0)
return; return;
append(DrawEllipse { APPEND(DrawEllipse {
.rect = a_rect, .rect = a_rect,
.color = color, .color = color,
.thickness = thickness, .thickness = thickness,
@ -145,21 +147,21 @@ void DisplayListRecorder::fill_ellipse(Gfx::IntRect const& a_rect, Color color)
{ {
if (a_rect.is_empty() || color.alpha() == 0) if (a_rect.is_empty() || color.alpha() == 0)
return; return;
append(FillEllipse { a_rect, color }); APPEND(FillEllipse { a_rect, color });
} }
void DisplayListRecorder::fill_rect_with_linear_gradient(Gfx::IntRect const& gradient_rect, LinearGradientData const& data) void DisplayListRecorder::fill_rect_with_linear_gradient(Gfx::IntRect const& gradient_rect, LinearGradientData const& data)
{ {
if (gradient_rect.is_empty()) if (gradient_rect.is_empty())
return; return;
append(PaintLinearGradient { gradient_rect, data }); APPEND(PaintLinearGradient { gradient_rect, data });
} }
void DisplayListRecorder::fill_rect_with_conic_gradient(Gfx::IntRect const& rect, ConicGradientData const& data, Gfx::IntPoint const& position) void DisplayListRecorder::fill_rect_with_conic_gradient(Gfx::IntRect const& rect, ConicGradientData const& data, Gfx::IntPoint const& position)
{ {
if (rect.is_empty()) if (rect.is_empty())
return; return;
append(PaintConicGradient { APPEND(PaintConicGradient {
.rect = rect, .rect = rect,
.conic_gradient_data = data, .conic_gradient_data = data,
.position = position }); .position = position });
@ -169,7 +171,7 @@ void DisplayListRecorder::fill_rect_with_radial_gradient(Gfx::IntRect const& rec
{ {
if (rect.is_empty()) if (rect.is_empty())
return; return;
append(PaintRadialGradient { APPEND(PaintRadialGradient {
.rect = rect, .rect = rect,
.radial_gradient_data = data, .radial_gradient_data = data,
.center = center, .center = center,
@ -180,7 +182,7 @@ void DisplayListRecorder::draw_rect(Gfx::IntRect const& rect, Color color, bool
{ {
if (rect.is_empty() || color.alpha() == 0) if (rect.is_empty() || color.alpha() == 0)
return; return;
append(DrawRect { APPEND(DrawRect {
.rect = rect, .rect = rect,
.color = color, .color = color,
.rough = rough }); .rough = rough });
@ -190,7 +192,7 @@ void DisplayListRecorder::draw_painting_surface(Gfx::IntRect const& dst_rect, No
{ {
if (dst_rect.is_empty()) if (dst_rect.is_empty())
return; return;
append(DrawPaintingSurface { APPEND(DrawPaintingSurface {
.dst_rect = dst_rect, .dst_rect = dst_rect,
.surface = surface, .surface = surface,
.src_rect = src_rect, .src_rect = src_rect,
@ -202,7 +204,7 @@ void DisplayListRecorder::draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_r
{ {
if (dst_rect.is_empty()) if (dst_rect.is_empty())
return; return;
append(DrawScaledImmutableBitmap { APPEND(DrawScaledImmutableBitmap {
.dst_rect = dst_rect, .dst_rect = dst_rect,
.clip_rect = clip_rect, .clip_rect = clip_rect,
.bitmap = bitmap, .bitmap = bitmap,
@ -210,14 +212,14 @@ void DisplayListRecorder::draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_r
}); });
} }
void DisplayListRecorder::draw_repeated_immutable_bitmap(Gfx::IntRect dst_rect, Gfx::IntRect clip_rect, NonnullRefPtr<Gfx::ImmutableBitmap const> bitmap, Gfx::ScalingMode scaling_mode, DrawRepeatedImmutableBitmap::Repeat repeat) void DisplayListRecorder::draw_repeated_immutable_bitmap(Gfx::IntRect dst_rect, Gfx::IntRect clip_rect, NonnullRefPtr<Gfx::ImmutableBitmap const> bitmap, Gfx::ScalingMode scaling_mode, bool repeat_x, bool repeat_y)
{ {
append(DrawRepeatedImmutableBitmap { APPEND(DrawRepeatedImmutableBitmap {
.dst_rect = dst_rect, .dst_rect = dst_rect,
.clip_rect = clip_rect, .clip_rect = clip_rect,
.bitmap = move(bitmap), .bitmap = move(bitmap),
.scaling_mode = scaling_mode, .scaling_mode = scaling_mode,
.repeat = repeat, .repeat = { repeat_x, repeat_y },
}); });
} }
@ -225,7 +227,7 @@ void DisplayListRecorder::draw_line(Gfx::IntPoint from, Gfx::IntPoint to, Color
{ {
if (color.alpha() == 0) if (color.alpha() == 0)
return; return;
append(DrawLine { APPEND(DrawLine {
.color = color, .color = color,
.from = from, .from = from,
.to = to, .to = to,
@ -261,7 +263,7 @@ void DisplayListRecorder::draw_text_run(Gfx::FloatPoint baseline_start, Gfx::Gly
{ {
if (color.alpha() == 0) if (color.alpha() == 0)
return; return;
append(DrawGlyphRun { APPEND(DrawGlyphRun {
.glyph_run = glyph_run, .glyph_run = glyph_run,
.scale = scale, .scale = scale,
.rect = rect, .rect = rect,
@ -273,30 +275,30 @@ void DisplayListRecorder::draw_text_run(Gfx::FloatPoint baseline_start, Gfx::Gly
void DisplayListRecorder::add_clip_rect(Gfx::IntRect const& rect) void DisplayListRecorder::add_clip_rect(Gfx::IntRect const& rect)
{ {
append(AddClipRect { rect }); APPEND(AddClipRect { rect });
} }
void DisplayListRecorder::translate(Gfx::IntPoint delta) void DisplayListRecorder::translate(Gfx::IntPoint delta)
{ {
append(Translate { delta }); APPEND(Translate { delta });
} }
void DisplayListRecorder::save() void DisplayListRecorder::save()
{ {
++m_save_nesting_level; ++m_save_nesting_level;
append(Save {}); APPEND(Save {});
} }
void DisplayListRecorder::save_layer() void DisplayListRecorder::save_layer()
{ {
++m_save_nesting_level; ++m_save_nesting_level;
append(SaveLayer {}); APPEND(SaveLayer {});
} }
void DisplayListRecorder::restore() void DisplayListRecorder::restore()
{ {
--m_save_nesting_level; --m_save_nesting_level;
append(Restore {}); APPEND(Restore {});
} }
void DisplayListRecorder::push_scroll_frame_id(Optional<i32> id) void DisplayListRecorder::push_scroll_frame_id(Optional<i32> id)
@ -311,7 +313,7 @@ void DisplayListRecorder::pop_scroll_frame_id()
void DisplayListRecorder::push_stacking_context(PushStackingContextParams params) void DisplayListRecorder::push_stacking_context(PushStackingContextParams params)
{ {
append(PushStackingContext { APPEND(PushStackingContext {
.opacity = params.opacity, .opacity = params.opacity,
.compositing_and_blending_operator = params.compositing_and_blending_operator, .compositing_and_blending_operator = params.compositing_and_blending_operator,
.isolate = params.isolate, .isolate = params.isolate,
@ -325,14 +327,14 @@ void DisplayListRecorder::push_stacking_context(PushStackingContextParams params
void DisplayListRecorder::pop_stacking_context() void DisplayListRecorder::pop_stacking_context()
{ {
append(PopStackingContext {}); APPEND(PopStackingContext {});
} }
void DisplayListRecorder::apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, Gfx::Filter const& backdrop_filter) void DisplayListRecorder::apply_backdrop_filter(Gfx::IntRect const& backdrop_region, BorderRadiiData const& border_radii_data, Gfx::Filter const& backdrop_filter)
{ {
if (backdrop_region.is_empty()) if (backdrop_region.is_empty())
return; return;
append(ApplyBackdropFilter { APPEND(ApplyBackdropFilter {
.backdrop_region = backdrop_region, .backdrop_region = backdrop_region,
.border_radii_data = border_radii_data, .border_radii_data = border_radii_data,
.backdrop_filter = backdrop_filter, .backdrop_filter = backdrop_filter,
@ -341,17 +343,17 @@ void DisplayListRecorder::apply_backdrop_filter(Gfx::IntRect const& backdrop_reg
void DisplayListRecorder::paint_outer_box_shadow_params(PaintBoxShadowParams params) void DisplayListRecorder::paint_outer_box_shadow_params(PaintBoxShadowParams params)
{ {
append(PaintOuterBoxShadow { .box_shadow_params = params }); APPEND(PaintOuterBoxShadow { .box_shadow_params = params });
} }
void DisplayListRecorder::paint_inner_box_shadow_params(PaintBoxShadowParams params) void DisplayListRecorder::paint_inner_box_shadow_params(PaintBoxShadowParams params)
{ {
append(PaintInnerBoxShadow { .box_shadow_params = params }); APPEND(PaintInnerBoxShadow { .box_shadow_params = params });
} }
void DisplayListRecorder::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const& glyph_run, double glyph_run_scale, Color color, Gfx::FloatPoint draw_location) void DisplayListRecorder::paint_text_shadow(int blur_radius, Gfx::IntRect bounding_rect, Gfx::IntRect text_rect, Gfx::GlyphRun const& glyph_run, double glyph_run_scale, Color color, Gfx::FloatPoint draw_location)
{ {
append(PaintTextShadow { APPEND(PaintTextShadow {
.glyph_run = glyph_run, .glyph_run = glyph_run,
.glyph_run_scale = glyph_run_scale, .glyph_run_scale = glyph_run_scale,
.shadow_bounding_rect = bounding_rect, .shadow_bounding_rect = bounding_rect,
@ -371,7 +373,7 @@ void DisplayListRecorder::fill_rect_with_rounded_corners(Gfx::IntRect const& rec
return; return;
} }
append(FillRectWithRoundedCorners { APPEND(FillRectWithRoundedCorners {
.rect = rect, .rect = rect,
.color = color, .color = color,
.corner_radii = { .corner_radii = {
@ -405,7 +407,7 @@ void DisplayListRecorder::draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a
{ {
if (color.alpha() == 0) if (color.alpha() == 0)
return; return;
append(DrawTriangleWave { APPEND(DrawTriangleWave {
.p1 = a_p1, .p1 = a_p1,
.p2 = a_p2, .p2 = a_p2,
.color = color, .color = color,
@ -415,7 +417,7 @@ void DisplayListRecorder::draw_triangle_wave(Gfx::IntPoint a_p1, Gfx::IntPoint a
void DisplayListRecorder::paint_scrollbar(int scroll_frame_id, Gfx::IntRect gutter_rect, Gfx::IntRect thumb_rect, CSSPixelFraction scroll_size, Color thumb_color, Color track_color, bool vertical) void DisplayListRecorder::paint_scrollbar(int scroll_frame_id, Gfx::IntRect gutter_rect, Gfx::IntRect thumb_rect, CSSPixelFraction scroll_size, Color thumb_color, Color track_color, bool vertical)
{ {
append(PaintScrollBar { APPEND(PaintScrollBar {
.scroll_frame_id = scroll_frame_id, .scroll_frame_id = scroll_frame_id,
.gutter_rect = gutter_rect, .gutter_rect = gutter_rect,
.thumb_rect = thumb_rect, .thumb_rect = thumb_rect,
@ -429,26 +431,26 @@ void DisplayListRecorder::apply_opacity(float opacity)
{ {
// Implementation of this item does saveLayer(), so we need to increment the nesting level. // Implementation of this item does saveLayer(), so we need to increment the nesting level.
++m_save_nesting_level; ++m_save_nesting_level;
append(ApplyOpacity { .opacity = opacity }); APPEND(ApplyOpacity { .opacity = opacity });
} }
void DisplayListRecorder::apply_compositing_and_blending_operator(Gfx::CompositingAndBlendingOperator compositing_and_blending_operator) void DisplayListRecorder::apply_compositing_and_blending_operator(Gfx::CompositingAndBlendingOperator compositing_and_blending_operator)
{ {
// Implementation of this item does saveLayer(), so we need to increment the nesting level. // Implementation of this item does saveLayer(), so we need to increment the nesting level.
m_save_nesting_level++; m_save_nesting_level++;
append(ApplyCompositeAndBlendingOperator { .compositing_and_blending_operator = compositing_and_blending_operator }); APPEND(ApplyCompositeAndBlendingOperator { .compositing_and_blending_operator = compositing_and_blending_operator });
} }
void DisplayListRecorder::apply_filter(Gfx::Filter filter) void DisplayListRecorder::apply_filter(Gfx::Filter filter)
{ {
// Implementation of this item does saveLayer(), so we need to increment the nesting level. // Implementation of this item does saveLayer(), so we need to increment the nesting level.
++m_save_nesting_level; ++m_save_nesting_level;
append(ApplyFilter { .filter = move(filter) }); APPEND(ApplyFilter { .filter = move(filter) });
} }
void DisplayListRecorder::apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatrix4x4 matrix) void DisplayListRecorder::apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatrix4x4 matrix)
{ {
append(ApplyTransform { APPEND(ApplyTransform {
.origin = origin, .origin = origin,
.matrix = matrix, .matrix = matrix,
}); });
@ -456,7 +458,7 @@ void DisplayListRecorder::apply_transform(Gfx::FloatPoint origin, Gfx::FloatMatr
void DisplayListRecorder::apply_mask_bitmap(Gfx::IntPoint origin, Gfx::ImmutableBitmap const& bitmap, Gfx::Bitmap::MaskKind kind) void DisplayListRecorder::apply_mask_bitmap(Gfx::IntPoint origin, Gfx::ImmutableBitmap const& bitmap, Gfx::Bitmap::MaskKind kind)
{ {
append(ApplyMaskBitmap { APPEND(ApplyMaskBitmap {
.origin = origin, .origin = origin,
.bitmap = bitmap, .bitmap = bitmap,
.kind = kind, .kind = kind,

View file

@ -7,26 +7,30 @@
#pragma once #pragma once
#include <AK/Forward.h> #include <AK/Forward.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibGfx/Color.h> #include <LibGfx/Color.h>
#include <LibGfx/Forward.h> #include <LibGfx/Forward.h>
#include <LibGfx/ImmutableBitmap.h> #include <LibGfx/ImmutableBitmap.h>
#include <LibGfx/LineStyle.h>
#include <LibGfx/PaintStyle.h> #include <LibGfx/PaintStyle.h>
#include <LibGfx/Palette.h> #include <LibGfx/Palette.h>
#include <LibGfx/Path.h> #include <LibGfx/Path.h>
#include <LibGfx/Point.h> #include <LibGfx/Point.h>
#include <LibGfx/Rect.h> #include <LibGfx/Rect.h>
#include <LibGfx/ScalingMode.h> #include <LibGfx/ScalingMode.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Painting/BorderRadiiData.h> #include <LibWeb/Painting/BorderRadiiData.h>
#include <LibWeb/Painting/BorderRadiusCornerClipper.h> #include <LibWeb/Painting/BorderRadiusCornerClipper.h>
#include <LibWeb/Painting/Command.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/GradientData.h> #include <LibWeb/Painting/GradientData.h>
#include <LibWeb/Painting/PaintBoxShadowParams.h> #include <LibWeb/Painting/PaintBoxShadowParams.h>
namespace Web::Painting { namespace Web::Painting {
struct StackingContextTransform {
Gfx::FloatPoint origin;
Gfx::FloatMatrix4x4 matrix;
};
class DisplayListRecorder { class DisplayListRecorder {
AK_MAKE_NONCOPYABLE(DisplayListRecorder); AK_MAKE_NONCOPYABLE(DisplayListRecorder);
AK_MAKE_NONMOVABLE(DisplayListRecorder); AK_MAKE_NONMOVABLE(DisplayListRecorder);
@ -91,7 +95,7 @@ public:
void draw_painting_surface(Gfx::IntRect const& dst_rect, NonnullRefPtr<Gfx::PaintingSurface>, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode = Gfx::ScalingMode::NearestNeighbor); void draw_painting_surface(Gfx::IntRect const& dst_rect, NonnullRefPtr<Gfx::PaintingSurface>, Gfx::IntRect const& src_rect, Gfx::ScalingMode scaling_mode = Gfx::ScalingMode::NearestNeighbor);
void draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_rect, Gfx::IntRect const& clip_rect, Gfx::ImmutableBitmap const& bitmap, Gfx::ScalingMode scaling_mode = Gfx::ScalingMode::NearestNeighbor); void draw_scaled_immutable_bitmap(Gfx::IntRect const& dst_rect, Gfx::IntRect const& clip_rect, Gfx::ImmutableBitmap const& bitmap, Gfx::ScalingMode scaling_mode = Gfx::ScalingMode::NearestNeighbor);
void draw_repeated_immutable_bitmap(Gfx::IntRect dst_rect, Gfx::IntRect clip_rect, NonnullRefPtr<Gfx::ImmutableBitmap const> bitmap, Gfx::ScalingMode scaling_mode, DrawRepeatedImmutableBitmap::Repeat); void draw_repeated_immutable_bitmap(Gfx::IntRect dst_rect, Gfx::IntRect clip_rect, NonnullRefPtr<Gfx::ImmutableBitmap const> bitmap, Gfx::ScalingMode scaling_mode, bool repeat_x, bool repeat_y);
void draw_line(Gfx::IntPoint from, Gfx::IntPoint to, Color color, int thickness = 1, Gfx::LineStyle style = Gfx::LineStyle::Solid, Color alternate_color = Color::Transparent); void draw_line(Gfx::IntPoint from, Gfx::IntPoint to, Color color, int thickness = 1, Gfx::LineStyle style = Gfx::LineStyle::Solid, Color alternate_color = Color::Transparent);
@ -153,8 +157,6 @@ public:
DisplayList& display_list() { return m_command_list; } DisplayList& display_list() { return m_command_list; }
void append(Command&& command);
int m_save_nesting_level { 0 }; int m_save_nesting_level { 0 };
private: private:

View file

@ -9,6 +9,7 @@
#include <LibWeb/Layout/NavigableContainerViewport.h> #include <LibWeb/Layout/NavigableContainerViewport.h>
#include <LibWeb/Layout/Viewport.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/BorderRadiusCornerClipper.h> #include <LibWeb/Painting/BorderRadiusCornerClipper.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/DisplayListRecorder.h> #include <LibWeb/Painting/DisplayListRecorder.h>
#include <LibWeb/Painting/NavigableContainerViewportPaintable.h> #include <LibWeb/Painting/NavigableContainerViewportPaintable.h>
#include <LibWeb/Painting/ViewportPaintable.h> #include <LibWeb/Painting/ViewportPaintable.h>

View file

@ -15,6 +15,7 @@
#include <LibWeb/Layout/ReplacedBox.h> #include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/Viewport.h> #include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/Blending.h> #include <LibWeb/Painting/Blending.h>
#include <LibWeb/Painting/DisplayList.h>
#include <LibWeb/Painting/DisplayListRecorder.h> #include <LibWeb/Painting/DisplayListRecorder.h>
#include <LibWeb/Painting/PaintableBox.h> #include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/SVGSVGPaintable.h> #include <LibWeb/Painting/SVGSVGPaintable.h>