1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 23:35:08 +00:00

Add a C++ helper class for working with shared buffers.

This is a bit more comfortable than passing the shared buffer ID manually
everywhere and keeping track of size etc.
This commit is contained in:
Andreas Kling 2019-03-08 12:22:55 +01:00
parent 0b5d5fc3c9
commit eda0866992
14 changed files with 186 additions and 46 deletions

View file

@ -172,15 +172,12 @@ void GWindow::event(GEvent& event)
ASSERT(!paint_event.window_size().is_empty());
Size new_backing_store_size = paint_event.window_size();
size_t size_in_bytes = new_backing_store_size.area() * sizeof(RGBA32);
void* buffer;
int shared_buffer_id = create_shared_buffer(GEventLoop::main().server_pid(), size_in_bytes, (void**)&buffer);
ASSERT(shared_buffer_id >= 0);
ASSERT(buffer);
ASSERT(buffer != (void*)-1);
auto shared_buffer = SharedBuffer::create(GEventLoop::main().server_pid(), size_in_bytes);
ASSERT(shared_buffer);
m_backing = GraphicsBitmap::create_with_shared_buffer(
m_has_alpha_channel ? GraphicsBitmap::Format::RGBA32 : GraphicsBitmap::Format::RGB32,
shared_buffer_id,
new_backing_store_size, (RGBA32*)buffer);
*shared_buffer,
new_backing_store_size);
}
if (rect.is_empty() || created_new_backing_store)
rect = m_main_widget->rect();