LibWeb: Use Gfx::Bitmap::create_shareable() in OOPWV

We were jumping through some pretty wasteful hoops in the resize event
handler of OOPWV by first creating a bitmap and then immediately
creating a new (shareable) clone of that bitmap. Now we go straight
to the shareable bitmap instead.
This commit is contained in:
Andreas Kling 2021-01-02 16:25:10 +01:00
parent 0bc8d58c3b
commit 1898aa8cd4

View file

@ -104,18 +104,14 @@ void OutOfProcessWebView::resize_event(GUI::ResizeEvent& event)
if (available_size().is_empty())
return;
// FIXME: Don't create a temporary bitmap just to convert it to one backed by a shared buffer.
if (auto helper = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, available_size())) {
m_front_bitmap = helper->to_bitmap_backed_by_shared_buffer();
ASSERT(m_front_bitmap);
m_front_bitmap->shared_buffer()->share_with(client().server_pid());
if (auto new_bitmap = Gfx::Bitmap::create_shareable(Gfx::BitmapFormat::RGB32, available_size())) {
new_bitmap->shared_buffer()->share_with(client().server_pid());
m_front_bitmap = move(new_bitmap);
}
// FIXME: Don't create a temporary bitmap just to convert it to one backed by a shared buffer.
if (auto helper = Gfx::Bitmap::create(Gfx::BitmapFormat::RGB32, available_size())) {
m_back_bitmap = helper->to_bitmap_backed_by_shared_buffer();
ASSERT(m_back_bitmap);
m_back_bitmap->shared_buffer()->share_with(client().server_pid());
if (auto new_bitmap = Gfx::Bitmap::create_shareable(Gfx::BitmapFormat::RGB32, available_size())) {
new_bitmap->shared_buffer()->share_with(client().server_pid());
m_back_bitmap = move(new_bitmap);
}
request_repaint();