diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index 01be0a51964..efbb6622188 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -18,9 +18,6 @@ #include #include #include -#include -#include -#include #include namespace Gfx { @@ -281,50 +278,3 @@ bool Bitmap::visually_equals(Bitmap const& other) const } } - -namespace IPC { - -template<> -ErrorOr encode(Encoder& encoder, AK::NonnullRefPtr const& bitmap) -{ - Core::AnonymousBuffer buffer; - if (bitmap->anonymous_buffer().is_valid()) { - buffer = bitmap->anonymous_buffer(); - } else { - buffer = MUST(Core::AnonymousBuffer::create_with_size(bitmap->size_in_bytes())); - memcpy(buffer.data(), bitmap->scanline(0), bitmap->size_in_bytes()); - } - TRY(encoder.encode(TRY(IPC::File::clone_fd(buffer.fd())))); - TRY(encoder.encode(static_cast(bitmap->format()))); - TRY(encoder.encode(static_cast(bitmap->alpha_type()))); - TRY(encoder.encode(bitmap->size_in_bytes())); - TRY(encoder.encode(bitmap->pitch())); - TRY(encoder.encode(bitmap->size())); - return {}; -} - -template<> -ErrorOr> decode(Decoder& decoder) -{ - auto anon_file = TRY(decoder.decode()); - - auto raw_bitmap_format = TRY(decoder.decode()); - if (!Gfx::is_valid_bitmap_format(raw_bitmap_format)) - return Error::from_string_literal("IPC: Invalid Gfx::ShareableBitmap format"); - auto bitmap_format = static_cast(raw_bitmap_format); - - auto raw_alpha_type = TRY(decoder.decode()); - if (!Gfx::is_valid_alpha_type(raw_alpha_type)) - return Error::from_string_literal("IPC: Invalid Gfx::ShareableBitmap alpha type"); - auto alpha_type = static_cast(raw_alpha_type); - - auto size_in_bytes = TRY(decoder.decode()); - auto pitch = TRY(decoder.decode()); - auto size = TRY(decoder.decode()); - auto* data = TRY(Core::System::mmap(nullptr, round_up_to_power_of_two(size_in_bytes, PAGE_SIZE), PROT_READ | PROT_WRITE, MAP_SHARED, anon_file.fd(), 0)); - return Gfx::Bitmap::create_wrapper(bitmap_format, alpha_type, size, pitch, data, [data, size_in_bytes] { - MUST(Core::System::munmap(data, size_in_bytes)); - }); -} - -} diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index 29ae045bb13..e83a65feb9f 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -15,7 +15,6 @@ #include #include #include -#include namespace Gfx { @@ -344,13 +343,3 @@ ALWAYS_INLINE void Bitmap::set_pixel(int x, int y, Color color) } } - -namespace IPC { - -template<> -ErrorOr encode(Encoder&, AK::NonnullRefPtr const&); - -template<> -ErrorOr> decode(Decoder&); - -}