diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-16 11:23:22 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-16 11:26:53 +0100 |
commit | 58b435f49e58be34755b317ac7405e8722855bd2 (patch) | |
tree | 19be1859ca265bd4fe7468d07a64431e7c04cdce /Userland/Libraries/LibGfx/ShareableBitmap.cpp | |
parent | f18d89b36d6762324af8ff420230b409efd95d81 (diff) | |
download | serenity-58b435f49e58be34755b317ac7405e8722855bd2.zip |
LibGfx: Short-circuit ShareableBitmap construction in IPC decoder
When decoding a ShareableBitmap that came over IPC, it's safe to assume
that it's backed by an anonymous file (since we just decoded it.)
Diffstat (limited to 'Userland/Libraries/LibGfx/ShareableBitmap.cpp')
-rw-r--r-- | Userland/Libraries/LibGfx/ShareableBitmap.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/ShareableBitmap.cpp b/Userland/Libraries/LibGfx/ShareableBitmap.cpp index 2ab5ece797..1edf498096 100644 --- a/Userland/Libraries/LibGfx/ShareableBitmap.cpp +++ b/Userland/Libraries/LibGfx/ShareableBitmap.cpp @@ -38,6 +38,11 @@ ShareableBitmap::ShareableBitmap(const Bitmap& bitmap) { } +ShareableBitmap::ShareableBitmap(NonnullRefPtr<Bitmap> bitmap, Tag) + : m_bitmap(move(bitmap)) +{ +} + } namespace IPC { @@ -70,7 +75,9 @@ bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap) return false; auto bitmap = Gfx::Bitmap::create_with_anon_fd(Gfx::BitmapFormat::RGBA32, anon_file.take_fd(), size, Gfx::Bitmap::ShouldCloseAnonymousFile::Yes); - shareable_bitmap = bitmap->to_shareable_bitmap(); + if (!bitmap) + return false; + shareable_bitmap = Gfx::ShareableBitmap { bitmap.release_nonnull(), Gfx::ShareableBitmap::ConstructWithKnownGoodBitmap }; return true; } |