diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-17 00:02:38 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-17 00:03:33 +0100 |
commit | fe96418a70f52a615f91c44d784139f966795f68 (patch) | |
tree | 5de76bf041847e1ea6d94054c06c325fa0b3fe5c /Userland/Libraries/LibGfx | |
parent | 447e6da52c319a012cd877346b936fb109f64527 (diff) | |
download | serenity-fe96418a70f52a615f91c44d784139f966795f68.zip |
LibGfx: Remove remaining SharedBuffer support in Gfx::Bitmap
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/Bitmap.cpp | 51 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Bitmap.h | 9 |
2 files changed, 0 insertions, 60 deletions
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 <AK/MemoryStream.h> #include <AK/Optional.h> #include <AK/ScopeGuard.h> -#include <AK/SharedBuffer.h> #include <AK/String.h> #include <LibGfx/BMPLoader.h> #include <LibGfx/Bitmap.h> @@ -165,11 +164,6 @@ Bitmap::Bitmap(BitmapFormat format, const IntSize& size, size_t pitch, void* dat allocate_palette_from_format(format, {}); } -RefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& 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> Bitmap::create_with_anon_fd(BitmapFormat format, int anon_fd, con return adopt(*new Bitmap(format, anon_fd, size, data, palette)); } -RefPtr<Bitmap> Bitmap::create_with_shared_buffer(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer, const IntSize& size, const Vector<RGBA32>& 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<SharedBuffer>&& shared_buffer, const IntSize& size, const Vector<RGBA32>& palette) - : m_size(size) - , m_data(shared_buffer->data<void>()) - , 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<size_t>(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<RGBA32>& palette) : m_size(size) , m_data(data) @@ -411,20 +379,6 @@ RefPtr<Gfx::Bitmap> Bitmap::flipped(Gfx::Orientation orientation) const return new_bitmap; } -RefPtr<Bitmap> 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<void>(), scanline(0), size_in_bytes()); - return bitmap; -} - #ifdef __serenity__ RefPtr<Bitmap> 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<Bitmap> create_wrapper(BitmapFormat, const IntSize&, size_t pitch, void*); static RefPtr<Bitmap> load_from_file(const StringView& path); static RefPtr<Bitmap> create_with_anon_fd(BitmapFormat, int anon_fd, const IntSize&, const Vector<RGBA32>& palette, ShouldCloseAnonymousFile); - static RefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const IntSize&); - static RefPtr<Bitmap> create_with_shared_buffer(BitmapFormat, NonnullRefPtr<SharedBuffer>&&, const IntSize&, const Vector<RGBA32>& palette); static RefPtr<Bitmap> create_from_serialized_byte_buffer(ByteBuffer&& buffer); static bool is_path_a_supported_image_format(const StringView& path) { @@ -132,7 +130,6 @@ public: RefPtr<Gfx::Bitmap> rotated(Gfx::RotationDirection) const; RefPtr<Gfx::Bitmap> flipped(Gfx::Orientation) const; - RefPtr<Bitmap> to_bitmap_backed_by_shared_buffer() const; RefPtr<Bitmap> 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<SharedBuffer>&&, const IntSize&, const Vector<RGBA32>& palette); Bitmap(BitmapFormat, int anon_fd, const IntSize&, void*, const Vector<RGBA32>& palette); static Optional<BackingStore> 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<SharedBuffer> m_shared_buffer; int m_anon_fd { -1 }; }; |