From 1898aa8cd4b4c180bcca2010f2ae64f3620b4d46 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 2 Jan 2021 16:25:10 +0100 Subject: [PATCH] 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. --- Libraries/LibWeb/OutOfProcessWebView.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Libraries/LibWeb/OutOfProcessWebView.cpp b/Libraries/LibWeb/OutOfProcessWebView.cpp index 50c71de703..18e8953d5e 100644 --- a/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -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();