summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/FileIconProvider.cpp2
-rw-r--r--Userland/Libraries/LibGfx/BMPLoader.cpp22
-rw-r--r--Userland/Libraries/LibGfx/BMPLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/DDSLoader.cpp28
-rw-r--r--Userland/Libraries/LibGfx/DDSLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/GIFLoader.cpp8
-rw-r--r--Userland/Libraries/LibGfx/GIFLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/ICOLoader.cpp38
-rw-r--r--Userland/Libraries/LibGfx/ICOLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/ImageDecoder.h2
-rw-r--r--Userland/Libraries/LibGfx/JPGLoader.cpp29
-rw-r--r--Userland/Libraries/LibGfx/JPGLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/PBMLoader.cpp28
-rw-r--r--Userland/Libraries/LibGfx/PBMLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/PGMLoader.cpp28
-rw-r--r--Userland/Libraries/LibGfx/PGMLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/PNGLoader.cpp30
-rw-r--r--Userland/Libraries/LibGfx/PNGLoader.h1
-rw-r--r--Userland/Libraries/LibGfx/PPMLoader.cpp28
-rw-r--r--Userland/Libraries/LibGfx/PPMLoader.h1
20 files changed, 101 insertions, 151 deletions
diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp
index 066ba4463f..716e90fc27 100644
--- a/Userland/Libraries/LibGUI/FileIconProvider.cpp
+++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp
@@ -188,7 +188,7 @@ Icon FileIconProvider::icon_for_executable(const String& path)
if (!section.has_value()) {
bitmap = s_executable_icon.bitmap_for_size(icon_section.image_size);
} else {
- bitmap = Gfx::PNGImageDecoderPlugin(reinterpret_cast<u8 const*>(section->raw_data()), section->size()).bitmap();
+ bitmap = Gfx::PNGImageDecoderPlugin(reinterpret_cast<u8 const*>(section->raw_data()), section->size()).frame(0).image;
}
if (!bitmap) {
diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp
index d96512fec0..04e406ac76 100644
--- a/Userland/Libraries/LibGfx/BMPLoader.cpp
+++ b/Userland/Libraries/LibGfx/BMPLoader.cpp
@@ -1321,18 +1321,6 @@ IntSize BMPImageDecoderPlugin::size()
return { m_context->dib.core.width, abs(m_context->dib.core.height) };
}
-RefPtr<Gfx::Bitmap> BMPImageDecoderPlugin::bitmap()
-{
- if (m_context->state == BMPLoadingContext::State::Error)
- return nullptr;
-
- if (m_context->state < BMPLoadingContext::State::PixelDataDecoded && !decode_bmp_pixel_data(*m_context))
- return nullptr;
-
- VERIFY(m_context->bitmap);
- return m_context->bitmap;
-}
-
void BMPImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@@ -1370,7 +1358,15 @@ ImageFrameDescriptor BMPImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == BMPLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < BMPLoadingContext::State::PixelDataDecoded && !decode_bmp_pixel_data(*m_context))
+ return {};
+
+ VERIFY(m_context->bitmap);
+ return { m_context->bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/BMPLoader.h b/Userland/Libraries/LibGfx/BMPLoader.h
index 926b69377b..f848ac4dd5 100644
--- a/Userland/Libraries/LibGfx/BMPLoader.h
+++ b/Userland/Libraries/LibGfx/BMPLoader.h
@@ -18,7 +18,6 @@ public:
BMPImageDecoderPlugin(const u8*, size_t);
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
virtual bool sniff() override;
diff --git a/Userland/Libraries/LibGfx/DDSLoader.cpp b/Userland/Libraries/LibGfx/DDSLoader.cpp
index 6553f41367..915990465b 100644
--- a/Userland/Libraries/LibGfx/DDSLoader.cpp
+++ b/Userland/Libraries/LibGfx/DDSLoader.cpp
@@ -959,21 +959,6 @@ IntSize DDSImageDecoderPlugin::size()
return {};
}
-RefPtr<Gfx::Bitmap> DDSImageDecoderPlugin::bitmap()
-{
- if (m_context->state == DDSLoadingContext::State::Error)
- return nullptr;
-
- if (m_context->state < DDSLoadingContext::State::BitmapDecoded) {
- bool success = decode_dds(*m_context);
- if (!success)
- return nullptr;
- }
-
- VERIFY(m_context->bitmap);
- return m_context->bitmap;
-}
-
void DDSImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@@ -1016,7 +1001,18 @@ ImageFrameDescriptor DDSImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == DDSLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < DDSLoadingContext::State::BitmapDecoded) {
+ bool success = decode_dds(*m_context);
+ if (!success)
+ return {};
+ }
+
+ VERIFY(m_context->bitmap);
+ return { m_context->bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/DDSLoader.h b/Userland/Libraries/LibGfx/DDSLoader.h
index 96e1ce21d7..1ba87da25e 100644
--- a/Userland/Libraries/LibGfx/DDSLoader.h
+++ b/Userland/Libraries/LibGfx/DDSLoader.h
@@ -239,7 +239,6 @@ public:
DDSImageDecoderPlugin(const u8*, size_t);
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
virtual bool sniff() override;
diff --git a/Userland/Libraries/LibGfx/GIFLoader.cpp b/Userland/Libraries/LibGfx/GIFLoader.cpp
index 95b47d4537..49f7a0b1c8 100644
--- a/Userland/Libraries/LibGfx/GIFLoader.cpp
+++ b/Userland/Libraries/LibGfx/GIFLoader.cpp
@@ -623,14 +623,6 @@ IntSize GIFImageDecoderPlugin::size()
return { m_context->logical_screen.width, m_context->logical_screen.height };
}
-RefPtr<Gfx::Bitmap> GIFImageDecoderPlugin::bitmap()
-{
- if (m_context->state < GIFLoadingContext::State::FrameComplete) {
- return frame(0).image;
- }
- return m_context->frame_buffer;
-}
-
void GIFImageDecoderPlugin::set_volatile()
{
if (m_context->frame_buffer) {
diff --git a/Userland/Libraries/LibGfx/GIFLoader.h b/Userland/Libraries/LibGfx/GIFLoader.h
index 8d7df27953..d3960cd8d0 100644
--- a/Userland/Libraries/LibGfx/GIFLoader.h
+++ b/Userland/Libraries/LibGfx/GIFLoader.h
@@ -19,7 +19,6 @@ public:
GIFImageDecoderPlugin(const u8*, size_t);
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
virtual bool sniff() override;
diff --git a/Userland/Libraries/LibGfx/ICOLoader.cpp b/Userland/Libraries/LibGfx/ICOLoader.cpp
index 42ad214a22..4056d7c0f0 100644
--- a/Userland/Libraries/LibGfx/ICOLoader.cpp
+++ b/Userland/Libraries/LibGfx/ICOLoader.cpp
@@ -263,7 +263,7 @@ static bool load_ico_bitmap(ICOLoadingContext& context, Optional<size_t> index)
PNGImageDecoderPlugin png_decoder(context.data + desc.offset, desc.size);
if (png_decoder.sniff()) {
- desc.bitmap = png_decoder.bitmap();
+ desc.bitmap = png_decoder.frame(0).image;
if (!desc.bitmap) {
dbgln_if(ICO_DEBUG, "load_ico_bitmap: failed to load PNG encoded image index: {}", real_index);
return false;
@@ -304,25 +304,6 @@ IntSize ICOImageDecoderPlugin::size()
return { m_context->images[m_context->largest_index].width, m_context->images[m_context->largest_index].height };
}
-RefPtr<Gfx::Bitmap> ICOImageDecoderPlugin::bitmap()
-{
- if (m_context->state == ICOLoadingContext::State::Error)
- return nullptr;
-
- if (m_context->state < ICOLoadingContext::State::BitmapDecoded) {
- // NOTE: This forces the chunk decoding to happen.
- bool success = load_ico_bitmap(*m_context, {});
- if (!success) {
- m_context->state = ICOLoadingContext::State::Error;
- return nullptr;
- }
- m_context->state = ICOLoadingContext::State::BitmapDecoded;
- }
-
- VERIFY(m_context->images[m_context->largest_index].bitmap);
- return m_context->images[m_context->largest_index].bitmap;
-}
-
void ICOImageDecoderPlugin::set_volatile()
{
if (m_context->images[0].bitmap)
@@ -361,7 +342,22 @@ ImageFrameDescriptor ICOImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == ICOLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < ICOLoadingContext::State::BitmapDecoded) {
+ // NOTE: This forces the chunk decoding to happen.
+ bool success = load_ico_bitmap(*m_context, {});
+ if (!success) {
+ m_context->state = ICOLoadingContext::State::Error;
+ return {};
+ }
+ m_context->state = ICOLoadingContext::State::BitmapDecoded;
+ }
+
+ VERIFY(m_context->images[m_context->largest_index].bitmap);
+ return { m_context->images[m_context->largest_index].bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/ICOLoader.h b/Userland/Libraries/LibGfx/ICOLoader.h
index d30939cc5c..0340b6249e 100644
--- a/Userland/Libraries/LibGfx/ICOLoader.h
+++ b/Userland/Libraries/LibGfx/ICOLoader.h
@@ -18,7 +18,6 @@ public:
ICOImageDecoderPlugin(const u8*, size_t);
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
virtual bool sniff() override;
diff --git a/Userland/Libraries/LibGfx/ImageDecoder.h b/Userland/Libraries/LibGfx/ImageDecoder.h
index d3c8272b83..7641402b99 100644
--- a/Userland/Libraries/LibGfx/ImageDecoder.h
+++ b/Userland/Libraries/LibGfx/ImageDecoder.h
@@ -42,8 +42,6 @@ public:
virtual ImageFrameDescriptor frame(size_t i) = 0;
protected:
- virtual RefPtr<Gfx::Bitmap> bitmap() = 0;
-
ImageDecoderPlugin() { }
};
diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp
index 0c2559e279..c32dac6cec 100644
--- a/Userland/Libraries/LibGfx/JPGLoader.cpp
+++ b/Userland/Libraries/LibGfx/JPGLoader.cpp
@@ -1240,21 +1240,6 @@ IntSize JPGImageDecoderPlugin::size()
return {};
}
-RefPtr<Gfx::Bitmap> JPGImageDecoderPlugin::bitmap()
-{
- if (m_context->state == JPGLoadingContext::State::Error)
- return nullptr;
- if (m_context->state < JPGLoadingContext::State::BitmapDecoded) {
- if (!decode_jpg(*m_context)) {
- m_context->state = JPGLoadingContext::State::Error;
- return nullptr;
- }
- m_context->state = JPGLoadingContext::State::BitmapDecoded;
- }
-
- return m_context->bitmap;
-}
-
void JPGImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@@ -1295,7 +1280,19 @@ ImageFrameDescriptor JPGImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == JPGLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < JPGLoadingContext::State::BitmapDecoded) {
+ if (!decode_jpg(*m_context)) {
+ m_context->state = JPGLoadingContext::State::Error;
+ return {};
+ }
+ m_context->state = JPGLoadingContext::State::BitmapDecoded;
+ }
+
+ return { m_context->bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/JPGLoader.h b/Userland/Libraries/LibGfx/JPGLoader.h
index 3dc67827ec..13573ea0ee 100644
--- a/Userland/Libraries/LibGfx/JPGLoader.h
+++ b/Userland/Libraries/LibGfx/JPGLoader.h
@@ -17,7 +17,6 @@ public:
virtual ~JPGImageDecoderPlugin() override;
JPGImageDecoderPlugin(const u8*, size_t);
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
virtual bool sniff() override;
diff --git a/Userland/Libraries/LibGfx/PBMLoader.cpp b/Userland/Libraries/LibGfx/PBMLoader.cpp
index 49115a47b2..4b2f45c8b3 100644
--- a/Userland/Libraries/LibGfx/PBMLoader.cpp
+++ b/Userland/Libraries/LibGfx/PBMLoader.cpp
@@ -119,21 +119,6 @@ IntSize PBMImageDecoderPlugin::size()
return { m_context->width, m_context->height };
}
-RefPtr<Gfx::Bitmap> PBMImageDecoderPlugin::bitmap()
-{
- if (m_context->state == PBMLoadingContext::State::Error)
- return nullptr;
-
- if (m_context->state < PBMLoadingContext::State::Decoded) {
- bool success = decode(*m_context);
- if (!success)
- return nullptr;
- }
-
- VERIFY(m_context->bitmap);
- return m_context->bitmap;
-}
-
void PBMImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@@ -181,7 +166,18 @@ ImageFrameDescriptor PBMImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == PBMLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < PBMLoadingContext::State::Decoded) {
+ bool success = decode(*m_context);
+ if (!success)
+ return {};
+ }
+
+ VERIFY(m_context->bitmap);
+ return { m_context->bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/PBMLoader.h b/Userland/Libraries/LibGfx/PBMLoader.h
index 5f3a512d80..ce7c26558b 100644
--- a/Userland/Libraries/LibGfx/PBMLoader.h
+++ b/Userland/Libraries/LibGfx/PBMLoader.h
@@ -18,7 +18,6 @@ public:
virtual ~PBMImageDecoderPlugin() override;
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
diff --git a/Userland/Libraries/LibGfx/PGMLoader.cpp b/Userland/Libraries/LibGfx/PGMLoader.cpp
index 59c2ee95a4..837563e27b 100644
--- a/Userland/Libraries/LibGfx/PGMLoader.cpp
+++ b/Userland/Libraries/LibGfx/PGMLoader.cpp
@@ -122,21 +122,6 @@ IntSize PGMImageDecoderPlugin::size()
return { m_context->width, m_context->height };
}
-RefPtr<Gfx::Bitmap> PGMImageDecoderPlugin::bitmap()
-{
- if (m_context->state == PGMLoadingContext::State::Error)
- return nullptr;
-
- if (m_context->state < PGMLoadingContext::State::Decoded) {
- bool success = decode(*m_context);
- if (!success)
- return nullptr;
- }
-
- VERIFY(m_context->bitmap);
- return m_context->bitmap;
-}
-
void PGMImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@@ -184,7 +169,18 @@ ImageFrameDescriptor PGMImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == PGMLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < PGMLoadingContext::State::Decoded) {
+ bool success = decode(*m_context);
+ if (!success)
+ return {};
+ }
+
+ VERIFY(m_context->bitmap);
+ return { m_context->bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/PGMLoader.h b/Userland/Libraries/LibGfx/PGMLoader.h
index 5815224e54..f3190ef709 100644
--- a/Userland/Libraries/LibGfx/PGMLoader.h
+++ b/Userland/Libraries/LibGfx/PGMLoader.h
@@ -18,7 +18,6 @@ public:
virtual ~PGMImageDecoderPlugin() override;
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp
index a0625cec71..13220dfe53 100644
--- a/Userland/Libraries/LibGfx/PNGLoader.cpp
+++ b/Userland/Libraries/LibGfx/PNGLoader.cpp
@@ -931,22 +931,6 @@ IntSize PNGImageDecoderPlugin::size()
return { m_context->width, m_context->height };
}
-RefPtr<Gfx::Bitmap> PNGImageDecoderPlugin::bitmap()
-{
- if (m_context->state == PNGLoadingContext::State::Error)
- return nullptr;
-
- if (m_context->state < PNGLoadingContext::State::BitmapDecoded) {
- // NOTE: This forces the chunk decoding to happen.
- bool success = decode_png_bitmap(*m_context);
- if (!success)
- return nullptr;
- }
-
- VERIFY(m_context->bitmap);
- return m_context->bitmap;
-}
-
void PNGImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@@ -984,7 +968,19 @@ ImageFrameDescriptor PNGImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == PNGLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < PNGLoadingContext::State::BitmapDecoded) {
+ // NOTE: This forces the chunk decoding to happen.
+ bool success = decode_png_bitmap(*m_context);
+ if (!success)
+ return {};
+ }
+
+ VERIFY(m_context->bitmap);
+ return { m_context->bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/PNGLoader.h b/Userland/Libraries/LibGfx/PNGLoader.h
index c98ab9be25..77c4b19c3d 100644
--- a/Userland/Libraries/LibGfx/PNGLoader.h
+++ b/Userland/Libraries/LibGfx/PNGLoader.h
@@ -18,7 +18,6 @@ public:
PNGImageDecoderPlugin(const u8*, size_t);
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
virtual bool sniff() override;
diff --git a/Userland/Libraries/LibGfx/PPMLoader.cpp b/Userland/Libraries/LibGfx/PPMLoader.cpp
index 8a98683fab..5316c27ab0 100644
--- a/Userland/Libraries/LibGfx/PPMLoader.cpp
+++ b/Userland/Libraries/LibGfx/PPMLoader.cpp
@@ -126,21 +126,6 @@ IntSize PPMImageDecoderPlugin::size()
return { m_context->width, m_context->height };
}
-RefPtr<Gfx::Bitmap> PPMImageDecoderPlugin::bitmap()
-{
- if (m_context->state == PPMLoadingContext::State::Error)
- return nullptr;
-
- if (m_context->state < PPMLoadingContext::State::Decoded) {
- bool success = decode(*m_context);
- if (!success)
- return nullptr;
- }
-
- VERIFY(m_context->bitmap);
- return m_context->bitmap;
-}
-
void PPMImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
@@ -188,7 +173,18 @@ ImageFrameDescriptor PPMImageDecoderPlugin::frame(size_t i)
{
if (i > 0)
return {};
- return { bitmap(), 0 };
+
+ if (m_context->state == PPMLoadingContext::State::Error)
+ return {};
+
+ if (m_context->state < PPMLoadingContext::State::Decoded) {
+ bool success = decode(*m_context);
+ if (!success)
+ return {};
+ }
+
+ VERIFY(m_context->bitmap);
+ return { m_context->bitmap, 0 };
}
}
diff --git a/Userland/Libraries/LibGfx/PPMLoader.h b/Userland/Libraries/LibGfx/PPMLoader.h
index 7d5e01928a..0a9b876fba 100644
--- a/Userland/Libraries/LibGfx/PPMLoader.h
+++ b/Userland/Libraries/LibGfx/PPMLoader.h
@@ -18,7 +18,6 @@ public:
virtual ~PPMImageDecoderPlugin() override;
virtual IntSize size() override;
- virtual RefPtr<Gfx::Bitmap> bitmap() override;
virtual void set_volatile() override;
[[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;