mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +00:00
LibGUI+WindowServer: Use anonymous files for window backing stores :^)
This patch replaces the use of shbufs for GUI::Window backing stores with the new anonymous files mechanism. Backing bitmaps are now built on memory allocated with anon_create(). They are passed across the IPC socket as IPC::File. This means that WindowServer now pledges "recvfd" and graphical clients need to pledge "sendfd" to work. To support the cached bitmap swapping optimization on the WindowServer side, each backing store is assigned an incrementing serial number on the client side. (This allows us to re-use an already mapped file.)
This commit is contained in:
parent
4d97b955e6
commit
0b0514d46b
5 changed files with 42 additions and 19 deletions
|
@ -571,17 +571,15 @@ OwnPtr<Messages::WindowServer::SetWindowBackingStoreResponse> ClientConnection::
|
|||
return {};
|
||||
}
|
||||
auto& window = *(*it).value;
|
||||
if (window.last_backing_store() && window.last_backing_store()->shbuf_id() == message.shbuf_id()) {
|
||||
if (window.last_backing_store() && window.last_backing_store_serial() == message.serial()) {
|
||||
window.swap_backing_stores();
|
||||
} else {
|
||||
auto shared_buffer = SharedBuffer::create_from_shbuf_id(message.shbuf_id());
|
||||
if (!shared_buffer)
|
||||
return make<Messages::WindowServer::SetWindowBackingStoreResponse>();
|
||||
auto backing_store = Gfx::Bitmap::create_with_shared_buffer(
|
||||
auto backing_store = Gfx::Bitmap::create_with_anon_fd(
|
||||
message.has_alpha_channel() ? Gfx::BitmapFormat::RGBA32 : Gfx::BitmapFormat::RGB32,
|
||||
*shared_buffer,
|
||||
message.size());
|
||||
window.set_backing_store(move(backing_store));
|
||||
message.anon_file().take_fd(),
|
||||
message.size(),
|
||||
Gfx::Bitmap::ShouldCloseAnonymousFile::Yes);
|
||||
window.set_backing_store(move(backing_store), message.serial());
|
||||
}
|
||||
|
||||
if (message.flush_immediately())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue