소스 검색

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.
Andreas Kling 3 년 전
부모
커밋
10add3f4c2

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

@@ -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);

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

@@ -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;

+ 1 - 0
Userland/Libraries/LibGfx/Bitmap.cpp

@@ -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>

+ 0 - 10
Userland/Libraries/LibGfx/DDSLoader.cpp

@@ -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);

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

@@ -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;

+ 0 - 10
Userland/Libraries/LibGfx/GIFLoader.cpp

@@ -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);

+ 0 - 1
Userland/Libraries/LibGfx/GIFLoader.h

@@ -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;

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

@@ -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);

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

@@ -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;

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

@@ -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);

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

@@ -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;

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

@@ -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);

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

@@ -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;

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

@@ -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);

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

@@ -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;

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

@@ -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);

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

@@ -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;

+ 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(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);

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

@@ -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;

+ 0 - 11
Userland/Libraries/LibGfx/PortableImageLoaderCommon.h

@@ -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));
-}
-
 }