diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index dcaba24a77..6296e4512c 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -165,11 +164,6 @@ Bitmap::Bitmap(BitmapFormat format, const IntSize& size, size_t pitch, void* dat allocate_palette_from_format(format, {}); } -RefPtr Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr&& shared_buffer, const IntSize& size) -{ - return create_with_shared_buffer(format, move(shared_buffer), size, {}); -} - static bool check_size(const IntSize& size, BitmapFormat format, unsigned actual_size) { @@ -219,17 +213,6 @@ RefPtr Bitmap::create_with_anon_fd(BitmapFormat format, int anon_fd, con return adopt(*new Bitmap(format, anon_fd, size, data, palette)); } -RefPtr Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr&& shared_buffer, const IntSize& size, const Vector& palette) -{ - if (size_would_overflow(format, size)) - return nullptr; - - if (!check_size(size, format, shared_buffer->size())) - return {}; - - return adopt(*new Bitmap(format, move(shared_buffer), size, palette)); -} - /// Read a bitmap as described by: /// - actual size /// - width @@ -315,21 +298,6 @@ ByteBuffer Bitmap::serialize_to_byte_buffer() const return buffer; } -Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr&& shared_buffer, const IntSize& size, const Vector& palette) - : m_size(size) - , m_data(shared_buffer->data()) - , m_pitch(minimum_pitch(size.width(), format)) - , m_format(format) - , m_shared_buffer(move(shared_buffer)) -{ - ASSERT(!is_indexed() || !palette.is_empty()); - ASSERT(!size_would_overflow(format, size)); - ASSERT(size_in_bytes() <= static_cast(m_shared_buffer->size())); - - if (is_indexed(m_format)) - allocate_palette_from_format(m_format, palette); -} - Bitmap::Bitmap(BitmapFormat format, int anon_fd, const IntSize& size, void* data, const Vector& palette) : m_size(size) , m_data(data) @@ -411,20 +379,6 @@ RefPtr Bitmap::flipped(Gfx::Orientation orientation) const return new_bitmap; } -RefPtr Bitmap::to_bitmap_backed_by_shared_buffer() const -{ - if (m_shared_buffer) - return *this; - auto buffer = SharedBuffer::create_with_size(size_in_bytes()); - if (!buffer) - return nullptr; - auto bitmap = Bitmap::create_with_shared_buffer(m_format, *buffer, m_size, palette_to_vector()); - if (!bitmap) - return nullptr; - memcpy(buffer->data(), scanline(0), size_in_bytes()); - return bitmap; -} - #ifdef __serenity__ RefPtr Bitmap::to_bitmap_backed_by_anon_fd() const { @@ -505,11 +459,6 @@ void Bitmap::set_volatile() return rc == 0; } -int Bitmap::shbuf_id() const -{ - return m_shared_buffer ? m_shared_buffer->shbuf_id() : -1; -} - #ifdef __serenity__ ShareableBitmap Bitmap::to_shareable_bitmap() const { diff --git a/Userland/Libraries/LibGfx/Bitmap.h b/Userland/Libraries/LibGfx/Bitmap.h index 09b90222d6..47098f17ff 100644 --- a/Userland/Libraries/LibGfx/Bitmap.h +++ b/Userland/Libraries/LibGfx/Bitmap.h @@ -114,8 +114,6 @@ public: static RefPtr create_wrapper(BitmapFormat, const IntSize&, size_t pitch, void*); static RefPtr load_from_file(const StringView& path); static RefPtr create_with_anon_fd(BitmapFormat, int anon_fd, const IntSize&, const Vector& palette, ShouldCloseAnonymousFile); - static RefPtr create_with_shared_buffer(BitmapFormat, NonnullRefPtr&&, const IntSize&); - static RefPtr create_with_shared_buffer(BitmapFormat, NonnullRefPtr&&, const IntSize&, const Vector& palette); static RefPtr create_from_serialized_byte_buffer(ByteBuffer&& buffer); static bool is_path_a_supported_image_format(const StringView& path) { @@ -132,7 +130,6 @@ public: RefPtr rotated(Gfx::RotationDirection) const; RefPtr flipped(Gfx::Orientation) const; - RefPtr to_bitmap_backed_by_shared_buffer() const; RefPtr to_bitmap_backed_by_anon_fd() const; ByteBuffer serialize_to_byte_buffer() const; @@ -150,10 +147,6 @@ public: int width() const { return m_size.width(); } int height() const { return m_size.height(); } size_t pitch() const { return m_pitch; } - int shbuf_id() const; - - SharedBuffer* shared_buffer() { return m_shared_buffer.ptr(); } - const SharedBuffer* shared_buffer() const { return m_shared_buffer.ptr(); } ALWAYS_INLINE bool is_indexed() const { @@ -255,7 +248,6 @@ private: }; Bitmap(BitmapFormat, const IntSize&, Purgeable, const BackingStore&); Bitmap(BitmapFormat, const IntSize&, size_t pitch, void*); - Bitmap(BitmapFormat, NonnullRefPtr&&, const IntSize&, const Vector& palette); Bitmap(BitmapFormat, int anon_fd, const IntSize&, void*, const Vector& palette); static Optional allocate_backing_store(BitmapFormat, const IntSize&, Purgeable); @@ -270,7 +262,6 @@ private: bool m_needs_munmap { false }; bool m_purgeable { false }; bool m_volatile { false }; - RefPtr m_shared_buffer; int m_anon_fd { -1 }; };