2024-06-17 18:50:57 +03:00
|
|
|
/*
|
2025-06-27 04:39:16 +02:00
|
|
|
* Copyright (c) 2024-2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
2024-06-17 18:50:57 +03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2024-06-17 18:50:57 +03:00
|
|
|
|
2025-06-26 22:33:58 +02:00
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
class WEB_API BackingStoreManager : public JS::Cell {
|
2025-06-26 22:33:58 +02:00
|
|
|
GC_CELL(BackingStoreManager, JS::Cell);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(BackingStoreManager);
|
2024-06-17 18:50:57 +03:00
|
|
|
|
|
|
|
|
public:
|
2024-06-20 21:34:51 +03:00
|
|
|
#ifdef AK_OS_MACOS
|
|
|
|
|
static void set_browser_mach_port(Core::MachPort&&);
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-06-17 18:50:57 +03:00
|
|
|
enum class WindowResizingInProgress {
|
|
|
|
|
No,
|
|
|
|
|
Yes
|
|
|
|
|
};
|
|
|
|
|
void resize_backing_stores_if_needed(WindowResizingInProgress window_resize_in_progress);
|
2024-06-20 21:34:51 +03:00
|
|
|
void reallocate_backing_stores(Gfx::IntSize);
|
2024-06-17 18:50:57 +03:00
|
|
|
void restart_resize_timer();
|
|
|
|
|
|
2025-04-01 00:06:01 +02:00
|
|
|
struct BackingStore {
|
|
|
|
|
i32 bitmap_id { -1 };
|
2025-06-27 04:39:16 +02:00
|
|
|
RefPtr<Gfx::PaintingSurface> store;
|
2025-04-01 00:06:01 +02:00
|
|
|
};
|
2024-06-17 18:50:57 +03:00
|
|
|
|
2025-07-10 19:24:30 +02:00
|
|
|
BackingStore acquire_store_for_next_frame();
|
2024-06-17 18:50:57 +03:00
|
|
|
|
2025-06-26 22:33:58 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor& visitor) override;
|
|
|
|
|
|
|
|
|
|
BackingStoreManager(HTML::Navigable&);
|
2024-06-17 18:50:57 +03:00
|
|
|
|
|
|
|
|
private:
|
2025-04-01 00:06:01 +02:00
|
|
|
void swap_back_and_front();
|
|
|
|
|
|
2025-06-26 22:33:58 +02:00
|
|
|
GC::Ref<HTML::Navigable> m_navigable;
|
2024-06-17 18:50:57 +03:00
|
|
|
|
|
|
|
|
i32 m_front_bitmap_id { -1 };
|
|
|
|
|
i32 m_back_bitmap_id { -1 };
|
2025-06-27 04:39:16 +02:00
|
|
|
RefPtr<Gfx::PaintingSurface> m_front_store;
|
|
|
|
|
RefPtr<Gfx::PaintingSurface> m_back_store;
|
2024-06-17 18:50:57 +03:00
|
|
|
int m_next_bitmap_id { 0 };
|
|
|
|
|
|
|
|
|
|
RefPtr<Core::Timer> m_backing_store_shrink_timer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|