Skip to content

Truly independent web browser

LibCompositing+Tests: Remove VisualContextTreeTestBuilder

Aliaksandr Kalenike2d376554df0
diff --git a/Libraries/LibCompositing/CMakeLists.txt b/Libraries/LibCompositing/CMakeLists.txt
index 0370d7da39c..bccd8aaa8b9 100644
--- a/Libraries/LibCompositing/CMakeLists.txt
+++ b/Libraries/LibCompositing/CMakeLists.txt
@@ -6,7 +6,6 @@ set(SOURCES
DisplayList/DisplayListResourceStorage.cpp
DisplayList/DisplayListResourceTransaction.cpp
DisplayList/RustFFIAssertions.cpp
- DisplayList/VisualContextTreeTestBuilder.cpp
FontServiceClient.cpp
Scrolling/SmoothScrollAnimation.cpp
UIOverlays.cpp
@@ -50,7 +49,6 @@ import_rust_crate(
CRATE_NAME libcompositing_rust
FEATURES allocator
FFI_HEADERS
- TestBuilderRustFFI.h
RustFFI.h
TypesRustFFI.h
DisplayList/DisplayListCommandsGenerated.h
@@ -100,7 +98,7 @@ if(NOT BUILD_SHARED_LIBS)
# POST_BUILD steps don't track inputs, so the bridge files depend on the Rust archive: when it
# changes, LibCompositing re-archives and the merge picks up the fresh objects.
- foreach(bridge IN ITEMS DisplayList/DisplayListResourceStorage.cpp DisplayList/VisualContextTreeTestBuilder.cpp Scrolling/SmoothScrollAnimation.cpp)
+ foreach(bridge IN ITEMS DisplayList/DisplayListResourceStorage.cpp Scrolling/SmoothScrollAnimation.cpp)
set_property(SOURCE ${bridge} APPEND PROPERTY OBJECT_DEPENDS ${_libcompositing_rust_lib})
endforeach()
endif()
diff --git a/Libraries/LibCompositing/DisplayList/VisualContextTreeTestBuilder.cpp b/Libraries/LibCompositing/DisplayList/VisualContextTreeTestBuilder.cpp
deleted file mode 100644
index 533ffc8a6dd..00000000000
--- a/Libraries/LibCompositing/DisplayList/VisualContextTreeTestBuilder.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <LibCompositing/DisplayList/VisualContextTreeTestBuilder.h>
-#include <LibCompositing/RustFFI.h>
-#include <LibCompositing/TestBuilderRustFFI.h>
-
-namespace Compositing {
-
-VisualContextTreeTestBuilder::VisualContextTreeTestBuilder()
- : m_builder(Compositing::RustFFI::visual_context_tree_test_builder_create())
-{
-}
-
-VisualContextTreeTestBuilder::~VisualContextTreeTestBuilder()
-{
- Compositing::RustFFI::visual_context_tree_test_builder_destroy(m_builder);
-}
-
-EffectNodeIndex VisualContextTreeTestBuilder::append_image_filter(u64 image_id, Gfx::IntRect rect)
-{
- return EffectNodeIndex { RustFFI::visual_context_tree_test_builder_append_image_filter(m_builder, image_id, rect) };
-}
-
-void VisualContextTreeTestBuilder::finish()
-{
- RustFFI::visual_context_tree_test_builder_finish(m_builder);
-}
-
-void VisualContextTreeTestBuilder::record_filled_rect(ContextRef context, Gfx::IntRect rect, Gfx::Color color)
-{
- RustFFI::visual_context_tree_test_builder_filled_rect(m_builder, rect, color, context);
-}
-
-void VisualContextTreeTestBuilder::record_rounded_rect_ring(ContextRef context, FillRoundedRectRing const& ring)
-{
- RustFFI::visual_context_tree_test_builder_rounded_rect_ring(m_builder, ring, context);
-}
-
-void VisualContextTreeTestBuilder::replay(RustFFI::FfiRasterPainter const& painter, i64 time_nanoseconds) const
-{
- RustFFI::visual_context_tree_test_builder_replay(m_builder, time_nanoseconds, &painter);
-}
-
-}
diff --git a/Libraries/LibCompositing/DisplayList/VisualContextTreeTestBuilder.h b/Libraries/LibCompositing/DisplayList/VisualContextTreeTestBuilder.h
deleted file mode 100644
index 4aa9f5e0dec..00000000000
--- a/Libraries/LibCompositing/DisplayList/VisualContextTreeTestBuilder.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#pragma once
-
-#include <AK/Optional.h>
-#include <LibCompositing/DisplayList/ContextRef.h>
-#include <LibCompositing/DisplayList/DisplayListCommand.h>
-#include <LibCompositing/Export.h>
-#include <LibCompositing/Forward.h>
-#include <LibGfx/Color.h>
-#include <LibGfx/CornerRadii.h>
-#include <LibGfx/Forward.h>
-#include <LibGfx/Matrix4x4.h>
-#include <LibGfx/Point.h>
-#include <LibGfx/Rect.h>
-#include <LibGfx/Size.h>
-
-namespace Compositing {
-
-namespace RustFFI {
-
-struct FfiRasterPainter;
-
-}
-
-// Builds a visual context tree node by node in Rust for unit tests, which otherwise only ever
-// receive trees the layout arena built.
-class COMPOSITING_API VisualContextTreeTestBuilder {
- AK_MAKE_NONCOPYABLE(VisualContextTreeTestBuilder);
- AK_MAKE_NONMOVABLE(VisualContextTreeTestBuilder);
-
-public:
- VisualContextTreeTestBuilder();
- ~VisualContextTreeTestBuilder();
-
- EffectNodeIndex append_image_filter(u64 image_id, Gfx::IntRect);
- // Ends adding nodes. The lists below are recorded against the tree as it is then.
- void finish();
-
- // Records a list against the tree, which the builder replays from then on.
- void record_filled_rect(ContextRef, Gfx::IntRect, Gfx::Color);
- void record_rounded_rect_ring(ContextRef, FillRoundedRectRing const&);
-
- // Replays the list recorded last, with nothing scrolled, as it shows at `time_nanoseconds`.
- void replay(RustFFI::FfiRasterPainter const&, i64 time_nanoseconds) const;
-
-private:
- void* m_builder { nullptr };
-};
-
-}
diff --git a/Libraries/LibCompositing/Rust/build.rs b/Libraries/LibCompositing/Rust/build.rs
index 1d5bc076a09..8124c2df0e7 100644
--- a/Libraries/LibCompositing/Rust/build.rs
+++ b/Libraries/LibCompositing/Rust/build.rs
@@ -416,14 +416,6 @@ fn main() -> Result<(), Box<dyn Error>> {
]
.map(String::from)
.to_vec();
- let mut test_builder_config = ffi_config.clone();
- test_builder_config.export.include.clear();
- generate_ffi_header(
- test_builder_config,
- &[manifest_dir.join("src/test_builder.rs")],
- &out_dir,
- Path::new("TestBuilderRustFFI.h"),
- );
generate_ffi_header(
ffi_config,
&[
diff --git a/Libraries/LibCompositing/Rust/src/ffi.rs b/Libraries/LibCompositing/Rust/src/ffi.rs
index 47fb04ccdf8..7d19d595eed 100644
--- a/Libraries/LibCompositing/Rust/src/ffi.rs
+++ b/Libraries/LibCompositing/Rust/src/ffi.rs
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-//! The entry points the compositor process shares with WebContent: replaying display lists, computing
-//! their damage, the scroll queries of recorded display lists, and the tree builder tests use.
+//! What the compositor process shares with WebContent: the force-dark classification of images, smooth scroll
+//! animations, and the scroll queries of recorded display lists.
use crate::scrolling::smooth_scroll_animation::SmoothScrollAnimation;
use crate::scrolling::{
@@ -13,7 +13,6 @@ use crate::scrolling::{
};
use crate::time::Duration;
use libgfx_rust::FloatPoint;
-use std::ffi::c_void;
use std::sync::Arc;
/// Decide if force-dark should invert an image: the caller owns the sampling, this owns the policy. Returns false
@@ -36,108 +35,6 @@ pub unsafe extern "C" fn ladybird_web_force_dark_should_filter_image(
crate::force_dark::should_filter(&features)
}
-/// A hand-built test tree: nodes are added until it is finished, and lists are recorded against it after.
-pub(super) enum TestBuilderTree {
- Building(Box<crate::visual_context::VisualContextTree>),
- Finished(Arc<crate::visual_context::VisualContextTree>),
-}
-
-/// A hand-built test tree, and the list recorded against it last, which a test replays.
-pub(super) struct TestBuilder {
- pub(super) tree: TestBuilderTree,
- pub(super) recorded: Option<Arc<crate::display_list::storage::DisplayListStorage>>,
-}
-
-/// # Safety
-///
-/// Returns a builder handle for hand-built test trees rooted at an identity visual viewport
-/// transform; every builder call must receive it until `visual_context_tree_test_builder_destroy`
-/// consumes it.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_test_builder_create() -> *mut c_void {
- let builder = TestBuilder {
- tree: TestBuilderTree::Building(Box::new(crate::visual_context::VisualContextTree::create_identity())),
- recorded: None,
- };
- Box::into_raw(Box::new(builder)).cast()
-}
-
-/// # Safety
-///
-/// `builder` must be a live handle from `visual_context_tree_test_builder_create`.
-pub(super) unsafe fn test_builder<'a>(builder: *mut c_void) -> &'a mut TestBuilder {
- // SAFETY: The caller guarantees `builder` is the live boxed builder the create call returned.
- unsafe { &mut *builder.cast::<TestBuilder>() }
-}
-
-/// Ends adding nodes: the lists recorded from here on are recorded against the tree as it is.
-///
-/// # Safety
-///
-/// `builder` must be a live handle from `visual_context_tree_test_builder_create` that was not finished yet.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_test_builder_finish(builder: *mut c_void) {
- // SAFETY: Guaranteed by the caller.
- let tree = &mut unsafe { test_builder(builder) }.tree;
- let TestBuilderTree::Building(building) = std::mem::replace(
- tree,
- TestBuilderTree::Finished(Arc::new(crate::visual_context::VisualContextTree::create_identity())),
- ) else {
- panic!("a test tree is finished once");
- };
- *tree = TestBuilderTree::Finished(Arc::new(*building));
-}
-
-/// # Safety
-///
-/// `builder` must be null or a live handle from `visual_context_tree_test_builder_create`, consumed
-/// by this call.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_test_builder_destroy(builder: *mut c_void) {
- if builder.is_null() {
- return;
- }
- // SAFETY: The caller hands over the boxed builder the create call returned.
- drop(unsafe { Box::from_raw(builder.cast::<TestBuilder>()) });
-}
-
-/// Replays the list recorded last against the finished tree of `builder`, with nothing scrolled, showing a blinking caret
-/// as it is at `time_nanoseconds`.
-///
-/// # Safety
-///
-/// `builder` must be a live handle from `visual_context_tree_test_builder_create` that recorded a list, and `painter`
-/// must be live. The painter callbacks run synchronously.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_test_builder_replay(
- builder: *mut c_void,
- time_nanoseconds: i64,
- painter: *const crate::host::FfiRasterPainter,
-) {
- // SAFETY: Guaranteed by the caller.
- let builder = unsafe { test_builder(builder) };
- let storage = builder.recorded.as_ref().expect("a test replays a list it recorded");
- let tree = storage
- .visual_context_tree()
- .expect("a test list holds the tree it was recorded against");
- let frame = crate::display_list::replay::ReplayFrame::unscrolled(
- time_nanoseconds,
- &crate::display_list::replay::NoNestedDisplayLists,
- );
- // SAFETY: The caller guarantees `painter` is live for the call.
- let mut painter = unsafe { *painter };
- crate::display_list::replay::replay_display_list(
- tree,
- storage.bytes(),
- storage.command_runs(),
- storage.effect_clip_plan(tree),
- libgfx_rust::Color::TRANSPARENT,
- &frame,
- Default::default(),
- &mut painter,
- );
-}
-
#[unsafe(no_mangle)]
pub extern "C" fn smooth_scroll_animation_create(
start_offset: FloatPoint,
diff --git a/Libraries/LibCompositing/Rust/src/lib.rs b/Libraries/LibCompositing/Rust/src/lib.rs
index fb2d613acf0..d0f4d6aa8ac 100644
--- a/Libraries/LibCompositing/Rust/src/lib.rs
+++ b/Libraries/LibCompositing/Rust/src/lib.rs
@@ -30,5 +30,3 @@ mod test_stubs;
pub mod time;
pub mod visual_animation;
pub mod visual_context;
-
-mod test_builder;
diff --git a/Libraries/LibCompositing/Rust/src/test_builder.rs b/Libraries/LibCompositing/Rust/src/test_builder.rs
deleted file mode 100644
index e4796f73262..00000000000
--- a/Libraries/LibCompositing/Rust/src/test_builder.rs
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-use crate::display_list::builder::DisplayListBuilder;
-use crate::display_list::commands::{ClipNodeIndex, ContextRef, EffectNodeIndex, FillRoundedRectRing};
-use crate::display_list::storage::DisplayListStorage;
-use crate::ffi::{TestBuilderTree, test_builder};
-use std::ffi::c_void;
-use std::sync::Arc;
-
-/// Has `test_builder` keep what `builder` recorded, against its finished tree, as the list it replays.
-///
-/// # Safety
-///
-/// `test_builder` must be a live, finished handle from `visual_context_tree_test_builder_create`.
-unsafe fn record_against_finished_tree(test_builder: *mut c_void, builder: DisplayListBuilder) {
- // SAFETY: Guaranteed by the caller.
- let test_builder = unsafe { self::test_builder(test_builder) };
- let TestBuilderTree::Finished(tree) = &test_builder.tree else {
- panic!("lists are recorded against a finished test tree");
- };
- test_builder.recorded = Some(DisplayListStorage::recorded(Arc::new(builder.finish()), tree.clone()));
-}
-
-/// # Safety
-///
-/// `builder` must be a live handle from `visual_context_tree_test_builder_create` that was not finished yet.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_test_builder_append_image_filter(
- builder: *mut c_void,
- image_id: u64,
- rect: libgfx_rust::IntRect,
-) -> u32 {
- let TestBuilderTree::Building(tree) = &mut (unsafe { test_builder(builder) }).tree else {
- panic!("nodes are added to a test tree before it is finished");
- };
- let filter = libgfx_rust::filter::Filter::Image {
- frame_id: image_id,
- src_rect: rect,
- dest_rect: rect,
- scaling_mode: libgfx_rust::ScalingMode::NearestNeighbor,
- };
- tree.append_effect(
- crate::visual_context::EffectNodeData::Effects(crate::visual_context::EffectsData {
- isolation: false,
- opacity: 1.0,
- blend_mode: libgfx_rust::CompositingAndBlendingOperator::Normal,
- filter: Some(std::sync::Arc::new(filter.serialize())),
- backdrop_filter: None,
- }),
- EffectNodeIndex::NONE,
- crate::display_list::commands::VISUAL_VIEWPORT_NODE_INDEX,
- ClipNodeIndex::NONE,
- )
- .0
-}
-
-/// Records a rectangle with the same canonical builder as production recordings, against the finished tree of
-/// `test_builder`, which keeps it as the list it replays.
-///
-/// # Safety
-///
-/// `test_builder` must be a live, finished handle from `visual_context_tree_test_builder_create`.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_test_builder_filled_rect(
- test_builder: *mut c_void,
- rect: libgfx_rust::IntRect,
- color: libgfx_rust::Color,
- context: ContextRef,
-) {
- let mut builder = DisplayListBuilder::new();
- builder.append(
- &crate::display_list::commands::FillRect {
- rect,
- color,
- compositing_and_blending_operator: libgfx_rust::CompositingAndBlendingOperator::Normal,
- background_color_animation_effect: EffectNodeIndex::NONE,
- },
- &[],
- context,
- );
- // SAFETY: Guaranteed by the caller.
- unsafe { record_against_finished_tree(test_builder, builder) };
-}
-
-/// Records a rounded rectangle ring against the finished tree of `test_builder`, which keeps it as the list it replays.
-///
-/// # Safety
-///
-/// `test_builder` must be a live, finished handle from `visual_context_tree_test_builder_create`.
-#[unsafe(no_mangle)]
-pub unsafe extern "C" fn visual_context_tree_test_builder_rounded_rect_ring(
- test_builder: *mut c_void,
- ring: FillRoundedRectRing,
- context: ContextRef,
-) {
- let mut builder = DisplayListBuilder::new();
- builder.append(&ring, &[], context);
- // SAFETY: Guaranteed by the caller.
- unsafe { record_against_finished_tree(test_builder, builder) };
-}
diff --git a/Tests/Compositor/CMakeLists.txt b/Tests/Compositor/CMakeLists.txt
index c102efd188b..3e611e13388 100644
--- a/Tests/Compositor/CMakeLists.txt
+++ b/Tests/Compositor/CMakeLists.txt
@@ -9,7 +9,6 @@ set(TEST_SOURCES
# These drive Skia directly, and the compositor keeps its Skia dependency private.
list(APPEND TEST_SOURCES
- TestDisplayListImageFilters.cpp
TestForceDarkImageFilter.cpp
TestPaintingSurface.cpp
TestYUVData.cpp
diff --git a/Tests/Compositor/TestDisplayListImageFilters.cpp b/Tests/Compositor/TestDisplayListImageFilters.cpp
deleted file mode 100644
index 8cfe3992b82..00000000000
--- a/Tests/Compositor/TestDisplayListImageFilters.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2026-present, the Ladybird developers.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <Compositor/DisplayListPlayerSkia.h>
-#include <Compositor/DisplayListRasterCache.h>
-#include <Compositor/PaintingSurface.h>
-#include <LibCompositing/DisplayList/DisplayListResourceStorage.h>
-#include <LibCompositing/DisplayList/VisualContextTreeTestBuilder.h>
-#include <LibGfx/Bitmap.h>
-#include <LibTest/TestCase.h>
-#include <new>
-
-static Compositing::ImageFrameResourceId const image_id { 1 };
-static Gfx::IntRect const rect { 0, 0, 1, 1 };
-
-static NonnullRefPtr<Gfx::Bitmap> replace_image(Compositing::DisplayListResourceStorage& storage, Compositor::DisplayListRasterCache& cache, Gfx::Color color)
-{
- auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied, rect.size()));
- bitmap->set_pixel(0, 0, color);
- Compositing::DisplayListResourceTransaction transaction;
- transaction.image_frames.append({ image_id, MUST(Gfx::DecodedImageFrame::create(*bitmap)) });
- cache.evict(storage.apply_transaction(move(transaction)));
- return bitmap;
-}
-
-static Gfx::Color render(Compositor::DisplayListPlayerSkia& player, Compositing::VisualContextTreeTestBuilder const& builder, Compositing::DisplayListResourceStorage const& storage, Compositor::DisplayListRasterCache& cache)
-{
- auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied, rect.size()));
- auto surface = Gfx::PaintingSurface::wrap_bitmap(*bitmap);
- auto painter = player.begin_painting(*surface, storage, cache, nullptr);
- builder.replay(painter, 0);
- player.end_painting();
- player.flush(*surface);
- return bitmap->get_pixel(0, 0);
-}
-
-TEST_CASE(image_filters_use_the_current_resource_storage)
-{
- Compositing::VisualContextTreeTestBuilder builder;
- auto effect = builder.append_image_filter(image_id.value(), rect);
- builder.finish();
- builder.record_filled_rect({ .effect = effect }, rect, Gfx::Color::White);
- Compositor::DisplayListPlayerSkia player { nullptr };
- Compositing::DisplayListResourceStorage blue_storage;
- Compositing::DisplayListResourceStorage green_storage;
- Compositor::DisplayListRasterCache blue_cache;
- Compositor::DisplayListRasterCache green_cache;
- (void)replace_image(blue_storage, blue_cache, Gfx::Color::Blue);
- (void)replace_image(green_storage, green_cache, Gfx::Color::Green);
-
- EXPECT_EQ(render(player, builder, blue_storage, blue_cache), Gfx::Color::Blue);
- EXPECT_EQ(render(player, builder, green_storage, green_cache), Gfx::Color::Green);
- EXPECT_EQ(render(player, builder, blue_storage, blue_cache), Gfx::Color::Blue);
-}
-
-TEST_CASE(image_filters_drop_replaced_image_resources)
-{
- Compositing::VisualContextTreeTestBuilder builder;
- auto effect = builder.append_image_filter(image_id.value(), rect);
- builder.finish();
- builder.record_filled_rect({ .effect = effect }, rect, Gfx::Color::White);
- Compositor::DisplayListPlayerSkia player { nullptr };
- Compositing::DisplayListResourceStorage storage;
- Compositor::DisplayListRasterCache cache;
- auto original_bitmap = replace_image(storage, cache, Gfx::Color::Blue);
- EXPECT_EQ(render(player, builder, storage, cache), Gfx::Color::Blue);
- (void)replace_image(storage, cache, Gfx::Color::Green);
- EXPECT_EQ(render(player, builder, storage, cache), Gfx::Color::Green);
- EXPECT_EQ(original_bitmap->get_pixel(0, 0), Gfx::Color::Blue);
-}
-
-TEST_CASE(image_filters_do_not_keep_destroyed_resource_namespaces)
-{
- Compositing::VisualContextTreeTestBuilder builder;
- auto effect = builder.append_image_filter(image_id.value(), rect);
- builder.finish();
- builder.record_filled_rect({ .effect = effect }, rect, Gfx::Color::White);
- Compositor::DisplayListPlayerSkia player { nullptr };
- struct ResourceNamespace {
- Compositing::DisplayListResourceStorage storage;
- Compositor::DisplayListRasterCache cache;
- };
- alignas(ResourceNamespace) u8 memory[sizeof(ResourceNamespace)];
- Vector<NonnullRefPtr<Gfx::Bitmap>> kept_images;
- for (auto color : { Gfx::Color::Blue, Gfx::Color::Green }) {
- auto* resources = new (memory) ResourceNamespace;
- kept_images.append(replace_image(resources->storage, resources->cache, color));
- EXPECT_EQ(render(player, builder, resources->storage, resources->cache), color);
- resources->~ResourceNamespace();
- }
-}
diff --git a/Tests/Compositor/TestPaintingSurface.cpp b/Tests/Compositor/TestPaintingSurface.cpp
index c1f332dcd9c..1d9dbe17dd1 100644
--- a/Tests/Compositor/TestPaintingSurface.cpp
+++ b/Tests/Compositor/TestPaintingSurface.cpp
@@ -4,12 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <Compositor/DisplayListPlayerSkia.h>
-#include <Compositor/DisplayListRasterCache.h>
#include <Compositor/PaintingSurface.h>
#include <Compositor/SkiaBackendContext.h>
#include <Compositor/SkiaUtils.h>
-#include <LibCompositing/DisplayList/VisualContextTreeTestBuilder.h>
#include <LibGfx/Bitmap.h>
#include <LibTest/TestCase.h>
@@ -18,49 +15,6 @@
#include <core/SkPaint.h>
#include <core/SkPath.h>
-TEST_CASE(zero_width_border_sides_do_not_paint_on_gpu_surface)
-{
- // Set up the GPU renderer and pixel readback.
- auto context = Gfx::SkiaBackendContext::create_independent_gpu_backend();
- if (!context) {
- warnln("No GPU backend available, skipping");
- return;
- }
-
- Gfx::IntSize size { 10, 10 };
- auto surface = Gfx::PaintingSurface::create_with_size(size, Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied, context);
- Compositing::VisualContextTreeTestBuilder builder;
- builder.finish();
- Compositor::DisplayListPlayerSkia player { context };
- Compositing::DisplayListResourceStorage storage;
- Compositor::DisplayListRasterCache cache;
- auto bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied, size));
-
- // A half-pixel offset must not make the zero-width top and left borders visible.
- auto& canvas = surface->canvas();
- canvas.clear(SK_ColorWHITE);
- canvas.translate(0.5f, 0.5f);
-
- Compositing::FillRoundedRectRing ring {
- .rect = { 0, 0, 8, 8 },
- .corner_radii = {},
- .top_width = 0,
- .right_width = 1,
- .bottom_width = 1,
- .left_width = 0,
- .color = Gfx::Color::Black,
- };
- builder.record_rounded_rect_ring({}, ring);
- auto painter = player.begin_painting(*surface, storage, cache, nullptr);
- builder.replay(painter, 0);
- player.end_painting();
- surface->read_into_bitmap(*bitmap);
-
- EXPECT_EQ(bitmap->get_pixel(0, 4), Gfx::Color::White); // Left border.
- EXPECT_EQ(bitmap->get_pixel(4, 0), Gfx::Color::White); // Top border.
- EXPECT_NE(bitmap->get_pixel(8, 4), Gfx::Color::White); // Right border.
-}
-
static int count_red_pixels(Gfx::Bitmap const& bitmap, Gfx::IntRect const& rect)
{
int count = 0;