From 0bfcf73524d8549eb2abf9b02e536d040370d227 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 29 Jul 2024 16:51:15 +0300 Subject: [PATCH] LibWeb: Inline apply_backdrop_filter function into paint_backdrop_filter No need to have a separate file for this small function. --- .../Libraries/LibWeb/Painting/BUILD.gn | 1 - Userland/Libraries/LibWeb/CMakeLists.txt | 1 - .../LibWeb/Painting/FilterPainting.cpp | 21 ------------------- .../LibWeb/Painting/FilterPainting.h | 17 --------------- .../LibWeb/Painting/PaintableBox.cpp | 13 ++++++++---- 5 files changed, 9 insertions(+), 44 deletions(-) delete mode 100644 Userland/Libraries/LibWeb/Painting/FilterPainting.cpp delete mode 100644 Userland/Libraries/LibWeb/Painting/FilterPainting.h diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn index 00bb2dcb8ff..4c23751433e 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/Painting/BUILD.gn @@ -17,7 +17,6 @@ source_set("Painting") { "Command.cpp", "DisplayList.cpp", "DisplayListRecorder.cpp", - "FilterPainting.cpp", "GradientPainting.cpp", "ImagePaintable.cpp", "InlinePaintable.cpp", diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 9dc0d3fa22a..ed8b49992a9 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -558,7 +558,6 @@ set(SOURCES Painting/DisplayListPlayerSkia.cpp Painting/DisplayListRecorder.cpp Painting/GradientPainting.cpp - Painting/FilterPainting.cpp Painting/ImagePaintable.cpp Painting/InlinePaintable.cpp Painting/LabelablePaintable.cpp diff --git a/Userland/Libraries/LibWeb/Painting/FilterPainting.cpp b/Userland/Libraries/LibWeb/Painting/FilterPainting.cpp deleted file mode 100644 index 6c6561b4917..00000000000 --- a/Userland/Libraries/LibWeb/Painting/FilterPainting.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022, MacDue - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include -#include -#include - -namespace Web::Painting { - -void apply_backdrop_filter(PaintContext& context, CSSPixelRect const& backdrop_rect, BorderRadiiData const& border_radii_data, CSS::ResolvedBackdropFilter const& backdrop_filter) -{ - auto backdrop_region = context.rounded_device_rect(backdrop_rect); - - ScopedCornerRadiusClip corner_clipper { context, backdrop_region, border_radii_data }; - context.display_list_recorder().apply_backdrop_filter(backdrop_region.to_type(), border_radii_data, backdrop_filter); -} - -} diff --git a/Userland/Libraries/LibWeb/Painting/FilterPainting.h b/Userland/Libraries/LibWeb/Painting/FilterPainting.h deleted file mode 100644 index ea49606e80a..00000000000 --- a/Userland/Libraries/LibWeb/Painting/FilterPainting.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2022, MacDue - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include -#include -#include - -namespace Web::Painting { - -void apply_backdrop_filter(PaintContext&, CSSPixelRect const&, BorderRadiiData const&, CSS::ResolvedBackdropFilter const&); - -} diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 1b547dc10d7..a237e454331 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -438,9 +437,15 @@ void PaintableBox::paint_border(PaintContext& context) const void PaintableBox::paint_backdrop_filter(PaintContext& context) const { - auto& backdrop_filter = computed_values().backdrop_filter(); - if (!backdrop_filter.is_none()) - apply_backdrop_filter(context, absolute_border_box_rect(), normalized_border_radii_data(), backdrop_filter); + auto const& backdrop_filter = computed_values().backdrop_filter(); + if (backdrop_filter.is_none()) { + return; + } + + auto backdrop_region = context.rounded_device_rect(absolute_border_box_rect()); + auto border_radii_data = normalized_border_radii_data(); + ScopedCornerRadiusClip corner_clipper { context, backdrop_region, border_radii_data }; + context.display_list_recorder().apply_backdrop_filter(backdrop_region.to_type(), border_radii_data, backdrop_filter); } void PaintableBox::paint_background(PaintContext& context) const