From 0b48c1ea3f06a0f291d07f20c6f16a11af653efb Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Wed, 19 Jun 2024 16:44:42 +0300 Subject: [PATCH] Everywhere: Remove AffineCommandExecutorCPU No need to have it after introduction of Skia painter that supports transforms. --- Ladybird/HelperProcess.cpp | 2 - Ladybird/Qt/main.cpp | 3 - Ladybird/Types.h | 6 - Ladybird/WebContent/main.cpp | 6 - .../Libraries/LibWeb/Painting/BUILD.gn | 1 - Userland/Libraries/LibWeb/CMakeLists.txt | 1 - .../LibWeb/HTML/TraversableNavigable.cpp | 2 +- Userland/Libraries/LibWeb/Page/Page.h | 1 - .../Painting/AffineCommandExecutorCPU.cpp | 286 ------------------ .../Painting/AffineCommandExecutorCPU.h | 89 ------ .../LibWeb/Painting/CommandExecutorCPU.cpp | 17 +- .../LibWeb/Painting/CommandExecutorCPU.h | 11 +- .../Libraries/LibWeb/Painting/CommandList.cpp | 17 +- .../Libraries/LibWeb/Painting/CommandList.h | 3 - .../LibWeb/SVG/SVGDecodedImageData.cpp | 1 - Userland/Services/WebContent/PageClient.cpp | 8 - Userland/Services/WebContent/PageClient.h | 1 - 17 files changed, 12 insertions(+), 443 deletions(-) delete mode 100644 Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.cpp delete mode 100644 Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.h diff --git a/Ladybird/HelperProcess.cpp b/Ladybird/HelperProcess.cpp index 606def18b07..f67fad14f2b 100644 --- a/Ladybird/HelperProcess.cpp +++ b/Ladybird/HelperProcess.cpp @@ -91,8 +91,6 @@ ErrorOr> launch_web_content_process( arguments.append("--use-gpu-painting"sv); if (web_content_options.enable_skia_painting == Ladybird::EnableSkiaPainting::Yes) arguments.append("--use-skia-painting"sv); - if (web_content_options.enable_experimental_cpu_transforms == Ladybird::EnableExperimentalCPUTransforms::Yes) - arguments.append("--experimental-cpu-transforms"sv); if (web_content_options.wait_for_debugger == Ladybird::WaitForDebugger::Yes) arguments.append("--wait-for-debugger"sv); if (web_content_options.log_all_js_exceptions == Ladybird::LogAllJSExceptions::Yes) diff --git a/Ladybird/Qt/main.cpp b/Ladybird/Qt/main.cpp index 01ba52a14e5..cd22d0ae0bb 100644 --- a/Ladybird/Qt/main.cpp +++ b/Ladybird/Qt/main.cpp @@ -97,7 +97,6 @@ ErrorOr serenity_main(Main::Arguments arguments) bool expose_internals_object = false; bool use_gpu_painting = false; bool use_skia_painting = false; - bool use_experimental_cpu_transform_support = false; bool debug_web_content = false; bool log_all_js_exceptions = false; bool enable_idl_tracing = false; @@ -114,7 +113,6 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(enable_qt_networking, "Enable Qt as the backend networking service", "enable-qt-networking"); args_parser.add_option(use_gpu_painting, "Enable GPU painting", "enable-gpu-painting"); args_parser.add_option(use_skia_painting, "Enable Skia painting", "enable-skia-painting"); - args_parser.add_option(use_experimental_cpu_transform_support, "Enable experimental CPU transform support", "experimental-cpu-transforms"); args_parser.add_option(debug_web_content, "Wait for debugger to attach to WebContent", "debug-web-content"); args_parser.add_option(certificates, "Path to a certificate file", "certificate", 'C', "certificate"); args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions"); @@ -176,7 +174,6 @@ ErrorOr serenity_main(Main::Arguments arguments) .executable_path = MUST(String::from_byte_string(MUST(Core::System::current_executable_path()))), .enable_callgrind_profiling = enable_callgrind_profiling ? Ladybird::EnableCallgrindProfiling::Yes : Ladybird::EnableCallgrindProfiling::No, .enable_gpu_painting = use_gpu_painting ? Ladybird::EnableGPUPainting::Yes : Ladybird::EnableGPUPainting::No, - .enable_experimental_cpu_transforms = use_experimental_cpu_transform_support ? Ladybird::EnableExperimentalCPUTransforms::Yes : Ladybird::EnableExperimentalCPUTransforms::No, .enable_skia_painting = use_skia_painting ? Ladybird::EnableSkiaPainting::Yes : Ladybird::EnableSkiaPainting::No, .use_lagom_networking = enable_qt_networking ? Ladybird::UseLagomNetworking::No : Ladybird::UseLagomNetworking::Yes, .wait_for_debugger = debug_web_content ? Ladybird::WaitForDebugger::Yes : Ladybird::WaitForDebugger::No, diff --git a/Ladybird/Types.h b/Ladybird/Types.h index e9f0e8c7faa..70935131721 100644 --- a/Ladybird/Types.h +++ b/Ladybird/Types.h @@ -20,11 +20,6 @@ enum class EnableGPUPainting { Yes }; -enum class EnableExperimentalCPUTransforms { - No, - Yes -}; - enum class EnableSkiaPainting { No, Yes @@ -65,7 +60,6 @@ struct WebContentOptions { String executable_path; EnableCallgrindProfiling enable_callgrind_profiling { EnableCallgrindProfiling::No }; EnableGPUPainting enable_gpu_painting { EnableGPUPainting::No }; - EnableExperimentalCPUTransforms enable_experimental_cpu_transforms { EnableExperimentalCPUTransforms::No }; EnableSkiaPainting enable_skia_painting { EnableSkiaPainting::No }; IsLayoutTestMode is_layout_test_mode { IsLayoutTestMode::No }; UseLagomNetworking use_lagom_networking { UseLagomNetworking::Yes }; diff --git a/Ladybird/WebContent/main.cpp b/Ladybird/WebContent/main.cpp index 3286606181b..620bd30dbba 100644 --- a/Ladybird/WebContent/main.cpp +++ b/Ladybird/WebContent/main.cpp @@ -97,7 +97,6 @@ ErrorOr serenity_main(Main::Arguments arguments) bool expose_internals_object = false; bool use_lagom_networking = false; bool use_gpu_painting = false; - bool use_experimental_cpu_transform_support = false; bool use_skia_painter = false; bool wait_for_debugger = false; bool log_all_js_exceptions = false; @@ -111,7 +110,6 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(expose_internals_object, "Expose internals object", "expose-internals-object"); args_parser.add_option(use_lagom_networking, "Enable Lagom servers for networking", "use-lagom-networking"); args_parser.add_option(use_gpu_painting, "Enable GPU painting", "use-gpu-painting"); - args_parser.add_option(use_experimental_cpu_transform_support, "Enable experimental CPU transform support", "experimental-cpu-transforms"); args_parser.add_option(use_skia_painter, "Enable Skia painter", "use-skia-painting"); args_parser.add_option(wait_for_debugger, "Wait for debugger", "wait-for-debugger"); args_parser.add_option(mach_server_name, "Mach server name", "mach-server-name", 0, "mach_server_name"); @@ -138,10 +136,6 @@ ErrorOr serenity_main(Main::Arguments arguments) WebContent::PageClient::set_use_skia_painter(); } - if (use_experimental_cpu_transform_support) { - WebContent::PageClient::set_use_experimental_cpu_transform_support(); - } - #if defined(AK_OS_MACOS) if (!mach_server_name.is_empty()) { Core::Platform::register_with_mach_server(mach_server_name); diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn index 16f953bd6cb..2c0d554473e 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn @@ -5,7 +5,6 @@ source_set("Painting") { "//Userland/", # For LibGfx needing LibGUI needing WindowServer types ] sources = [ - "AffineCommandExecutorCPU.cpp", "AudioPaintable.cpp", "BackgroundPainting.cpp", "BorderPainting.cpp", diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index a74e5873940..4ec11ffd603 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -529,7 +529,6 @@ set(SOURCES Page/EventHandler.cpp Page/InputEvent.cpp Page/Page.cpp - Painting/AffineCommandExecutorCPU.cpp Painting/AudioPaintable.cpp Painting/BackgroundPainting.cpp Painting/BorderRadiiData.cpp diff --git a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp index 48f2bc8e15c..703a4fa775a 100644 --- a/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp +++ b/Userland/Libraries/LibWeb/HTML/TraversableNavigable.cpp @@ -1205,7 +1205,7 @@ void TraversableNavigable::paint(Web::DevicePixelRect const& content_rect, Gfx:: Painting::CommandExecutorSkia painting_command_executor(target); painting_commands.execute(painting_command_executor); } else { - Web::Painting::CommandExecutorCPU painting_command_executor(target, painting_command_executor_type == PaintingCommandExecutorType::CPUWithExperimentalTransformSupport); + Web::Painting::CommandExecutorCPU painting_command_executor(target); painting_commands.execute(painting_command_executor); } } diff --git a/Userland/Libraries/LibWeb/Page/Page.h b/Userland/Libraries/LibWeb/Page/Page.h index c358b6f27ef..7cc2f8d97f2 100644 --- a/Userland/Libraries/LibWeb/Page/Page.h +++ b/Userland/Libraries/LibWeb/Page/Page.h @@ -276,7 +276,6 @@ struct PaintOptions { enum class PaintingCommandExecutorType { CPU, - CPUWithExperimentalTransformSupport, GPU, Skia }; diff --git a/Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.cpp b/Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.cpp deleted file mode 100644 index 0adc2979a3b..00000000000 --- a/Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.cpp +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Copyright (c) 2024, MacDue - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -namespace Web::Painting { - -// This executor is hopes to handle (at least) 2D CSS transforms. All commands -// implemented here are required to support affine transformations, if that is -// not possible the implementation should say in CommandExecutorCPU. Note: The -// transform can be assumed to be non-identity or translation, so there's no -// need to add fast paths here (those will be handled in the normal executor). - -static Gfx::Path rect_path(Gfx::FloatRect const& rect) -{ - Gfx::Path path; - path.move_to({ rect.x(), rect.y() }); - path.line_to({ rect.x() + rect.width(), rect.y() }); - path.line_to({ rect.x() + rect.width(), rect.y() + rect.height() }); - path.line_to({ rect.x(), rect.y() + rect.height() }); - path.close(); - return path; -} - -AffineCommandExecutorCPU::AffineCommandExecutorCPU(Gfx::Bitmap& bitmap, Gfx::AffineTransform transform, Gfx::IntRect clip) - : m_painter(bitmap) -{ - auto clip_quad = Gfx::AffineTransform {}.map_to_quad(clip.to_type()); - m_stacking_contexts.append(StackingContext { transform, clip_quad, clip_quad.bounding_rect() }); -} - -CommandResult AffineCommandExecutorCPU::draw_glyph_run(DrawGlyphRun const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::draw_text(DrawText const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::fill_rect(FillRect const& command) -{ - // FIXME: Somehow support clip_paths? - auto path = rect_path(command.rect.to_type()).copy_transformed(stacking_context().transform); - aa_painter().fill_path(path, command.color, Gfx::WindingRule::EvenOdd); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::draw_scaled_bitmap(DrawScaledBitmap const& command) -{ - m_painter.draw_scaled_bitmap_with_transform(command.dst_rect, command.bitmap, command.src_rect.to_type(), stacking_context().transform, 1.0f, command.scaling_mode); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const& command) -{ - m_painter.draw_scaled_bitmap_with_transform(command.dst_rect, command.bitmap->bitmap(), command.src_rect.to_type(), stacking_context().transform, 1.0f, command.scaling_mode); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::save(Save const&) -{ - m_painter.save(); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::restore(Restore const&) -{ - m_painter.restore(); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::add_clip_rect(AddClipRect const&) -{ - // FIXME: Implement. The plan here is to implement https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm - // within the rasterizer (which should work as the clip quadrilateral will always be convex). - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::push_stacking_context(PushStackingContext const& command) -{ - // FIXME: Support opacity. - // FIXME: Support masks. - // Note: Image rendering is not relevant as this does not transform via a bitmap. - // Note: `position: fixed` does not apply when CSS transforms are involved. - - // FIXME: Attempt to support 3D transforms... Somehow? - auto affine_transform = Gfx::extract_2d_affine_transform(command.transform.matrix); - auto new_transform = Gfx::AffineTransform {} - .set_translation(command.post_transform_translation.to_type()) - .translate(command.transform.origin) - .multiply(affine_transform) - .translate(-command.transform.origin); - - auto const& current_stacking_context = stacking_context(); - m_stacking_contexts.append(StackingContext { - .transform = Gfx::AffineTransform(current_stacking_context.transform).multiply(new_transform), - .clip = current_stacking_context.clip, - .clip_bounds = current_stacking_context.clip_bounds }); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::pop_stacking_context(PopStackingContext const&) -{ - m_stacking_contexts.take_last(); - if (m_stacking_contexts.size() == 0) - return CommandResult::ContinueWithParentExecutor; - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::paint_linear_gradient(PaintLinearGradient const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::paint_outer_box_shadow(PaintOuterBoxShadow const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::paint_inner_box_shadow(PaintInnerBoxShadow const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::paint_text_shadow(PaintTextShadow const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::fill_rect_with_rounded_corners(FillRectWithRoundedCorners const& command) -{ - Gfx::Path path; - - auto x = command.rect.x(); - auto y = command.rect.y(); - auto width = command.rect.width(); - auto height = command.rect.height(); - - if (command.top_left_radius) - path.move_to({ x + command.top_left_radius.horizontal_radius, y }); - else - path.move_to({ x, y }); - - if (command.top_right_radius) { - path.horizontal_line_to(x + width - command.top_right_radius.horizontal_radius); - path.elliptical_arc_to({ x + width, y + command.top_right_radius.horizontal_radius }, { command.top_right_radius.horizontal_radius, command.top_right_radius.vertical_radius }, 0, false, true); - } else { - path.horizontal_line_to(x + width); - } - - if (command.bottom_right_radius) { - path.vertical_line_to(y + height - command.bottom_right_radius.vertical_radius); - path.elliptical_arc_to({ x + width - command.bottom_right_radius.horizontal_radius, y + height }, { command.bottom_right_radius.horizontal_radius, command.bottom_right_radius.vertical_radius }, 0, false, true); - } else { - path.vertical_line_to(y + height); - } - - if (command.bottom_left_radius) { - path.horizontal_line_to(x + command.bottom_left_radius.horizontal_radius); - path.elliptical_arc_to({ x, y + height - command.bottom_left_radius.vertical_radius }, { command.bottom_left_radius.horizontal_radius, command.bottom_left_radius.vertical_radius }, 0, false, true); - } else { - path.horizontal_line_to(x); - } - - if (command.top_left_radius) { - path.vertical_line_to(y + command.top_left_radius.vertical_radius); - path.elliptical_arc_to({ x + command.top_left_radius.horizontal_radius, y }, { command.top_left_radius.horizontal_radius, command.top_left_radius.vertical_radius }, 0, false, true); - } else { - path.vertical_line_to(y); - } - - path = path.copy_transformed(stacking_context().transform); - aa_painter().fill_path(path, command.color, Gfx::WindingRule::EvenOdd); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::fill_path_using_color(FillPathUsingColor const& command) -{ - auto path_transform = Gfx::AffineTransform(stacking_context().transform).multiply(Gfx::AffineTransform {}.set_translation(command.aa_translation)); - aa_painter().fill_path(command.path.copy_transformed(path_transform), command.color, command.winding_rule); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::fill_path_using_paint_style(FillPathUsingPaintStyle const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::stroke_path_using_color(StrokePathUsingColor const& command) -{ - auto path_transform = Gfx::AffineTransform(stacking_context().transform).multiply(Gfx::AffineTransform {}.set_translation(command.aa_translation)); - aa_painter().stroke_path(command.path.copy_transformed(path_transform), command.color, command.thickness); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::draw_ellipse(DrawEllipse const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::fill_ellipse(FillEllipse const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::draw_line(DrawLine const& command) -{ - // FIXME: Implement other line styles. - Gfx::Path path; - path.move_to(command.from.to_type()); - path.line_to(command.to.to_type()); - aa_painter().stroke_path(path, command.color, command.thickness); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::apply_backdrop_filter(ApplyBackdropFilter const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::draw_rect(DrawRect const& command) -{ - auto path = rect_path(command.rect.to_type()).copy_transformed(stacking_context().transform); - aa_painter().stroke_path(path, command.color, 1); - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::paint_radial_gradient(PaintRadialGradient const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::paint_conic_gradient(PaintConicGradient const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::draw_triangle_wave(DrawTriangleWave const&) -{ - // FIXME: Implement. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::sample_under_corners(SampleUnderCorners const&) -{ - // FIXME: Implement? -- Likely not a good approach for transforms. - return CommandResult::Continue; -} - -CommandResult AffineCommandExecutorCPU::blit_corner_clipping(BlitCornerClipping const&) -{ - // FIXME: Implement? -- Likely not a good approach for transforms. - return CommandResult::Continue; -} - -bool AffineCommandExecutorCPU::would_be_fully_clipped_by_painter(Gfx::IntRect rect) const -{ - auto const& current_stacking_context = stacking_context(); - auto transformed_rect = current_stacking_context.transform.map(rect.to_type()); - return transformed_rect.intersected(current_stacking_context.clip_bounds).is_empty(); -} - -} diff --git a/Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.h b/Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.h deleted file mode 100644 index 22ce6f1e203..00000000000 --- a/Userland/Libraries/LibWeb/Painting/AffineCommandExecutorCPU.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2024, MacDue - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include -#include -#include - -namespace Web::Painting { - -class AffineCommandExecutorCPU : public CommandExecutor { -public: - CommandResult draw_glyph_run(DrawGlyphRun const&) override; - CommandResult draw_text(DrawText const&) override; - CommandResult fill_rect(FillRect const&) override; - CommandResult draw_scaled_bitmap(DrawScaledBitmap const&) override; - CommandResult draw_scaled_immutable_bitmap(DrawScaledImmutableBitmap const&) override; - CommandResult save(Save const&) override; - CommandResult restore(Restore const&) override; - CommandResult add_clip_rect(AddClipRect const&) override; - CommandResult push_stacking_context(PushStackingContext const&) override; - CommandResult pop_stacking_context(PopStackingContext const&) override; - CommandResult paint_linear_gradient(PaintLinearGradient const&) override; - CommandResult paint_outer_box_shadow(PaintOuterBoxShadow const&) override; - CommandResult paint_inner_box_shadow(PaintInnerBoxShadow const&) override; - CommandResult paint_text_shadow(PaintTextShadow const&) override; - CommandResult fill_rect_with_rounded_corners(FillRectWithRoundedCorners const&) override; - CommandResult fill_path_using_color(FillPathUsingColor const&) override; - CommandResult fill_path_using_paint_style(FillPathUsingPaintStyle const&) override; - CommandResult stroke_path_using_color(StrokePathUsingColor const&) override; - CommandResult stroke_path_using_paint_style(StrokePathUsingPaintStyle const&) override; - CommandResult draw_ellipse(DrawEllipse const&) override; - CommandResult fill_ellipse(FillEllipse const&) override; - CommandResult draw_line(DrawLine const&) override; - CommandResult apply_backdrop_filter(ApplyBackdropFilter const&) override; - CommandResult draw_rect(DrawRect const&) override; - CommandResult paint_radial_gradient(PaintRadialGradient const&) override; - CommandResult paint_conic_gradient(PaintConicGradient const&) override; - CommandResult draw_triangle_wave(DrawTriangleWave const&) override; - CommandResult sample_under_corners(SampleUnderCorners const&) override; - CommandResult blit_corner_clipping(BlitCornerClipping const&) override; - - bool would_be_fully_clipped_by_painter(Gfx::IntRect) const override; - - bool needs_prepare_glyphs_texture() const override { return false; } - void prepare_glyph_texture(HashMap> const&) override {}; - - virtual void prepare_to_execute(size_t) override { } - - bool needs_update_immutable_bitmap_texture_cache() const override { return false; } - void update_immutable_bitmap_texture_cache(HashMap&) override {}; - - AffineCommandExecutorCPU(Gfx::Bitmap& bitmap, Gfx::AffineTransform transform, Gfx::IntRect clip); - - virtual ~AffineCommandExecutorCPU() override = default; - -private: - // FIXME: Support masking. - // FIXME: Support opacity < 1.0f. - struct StackingContext { - Gfx::AffineTransform transform; - Gfx::FloatQuad clip; - Gfx::FloatRect clip_bounds; - }; - - Gfx::AntiAliasingPainter aa_painter() - { - return Gfx::AntiAliasingPainter(m_painter); - } - - StackingContext& stacking_context() - { - return m_stacking_contexts.last(); - } - - StackingContext const& stacking_context() const - { - return m_stacking_contexts.last(); - } - - Gfx::Painter m_painter; - Vector m_stacking_contexts; -}; - -} diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp index f04c191ae61..175a9fcf792 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -14,9 +15,8 @@ namespace Web::Painting { -CommandExecutorCPU::CommandExecutorCPU(Gfx::Bitmap& bitmap, bool enable_affine_command_executor) +CommandExecutorCPU::CommandExecutorCPU(Gfx::Bitmap& bitmap) : m_target_bitmap(bitmap) - , m_enable_affine_command_executor(enable_affine_command_executor) { stacking_contexts.append({ .painter = AK::make(bitmap), .opacity = 1.0f, @@ -24,6 +24,8 @@ CommandExecutorCPU::CommandExecutorCPU(Gfx::Bitmap& bitmap, bool enable_affine_c .scaling_mode = {} }); } +CommandExecutorCPU::~CommandExecutorCPU() = default; + CommandResult CommandExecutorCPU::draw_glyph_run(DrawGlyphRun const& command) { auto& painter = this->painter(); @@ -131,17 +133,6 @@ CommandResult CommandExecutorCPU::push_stacking_context(PushStackingContext cons // Use the whole matrix when we get better transformation support in LibGfx or use LibGL for drawing the bitmap auto affine_transform = Gfx::extract_2d_affine_transform(command.transform.matrix); - if (m_enable_affine_command_executor && command.opacity == 1.0f && !affine_transform.is_identity_or_translation()) { - auto offset = command.is_fixed_position ? Gfx::IntPoint {} : painter().translation(); - auto full_transform = Gfx::AffineTransform {} - .set_translation((command.post_transform_translation + offset).to_type()) - .translate(command.transform.origin) - .multiply(affine_transform) - .translate(-command.transform.origin); - m_affine_command_executor = AffineCommandExecutorCPU(m_target_bitmap, full_transform, painter().clip_rect()); - return CommandResult::ContinueWithNestedExecutor; - } - painter().save(); if (command.is_fixed_position) painter().translate(-painter().translation()); diff --git a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h index 67f2d90c449..2e6313aa3a6 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h +++ b/Userland/Libraries/LibWeb/Painting/CommandExecutorCPU.h @@ -8,7 +8,6 @@ #include #include -#include #include namespace Web::Painting { @@ -55,16 +54,11 @@ public: bool needs_update_immutable_bitmap_texture_cache() const override { return false; } void update_immutable_bitmap_texture_cache(HashMap&) override {}; - CommandExecutorCPU(Gfx::Bitmap& bitmap, bool enable_affine_command_executor = false); - - CommandExecutor& nested_executor() override - { - return *m_affine_command_executor; - } + CommandExecutorCPU(Gfx::Bitmap& bitmap); + ~CommandExecutorCPU(); private: Gfx::Bitmap& m_target_bitmap; - bool m_enable_affine_command_executor { false }; Vector> m_corner_clippers_stack; @@ -80,7 +74,6 @@ private: [[nodiscard]] Gfx::Painter& painter() { return *stacking_contexts.last().painter; } Vector stacking_contexts; - Optional m_affine_command_executor; }; } diff --git a/Userland/Libraries/LibWeb/Painting/CommandList.cpp b/Userland/Libraries/LibWeb/Painting/CommandList.cpp index 66974a373ba..5fe373341c0 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandList.cpp +++ b/Userland/Libraries/LibWeb/Painting/CommandList.cpp @@ -112,8 +112,6 @@ void CommandList::execute(CommandExecutor& executor) HashTable skipped_sample_corner_commands; size_t next_command_index = 0; - Vector executor_stack; - CommandExecutor* current_executor = &executor; while (next_command_index < m_commands.size()) { if (m_commands[next_command_index].skip) { next_command_index++; @@ -122,7 +120,7 @@ void CommandList::execute(CommandExecutor& executor) auto& command = m_commands[next_command_index++].command; auto bounding_rect = command_bounding_rectangle(command); - if (bounding_rect.has_value() && (bounding_rect->is_empty() || current_executor->would_be_fully_clipped_by_painter(*bounding_rect))) { + if (bounding_rect.has_value() && (bounding_rect->is_empty() || executor.would_be_fully_clipped_by_painter(*bounding_rect))) { if (command.has()) { auto const& sample_under_corners = command.get(); skipped_sample_corner_commands.set(sample_under_corners.id); @@ -142,9 +140,9 @@ void CommandList::execute(CommandExecutor& executor) } } -#define HANDLE_COMMAND(command_type, executor_method) \ - if (command.has()) { \ - result = current_executor->executor_method(command.get()); \ +#define HANDLE_COMMAND(command_type, executor_method) \ + if (command.has()) { \ + result = executor.executor_method(command.get()); \ } // clang-format off @@ -181,12 +179,7 @@ void CommandList::execute(CommandExecutor& executor) else VERIFY_NOT_REACHED(); // clang-format on - if (result == CommandResult::ContinueWithNestedExecutor) { - executor_stack.append(*current_executor); - current_executor = ¤t_executor->nested_executor(); - } else if (result == CommandResult::ContinueWithParentExecutor) { - current_executor = &executor_stack.take_last(); - } else if (result == CommandResult::SkipStackingContext) { + if (result == CommandResult::SkipStackingContext) { auto stacking_context_nesting_level = 1; while (next_command_index < m_commands.size()) { if (m_commands[next_command_index].command.has()) { diff --git a/Userland/Libraries/LibWeb/Painting/CommandList.h b/Userland/Libraries/LibWeb/Painting/CommandList.h index 8b642c1d76a..4126a957f55 100644 --- a/Userland/Libraries/LibWeb/Painting/CommandList.h +++ b/Userland/Libraries/LibWeb/Painting/CommandList.h @@ -39,8 +39,6 @@ namespace Web::Painting { enum class CommandResult { Continue, SkipStackingContext, - ContinueWithNestedExecutor, - ContinueWithParentExecutor }; class CommandExecutor { @@ -82,7 +80,6 @@ public: virtual void prepare_to_execute([[maybe_unused]] size_t corner_clip_max_depth) { } virtual bool needs_update_immutable_bitmap_texture_cache() const = 0; virtual void update_immutable_bitmap_texture_cache(HashMap&) = 0; - virtual CommandExecutor& nested_executor() { VERIFY_NOT_REACHED(); } }; class CommandList { diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp index 1cf52888f2d..d2d1259763d 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.cpp @@ -101,7 +101,6 @@ RefPtr SVGDecodedImageData::render(Gfx::IntSize size) const auto painting_command_executor_type = m_page_client->painting_command_executor_type(); switch (painting_command_executor_type) { case PaintingCommandExecutorType::CPU: - case PaintingCommandExecutorType::CPUWithExperimentalTransformSupport: case PaintingCommandExecutorType::GPU: { // GPU painter does not have any path rasterization support so we always fall back to CPU painter Painting::CommandExecutorCPU executor { *bitmap }; painting_commands.execute(executor); diff --git a/Userland/Services/WebContent/PageClient.cpp b/Userland/Services/WebContent/PageClient.cpp index 5c6a44b8089..476d6192d56 100644 --- a/Userland/Services/WebContent/PageClient.cpp +++ b/Userland/Services/WebContent/PageClient.cpp @@ -32,7 +32,6 @@ namespace WebContent { static bool s_use_gpu_painter = false; -static bool s_use_experimental_cpu_transform_support = false; static bool s_use_skia_painter = false; JS_DEFINE_ALLOCATOR(PageClient); @@ -47,11 +46,6 @@ void PageClient::set_use_skia_painter() s_use_skia_painter = true; } -void PageClient::set_use_experimental_cpu_transform_support() -{ - s_use_experimental_cpu_transform_support = true; -} - JS::NonnullGCPtr PageClient::create(JS::VM& vm, PageHost& page_host, u64 id) { return vm.heap().allocate_without_realm(page_host, id); @@ -734,8 +728,6 @@ Web::PaintingCommandExecutorType PageClient::painting_command_executor_type() co return Web::PaintingCommandExecutorType::GPU; if (s_use_skia_painter) return Web::PaintingCommandExecutorType::Skia; - if (s_use_experimental_cpu_transform_support) - return Web::PaintingCommandExecutorType::CPUWithExperimentalTransformSupport; return Web::PaintingCommandExecutorType::CPU; } diff --git a/Userland/Services/WebContent/PageClient.h b/Userland/Services/WebContent/PageClient.h index cb05e40a2cb..1cc06b4236f 100644 --- a/Userland/Services/WebContent/PageClient.h +++ b/Userland/Services/WebContent/PageClient.h @@ -33,7 +33,6 @@ public: static void set_use_gpu_painter(); static void set_use_skia_painter(); - static void set_use_experimental_cpu_transform_support(); virtual void schedule_repaint() override; virtual bool is_ready_to_paint() const override;