1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

Ladybird: Make resizing the window a lot less laggy

While resizing, we now pad the shared bitmap allocations with 256 pixels
extra in both axes. This avoids churning through huge allocations for
every single resize step.

We also don't reallocate at all when making the window smaller.

3 seconds after the user stops resizing, we resize the backing stores
again so they fit the window perfectly.
This commit is contained in:
Andreas Kling 2023-05-14 18:57:14 +02:00
parent 984630845d
commit ec2600f246
2 changed files with 71 additions and 24 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022-2023, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@ -203,6 +203,12 @@ private:
void update_viewport_rect();
void handle_resize();
enum class WindowResizeInProgress {
No,
Yes,
};
void resize_backing_stores_if_needed(WindowResizeInProgress);
void ensure_js_console_widget();
void ensure_inspector_widget();
@ -222,6 +228,9 @@ private:
void handle_web_content_process_crash();
RefPtr<Gfx::Bitmap> m_backup_bitmap;
Gfx::IntSize m_backup_bitmap_size;
StringView m_webdriver_content_ipc_path;
RefPtr<Core::Timer> m_backing_store_shrink_timer;
};