BackingStoreManager was owned by Navigable and allocated on the GC heap, which left backing-store sizing decisions on the main thread even though the compositor thread was already responsible for allocating the actual surfaces. That split ownership makes it harder to isolate the compositor behind a process boundary. Move the manager into LibWeb's compositor code and let CompositorThread thread data own it. The main thread now reports viewport size changes through a compositor command, and the compositor uses that message to decide when to resize and publish backing stores. The delayed shrink timer remains with the main-thread CompositorThread facade so it can use the Core event loop, but it now only sends another viewport-size update. This removes the GC edge from Navigable, drops stale WebContent includes and keeps the existing resize padding and delayed shrink behavior.
41 lines
1.5 KiB
C++
41 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2024-2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Compositor/BackingStoreManager.h>
|
|
#include <LibWeb/Compositor/CompositorThread.h>
|
|
|
|
namespace Web::Compositor {
|
|
|
|
Optional<BackingStoreManager::Allocation> BackingStoreManager::resize_backing_stores_if_needed(
|
|
Gfx::IntSize viewport_size, bool is_top_level_traversable, WindowResizingInProgress window_resize_in_progress)
|
|
{
|
|
if (viewport_size.is_empty())
|
|
return {};
|
|
|
|
auto minimum_needed_size = viewport_size;
|
|
bool force_reallocate = false;
|
|
if (window_resize_in_progress == WindowResizingInProgress::Yes && is_top_level_traversable) {
|
|
// Pad the minimum needed size so that we don't have to keep reallocating backing stores while the window is being resized.
|
|
minimum_needed_size = { viewport_size.width() + 256, viewport_size.height() + 256 };
|
|
} else {
|
|
// If we're not in the middle of a resize, we can shrink the backing store size to match the viewport size.
|
|
minimum_needed_size = viewport_size;
|
|
force_reallocate = m_allocated_size != minimum_needed_size;
|
|
}
|
|
|
|
if (force_reallocate || m_allocated_size.is_empty() || !m_allocated_size.contains(minimum_needed_size)) {
|
|
m_allocated_size = minimum_needed_size;
|
|
return Allocation {
|
|
.size = minimum_needed_size,
|
|
.front_bitmap_id = m_next_bitmap_id++,
|
|
.back_bitmap_id = m_next_bitmap_id++,
|
|
};
|
|
}
|
|
|
|
return {};
|
|
}
|
|
|
|
}
|