Ver código fonte

LibGfx: Remove all load_FORMAT_from_memory() decoder wrappers

There are no more clients of these APIs, now that everyone has been made
to use ImageDecoderPlugin objects instead.
Andreas Kling 3 anos atrás
pai
commit
47edd6ae89

+ 1 - 25
Userland/Libraries/LibGfx/BMPLoader.cpp

@@ -6,6 +6,7 @@
 
 #include <AK/Debug.h>
 #include <AK/Function.h>
+#include <AK/String.h>
 #include <AK/Vector.h>
 #include <LibGfx/BMPLoader.h>
 
@@ -163,16 +164,6 @@ struct BMPLoadingContext {
     }
 };
 
-static RefPtr<Bitmap> load_bmp_impl(const u8*, size_t);
-
-RefPtr<Gfx::Bitmap> load_bmp_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    auto bitmap = load_bmp_impl(data, length);
-    if (bitmap)
-        bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded BMP: {}", bitmap->size(), mmap_name));
-    return bitmap;
-}
-
 class InputStreamer {
 public:
     InputStreamer(const u8* data, size_t size)
@@ -1308,21 +1299,6 @@ static bool decode_bmp_pixel_data(BMPLoadingContext& context)
     return true;
 }
 
-static RefPtr<Bitmap> load_bmp_impl(const u8* data, size_t data_size)
-{
-    BMPLoadingContext context;
-    context.file_bytes = data;
-    context.file_size = data_size;
-
-    // Forces a decode of the header, dib, and color table as well
-    if (!decode_bmp_pixel_data(context)) {
-        context.state = BMPLoadingContext::State::Error;
-        return nullptr;
-    }
-
-    return context.bitmap;
-}
-
 BMPImageDecoderPlugin::BMPImageDecoderPlugin(const u8* data, size_t data_size)
 {
     m_context = make<BMPLoadingContext>();

+ 0 - 4
Userland/Libraries/LibGfx/BMPLoader.h

@@ -6,14 +6,10 @@
 
 #pragma once
 
-#include <AK/String.h>
-#include <LibGfx/Bitmap.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
 
-RefPtr<Gfx::Bitmap> load_bmp_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
-
 struct BMPLoadingContext;
 
 class BMPImageDecoderPlugin final : public ImageDecoderPlugin {

+ 1 - 20
Userland/Libraries/LibGfx/DDSLoader.cpp

@@ -7,6 +7,7 @@
 #include <AK/Debug.h>
 #include <AK/Endian.h>
 #include <AK/MemoryStream.h>
+#include <AK/String.h>
 #include <AK/StringBuilder.h>
 #include <AK/Vector.h>
 #include <LibGfx/DDSLoader.h>
@@ -936,26 +937,6 @@ void DDSLoadingContext::dump_debug()
     dbgln("{}", builder.to_string());
 }
 
-static RefPtr<Gfx::Bitmap> load_dds_impl(const u8* data, size_t length)
-{
-    DDSLoadingContext context;
-    context.data = data;
-    context.data_size = length;
-
-    if (!decode_dds(context))
-        return nullptr;
-
-    return context.bitmap;
-}
-
-RefPtr<Gfx::Bitmap> load_dds_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    auto bitmap = load_dds_impl(data, length);
-    if (bitmap)
-        bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded DDS: {}", bitmap->size(), mmap_name));
-    return bitmap;
-}
-
 DDSImageDecoderPlugin::DDSImageDecoderPlugin(const u8* data, size_t size)
 {
     m_context = make<DDSLoadingContext>();

+ 0 - 4
Userland/Libraries/LibGfx/DDSLoader.h

@@ -6,8 +6,6 @@
 
 #pragma once
 
-#include <AK/String.h>
-#include <LibGfx/Bitmap.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
@@ -233,8 +231,6 @@ struct DDSHeaderDXT10 {
     u32 misc_flag2 {};
 };
 
-RefPtr<Gfx::Bitmap> load_dds_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
-
 struct DDSLoadingContext;
 
 class DDSImageDecoderPlugin final : public ImageDecoderPlugin {

+ 0 - 9
Userland/Libraries/LibGfx/ICOLoader.cpp

@@ -89,15 +89,6 @@ struct ICOLoadingContext {
     size_t largest_index;
 };
 
-RefPtr<Gfx::Bitmap> load_ico_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    ICOImageDecoderPlugin decoder(data, length);
-    auto bitmap = decoder.bitmap();
-    if (bitmap)
-        bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded ICO: {}", bitmap->size(), mmap_name));
-    return bitmap;
-}
-
 static Optional<size_t> decode_ico_header(InputMemoryStream& stream)
 {
     ICONDIR header;

+ 0 - 4
Userland/Libraries/LibGfx/ICOLoader.h

@@ -6,14 +6,10 @@
 
 #pragma once
 
-#include <AK/String.h>
-#include <LibGfx/Bitmap.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
 
-RefPtr<Gfx::Bitmap> load_ico_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
-
 struct ICOLoadingContext;
 
 class ICOImageDecoderPlugin final : public ImageDecoderPlugin {

+ 0 - 24
Userland/Libraries/LibGfx/JPGLoader.cpp

@@ -4,15 +4,11 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
-#include <AK/Bitmap.h>
-#include <AK/ByteBuffer.h>
 #include <AK/Debug.h>
 #include <AK/HashMap.h>
 #include <AK/Math.h>
 #include <AK/MemoryStream.h>
-#include <AK/String.h>
 #include <AK/Vector.h>
-#include <LibGfx/Bitmap.h>
 #include <LibGfx/JPGLoader.h>
 
 #define JPG_INVALID 0X0000
@@ -1222,26 +1218,6 @@ static bool decode_jpg(JPGLoadingContext& context)
     return true;
 }
 
-static RefPtr<Gfx::Bitmap> load_jpg_impl(const u8* data, size_t data_size)
-{
-    JPGLoadingContext context;
-    context.data = data;
-    context.data_size = data_size;
-
-    if (!decode_jpg(context))
-        return nullptr;
-
-    return context.bitmap;
-}
-
-RefPtr<Gfx::Bitmap> load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    auto bitmap = load_jpg_impl(data, length);
-    if (bitmap)
-        bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded jpg: {}", bitmap->size(), mmap_name));
-    return bitmap;
-}
-
 JPGImageDecoderPlugin::JPGImageDecoderPlugin(const u8* data, size_t size)
 {
     m_context = make<JPGLoadingContext>();

+ 0 - 3
Userland/Libraries/LibGfx/JPGLoader.h

@@ -6,13 +6,10 @@
 
 #pragma once
 
-#include <AK/String.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
 
-RefPtr<Gfx::Bitmap> load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name = "<memory>");
-
 struct JPGLoadingContext;
 
 class JPGImageDecoderPlugin : public ImageDecoderPlugin {

+ 0 - 5
Userland/Libraries/LibGfx/PBMLoader.cpp

@@ -94,11 +94,6 @@ static bool read_image_data(PBMLoadingContext& context, Streamer& streamer)
     return true;
 }
 
-RefPtr<Gfx::Bitmap> load_pbm_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    return load_from_memory<PBMLoadingContext>(data, length, mmap_name);
-}
-
 PBMImageDecoderPlugin::PBMImageDecoderPlugin(const u8* data, size_t size)
 {
     m_context = make<PBMLoadingContext>();

+ 0 - 3
Userland/Libraries/LibGfx/PBMLoader.h

@@ -6,13 +6,10 @@
 
 #pragma once
 
-#include <AK/String.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
 
-RefPtr<Gfx::Bitmap> load_pbm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
-
 struct PBMLoadingContext;
 
 class PBMImageDecoderPlugin final : public ImageDecoderPlugin {

+ 0 - 5
Userland/Libraries/LibGfx/PGMLoader.cpp

@@ -97,11 +97,6 @@ static bool read_image_data(PGMLoadingContext& context, Streamer& streamer)
     return true;
 }
 
-RefPtr<Gfx::Bitmap> load_pgm_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    return load_from_memory<PGMLoadingContext>(data, length, mmap_name);
-}
-
 PGMImageDecoderPlugin::PGMImageDecoderPlugin(const u8* data, size_t size)
 {
     m_context = make<PGMLoadingContext>();

+ 0 - 4
Userland/Libraries/LibGfx/PGMLoader.h

@@ -6,14 +6,10 @@
 
 #pragma once
 
-#include <AK/String.h>
-#include <LibGfx/Bitmap.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
 
-RefPtr<Gfx::Bitmap> load_pgm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
-
 struct PGMLoadingContext;
 
 class PGMImageDecoderPlugin final : public ImageDecoderPlugin {

+ 0 - 24
Userland/Libraries/LibGfx/PNGLoader.cpp

@@ -165,17 +165,8 @@ private:
     size_t m_size_remaining { 0 };
 };
 
-static RefPtr<Gfx::Bitmap> load_png_impl(const u8*, size_t);
 static bool process_chunk(Streamer&, PNGLoadingContext& context);
 
-RefPtr<Gfx::Bitmap> load_png_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    auto bitmap = load_png_impl(data, length);
-    if (bitmap)
-        bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded PNG: {}", bitmap->size(), mmap_name));
-    return bitmap;
-}
-
 ALWAYS_INLINE static u8 paeth_predictor(int a, int b, int c)
 {
     int p = a + b - c;
@@ -775,21 +766,6 @@ static bool decode_png_bitmap(PNGLoadingContext& context)
     return true;
 }
 
-static RefPtr<Gfx::Bitmap> load_png_impl(const u8* data, size_t data_size)
-{
-    PNGLoadingContext context;
-    context.data = data;
-    context.data_size = data_size;
-
-    if (!decode_png_chunks(context))
-        return nullptr;
-
-    if (!decode_png_bitmap(context))
-        return nullptr;
-
-    return context.bitmap;
-}
-
 static bool is_valid_compression_method(u8 compression_method)
 {
     return compression_method == 0;

+ 0 - 3
Userland/Libraries/LibGfx/PNGLoader.h

@@ -6,13 +6,10 @@
 
 #pragma once
 
-#include <AK/String.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
 
-RefPtr<Gfx::Bitmap> load_png_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
-
 struct PNGLoadingContext;
 
 class PNGImageDecoderPlugin final : public ImageDecoderPlugin {

+ 0 - 5
Userland/Libraries/LibGfx/PPMLoader.cpp

@@ -101,11 +101,6 @@ static bool read_image_data(PPMLoadingContext& context, Streamer& streamer)
     return true;
 }
 
-RefPtr<Gfx::Bitmap> load_ppm_from_memory(u8 const* data, size_t length, String const& mmap_name)
-{
-    return load_from_memory<PPMLoadingContext>(data, length, mmap_name);
-}
-
 PPMImageDecoderPlugin::PPMImageDecoderPlugin(const u8* data, size_t size)
 {
     m_context = make<PPMLoadingContext>();

+ 0 - 4
Userland/Libraries/LibGfx/PPMLoader.h

@@ -6,14 +6,10 @@
 
 #pragma once
 
-#include <AK/String.h>
-#include <LibGfx/Bitmap.h>
 #include <LibGfx/ImageDecoder.h>
 
 namespace Gfx {
 
-RefPtr<Gfx::Bitmap> load_ppm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
-
 struct PPMLoadingContext;
 
 class PPMImageDecoderPlugin final : public ImageDecoderPlugin {