summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-16 23:14:24 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-16 23:21:52 +0100
commit04b2aeef337642559596d1f01a4ba698ef9fa8c2 (patch)
tree67675ac0198eb88d55bd4ad11341314f71ec1de4 /Userland
parentc16e36be488a68de2f5f6147faf346fddcdebb11 (diff)
downloadserenity-04b2aeef337642559596d1f01a4ba698ef9fa8c2.zip
LibGfx: Make Gfx::Bitmap::create_shareable() use an anonymous file
Note that this is only used by OOPWV in LibWeb at the moment.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGfx/Bitmap.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp
index 5de2da2062..1d3097e207 100644
--- a/Userland/Libraries/LibGfx/Bitmap.cpp
+++ b/Userland/Libraries/LibGfx/Bitmap.cpp
@@ -103,6 +103,7 @@ RefPtr<Bitmap> Bitmap::create_purgeable(BitmapFormat format, const IntSize& size
return adopt(*new Bitmap(format, size, Purgeable::Yes, backing_store.value()));
}
+#ifdef __serenity__
RefPtr<Bitmap> Bitmap::create_shareable(BitmapFormat format, const IntSize& size)
{
if (size_would_overflow(format, size))
@@ -110,11 +111,13 @@ RefPtr<Bitmap> Bitmap::create_shareable(BitmapFormat format, const IntSize& size
const auto pitch = minimum_pitch(size.width(), format);
const auto data_size = size_in_bytes(pitch, size.height());
- auto shared_buffer = SharedBuffer::create_with_size(data_size);
- if (!shared_buffer)
+
+ auto anon_fd = anon_create(round_up_to_power_of_two(data_size, PAGE_SIZE), O_CLOEXEC);
+ if (anon_fd < 0)
return nullptr;
- return adopt(*new Bitmap(format, shared_buffer.release_nonnull(), size, Vector<RGBA32>()));
+ return Bitmap::create_with_anon_fd(format, anon_fd, size, ShouldCloseAnonymousFile::No);
}
+#endif
Bitmap::Bitmap(BitmapFormat format, const IntSize& size, Purgeable purgeable, const BackingStore& backing_store)
: m_size(size)