mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibGUI+WindowServer: Improve window resizing performance
The old `GUI::Window` resizing behavior created a new backing store for each resize event (i.e. every visible window size). This caused a lot of trashing and on my machine, caused up to 25% of CPU time spent in creating new backing stores. The new behavior is a bit more sensible: * If the window size is shrinking, the backing store is already large enough to contain the entire window - so we don't create a new one. * If the window size is growing, as soon as the backing store can no longer contain the window, it is inflated with a large margin (of an arbitrary chosen 64 pixels) in both directions to accommodate some leeway in resizing before an even larger backing store is required. * When the user stops resizing the window, the backing store is resized to the exact dimensions of the window. For me, this brings the CPU time for creating backing stores down to 0%.
This commit is contained in:
parent
45e85d20b6
commit
634d1e0197
8 changed files with 73 additions and 39 deletions
|
@ -733,7 +733,7 @@ void ConnectionFromClient::did_finish_painting(i32 window_id, Vector<Gfx::IntRec
|
|||
|
||||
void ConnectionFromClient::set_window_backing_store(i32 window_id, [[maybe_unused]] i32 bpp,
|
||||
[[maybe_unused]] i32 pitch, IPC::File const& anon_file, i32 serial, bool has_alpha_channel,
|
||||
Gfx::IntSize size, bool flush_immediately)
|
||||
Gfx::IntSize size, Gfx::IntSize visible_size, bool flush_immediately)
|
||||
{
|
||||
auto it = m_windows.find(window_id);
|
||||
if (it == m_windows.end()) {
|
||||
|
@ -761,6 +761,7 @@ void ConnectionFromClient::set_window_backing_store(i32 window_id, [[maybe_unuse
|
|||
}
|
||||
window.set_backing_store(backing_store_or_error.release_value(), serial);
|
||||
}
|
||||
window.set_backing_store_visible_size(visible_size);
|
||||
|
||||
if (flush_immediately)
|
||||
window.invalidate(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue