1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibGfx: Remove load_FORMAT() image codec wrappers

We had a bunch of old unused wrapper functions for each image codec that
would load a supported image with a given path. Nobody actually used
them, so let's just get rid of load_png(), load_gif(), etc.
This commit is contained in:
Andreas Kling 2021-11-11 11:32:22 +01:00
parent 09780ba7a9
commit 10add3f4c2
20 changed files with 2 additions and 105 deletions

View file

@ -6,8 +6,7 @@
#include <AK/Debug.h>
#include <AK/Function.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/Vector.h>
#include <LibGfx/BMPLoader.h>
namespace Gfx {
@ -166,14 +165,6 @@ struct BMPLoadingContext {
static RefPtr<Bitmap> load_bmp_impl(const u8*, size_t);
RefPtr<Gfx::Bitmap> load_bmp(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
return load_bmp_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
RefPtr<Gfx::Bitmap> load_bmp_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_bmp_impl(data, length);

View file

@ -12,7 +12,6 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_bmp(String const& path);
RefPtr<Gfx::Bitmap> load_bmp_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct BMPLoadingContext;

View file

@ -6,6 +6,7 @@
#include <AK/Checked.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/Memory.h>
#include <AK/MemoryStream.h>
#include <AK/Optional.h>

View file

@ -6,8 +6,6 @@
#include <AK/Debug.h>
#include <AK/Endian.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/MemoryStream.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
@ -950,14 +948,6 @@ static RefPtr<Gfx::Bitmap> load_dds_impl(const u8* data, size_t length)
return context.bitmap;
}
RefPtr<Gfx::Bitmap> load_dds(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
return load_dds_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
RefPtr<Gfx::Bitmap> load_dds_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_dds_impl(data, length);

View file

@ -233,7 +233,6 @@ struct DDSHeaderDXT10 {
u32 misc_flag2 {};
};
RefPtr<Gfx::Bitmap> load_dds(String const& path);
RefPtr<Gfx::Bitmap> load_dds_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct DDSLoadingContext;

View file

@ -6,8 +6,6 @@
#include <AK/Array.h>
#include <AK/Debug.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/Math.h>
#include <AK/Memory.h>
#include <AK/MemoryStream.h>
@ -82,14 +80,6 @@ struct GIFLoadingContext {
RefPtr<Gfx::Bitmap> prev_frame_buffer;
};
RefPtr<Gfx::Bitmap> load_gif(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
return load_gif_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
RefPtr<Gfx::Bitmap> load_gif_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
GIFImageDecoderPlugin gif_decoder(data, length);

View file

@ -12,7 +12,6 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_gif(String const& path);
RefPtr<Gfx::Bitmap> load_gif_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct GIFLoadingContext;

View file

@ -6,8 +6,6 @@
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/MemoryStream.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/Types.h>
@ -91,14 +89,6 @@ struct ICOLoadingContext {
size_t largest_index;
};
RefPtr<Gfx::Bitmap> load_ico(StringView path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
return load_ico_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
RefPtr<Gfx::Bitmap> load_ico_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
ICOImageDecoderPlugin decoder(data, length);

View file

@ -12,7 +12,6 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_ico(StringView path);
RefPtr<Gfx::Bitmap> load_ico_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct ICOLoadingContext;

View file

@ -8,7 +8,6 @@
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <AK/LexicalPath.h>
#include <AK/Math.h>
#include <AK/MemoryStream.h>
#include <AK/String.h>
@ -1235,14 +1234,6 @@ static RefPtr<Gfx::Bitmap> load_jpg_impl(const u8* data, size_t data_size)
return context.bitmap;
}
RefPtr<Gfx::Bitmap> load_jpg(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
return load_jpg_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), path);
}
RefPtr<Gfx::Bitmap> load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_jpg_impl(data, length);

View file

@ -6,16 +6,11 @@
#pragma once
#include <AK/MappedFile.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
#include <LibGfx/Size.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_jpg(String const& path);
RefPtr<Gfx::Bitmap> load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name = "<memory>");
struct JPGLoadingContext;

View file

@ -8,9 +8,6 @@
#include "PortableImageLoaderCommon.h"
#include "Streamer.h"
#include <AK/Endian.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/StringBuilder.h>
#include <string.h>
namespace Gfx {
@ -97,11 +94,6 @@ static bool read_image_data(PBMLoadingContext& context, Streamer& streamer)
return true;
}
RefPtr<Gfx::Bitmap> load_pbm(StringView path)
{
return load<PBMLoadingContext>(path);
}
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);

View file

@ -7,12 +7,10 @@
#pragma once
#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_pbm(StringView path);
RefPtr<Gfx::Bitmap> load_pbm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PBMLoadingContext;

View file

@ -8,8 +8,6 @@
#include "PortableImageLoaderCommon.h"
#include "Streamer.h"
#include <AK/Endian.h>
#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <string.h>
namespace Gfx {
@ -99,11 +97,6 @@ static bool read_image_data(PGMLoadingContext& context, Streamer& streamer)
return true;
}
RefPtr<Gfx::Bitmap> load_pgm(StringView path)
{
return load<PGMLoadingContext>(path);
}
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);

View file

@ -12,7 +12,6 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_pgm(StringView path);
RefPtr<Gfx::Bitmap> load_pgm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PGMLoadingContext;

View file

@ -6,8 +6,6 @@
#include <AK/Debug.h>
#include <AK/Endian.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <LibCompress/Zlib.h>
#include <LibGfx/PNGLoader.h>
#include <fcntl.h>
@ -169,14 +167,6 @@ private:
static RefPtr<Gfx::Bitmap> load_png_impl(const u8*, size_t);
static bool process_chunk(Streamer&, PNGLoadingContext& context);
RefPtr<Gfx::Bitmap> load_png(String const& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
return load_png_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
RefPtr<Gfx::Bitmap> load_png_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_png_impl(data, length);

View file

@ -7,12 +7,10 @@
#pragma once
#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_png(String const& path);
RefPtr<Gfx::Bitmap> load_png_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PNGLoadingContext;

View file

@ -101,11 +101,6 @@ static bool read_image_data(PPMLoadingContext& context, Streamer& streamer)
return true;
}
RefPtr<Gfx::Bitmap> load_ppm(StringView path)
{
return load<PPMLoadingContext>(path);
}
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);

View file

@ -12,7 +12,6 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_ppm(StringView path);
RefPtr<Gfx::Bitmap> load_ppm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PPMLoadingContext;

View file

@ -10,8 +10,6 @@
#include <AK/Array.h>
#include <AK/Debug.h>
#include <AK/Endian.h>
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
@ -272,13 +270,4 @@ static RefPtr<Gfx::Bitmap> load_from_memory(u8 const* data, size_t length, Strin
return bitmap;
}
template<typename TContext>
static RefPtr<Gfx::Bitmap> load(StringView path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
return load_from_memory<TContext>((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
}