mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibGfx: Make Gfx::Bitmap::create_shareable() use an anonymous file
Note that this is only used by OOPWV in LibWeb at the moment.
This commit is contained in:
parent
c16e36be48
commit
04b2aeef33
1 changed files with 6 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue