From 10add3f4c2cddc0d603b62ec79bfc54b47a3f53b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 11 Nov 2021 11:32:22 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibGfx/BMPLoader.cpp | 11 +---------- Userland/Libraries/LibGfx/BMPLoader.h | 1 - Userland/Libraries/LibGfx/Bitmap.cpp | 1 + Userland/Libraries/LibGfx/DDSLoader.cpp | 10 ---------- Userland/Libraries/LibGfx/DDSLoader.h | 1 - Userland/Libraries/LibGfx/GIFLoader.cpp | 10 ---------- Userland/Libraries/LibGfx/GIFLoader.h | 1 - Userland/Libraries/LibGfx/ICOLoader.cpp | 10 ---------- Userland/Libraries/LibGfx/ICOLoader.h | 1 - Userland/Libraries/LibGfx/JPGLoader.cpp | 9 --------- Userland/Libraries/LibGfx/JPGLoader.h | 5 ----- Userland/Libraries/LibGfx/PBMLoader.cpp | 8 -------- Userland/Libraries/LibGfx/PBMLoader.h | 2 -- Userland/Libraries/LibGfx/PGMLoader.cpp | 7 ------- Userland/Libraries/LibGfx/PGMLoader.h | 1 - Userland/Libraries/LibGfx/PNGLoader.cpp | 10 ---------- Userland/Libraries/LibGfx/PNGLoader.h | 2 -- Userland/Libraries/LibGfx/PPMLoader.cpp | 5 ----- Userland/Libraries/LibGfx/PPMLoader.h | 1 - Userland/Libraries/LibGfx/PortableImageLoaderCommon.h | 11 ----------- 20 files changed, 2 insertions(+), 105 deletions(-) diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp index 92e23261859..f244c3aff28 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.cpp +++ b/Userland/Libraries/LibGfx/BMPLoader.cpp @@ -6,8 +6,7 @@ #include #include -#include -#include +#include #include namespace Gfx { @@ -166,14 +165,6 @@ struct BMPLoadingContext { static RefPtr load_bmp_impl(const u8*, size_t); -RefPtr 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 load_bmp_from_memory(u8 const* data, size_t length, String const& mmap_name) { auto bitmap = load_bmp_impl(data, length); diff --git a/Userland/Libraries/LibGfx/BMPLoader.h b/Userland/Libraries/LibGfx/BMPLoader.h index 1503bc36806..ff6d6f48328 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.h +++ b/Userland/Libraries/LibGfx/BMPLoader.h @@ -12,7 +12,6 @@ namespace Gfx { -RefPtr load_bmp(String const& path); RefPtr load_bmp_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct BMPLoadingContext; diff --git a/Userland/Libraries/LibGfx/Bitmap.cpp b/Userland/Libraries/LibGfx/Bitmap.cpp index b0621577f00..f8db7fa4b1f 100644 --- a/Userland/Libraries/LibGfx/Bitmap.cpp +++ b/Userland/Libraries/LibGfx/Bitmap.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/Userland/Libraries/LibGfx/DDSLoader.cpp b/Userland/Libraries/LibGfx/DDSLoader.cpp index d94165fd4ae..bebd31fde93 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.cpp +++ b/Userland/Libraries/LibGfx/DDSLoader.cpp @@ -6,8 +6,6 @@ #include #include -#include -#include #include #include #include @@ -950,14 +948,6 @@ static RefPtr load_dds_impl(const u8* data, size_t length) return context.bitmap; } -RefPtr 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 load_dds_from_memory(u8 const* data, size_t length, String const& mmap_name) { auto bitmap = load_dds_impl(data, length); diff --git a/Userland/Libraries/LibGfx/DDSLoader.h b/Userland/Libraries/LibGfx/DDSLoader.h index 852f4104734..73116a5b43f 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.h +++ b/Userland/Libraries/LibGfx/DDSLoader.h @@ -233,7 +233,6 @@ struct DDSHeaderDXT10 { u32 misc_flag2 {}; }; -RefPtr load_dds(String const& path); RefPtr load_dds_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct DDSLoadingContext; diff --git a/Userland/Libraries/LibGfx/GIFLoader.cpp b/Userland/Libraries/LibGfx/GIFLoader.cpp index cfb6d68c989..497421a7212 100644 --- a/Userland/Libraries/LibGfx/GIFLoader.cpp +++ b/Userland/Libraries/LibGfx/GIFLoader.cpp @@ -6,8 +6,6 @@ #include #include -#include -#include #include #include #include @@ -82,14 +80,6 @@ struct GIFLoadingContext { RefPtr prev_frame_buffer; }; -RefPtr 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 load_gif_from_memory(u8 const* data, size_t length, String const& mmap_name) { GIFImageDecoderPlugin gif_decoder(data, length); diff --git a/Userland/Libraries/LibGfx/GIFLoader.h b/Userland/Libraries/LibGfx/GIFLoader.h index 07eb4d6286d..1487cd0302e 100644 --- a/Userland/Libraries/LibGfx/GIFLoader.h +++ b/Userland/Libraries/LibGfx/GIFLoader.h @@ -12,7 +12,6 @@ namespace Gfx { -RefPtr load_gif(String const& path); RefPtr load_gif_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct GIFLoadingContext; diff --git a/Userland/Libraries/LibGfx/ICOLoader.cpp b/Userland/Libraries/LibGfx/ICOLoader.cpp index dd4890c01c9..ef928323448 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.cpp +++ b/Userland/Libraries/LibGfx/ICOLoader.cpp @@ -6,8 +6,6 @@ #include #include -#include -#include #include #include #include @@ -91,14 +89,6 @@ struct ICOLoadingContext { size_t largest_index; }; -RefPtr 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 load_ico_from_memory(u8 const* data, size_t length, String const& mmap_name) { ICOImageDecoderPlugin decoder(data, length); diff --git a/Userland/Libraries/LibGfx/ICOLoader.h b/Userland/Libraries/LibGfx/ICOLoader.h index eb2b948c70e..4487e869171 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.h +++ b/Userland/Libraries/LibGfx/ICOLoader.h @@ -12,7 +12,6 @@ namespace Gfx { -RefPtr load_ico(StringView path); RefPtr load_ico_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct ICOLoadingContext; diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp index c064908b1d9..914e8deaa8d 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPGLoader.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -1235,14 +1234,6 @@ static RefPtr load_jpg_impl(const u8* data, size_t data_size) return context.bitmap; } -RefPtr 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 load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name) { auto bitmap = load_jpg_impl(data, length); diff --git a/Userland/Libraries/LibGfx/JPGLoader.h b/Userland/Libraries/LibGfx/JPGLoader.h index 04741fa978c..284ae076f09 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.h +++ b/Userland/Libraries/LibGfx/JPGLoader.h @@ -6,16 +6,11 @@ #pragma once -#include #include -#include -#include #include -#include namespace Gfx { -RefPtr load_jpg(String const& path); RefPtr load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name = ""); struct JPGLoadingContext; diff --git a/Userland/Libraries/LibGfx/PBMLoader.cpp b/Userland/Libraries/LibGfx/PBMLoader.cpp index 8373a076e98..242719abf03 100644 --- a/Userland/Libraries/LibGfx/PBMLoader.cpp +++ b/Userland/Libraries/LibGfx/PBMLoader.cpp @@ -8,9 +8,6 @@ #include "PortableImageLoaderCommon.h" #include "Streamer.h" #include -#include -#include -#include #include namespace Gfx { @@ -97,11 +94,6 @@ static bool read_image_data(PBMLoadingContext& context, Streamer& streamer) return true; } -RefPtr load_pbm(StringView path) -{ - return load(path); -} - RefPtr load_pbm_from_memory(u8 const* data, size_t length, String const& mmap_name) { return load_from_memory(data, length, mmap_name); diff --git a/Userland/Libraries/LibGfx/PBMLoader.h b/Userland/Libraries/LibGfx/PBMLoader.h index 7520823b4d2..ea15e46b482 100644 --- a/Userland/Libraries/LibGfx/PBMLoader.h +++ b/Userland/Libraries/LibGfx/PBMLoader.h @@ -7,12 +7,10 @@ #pragma once #include -#include #include namespace Gfx { -RefPtr load_pbm(StringView path); RefPtr load_pbm_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct PBMLoadingContext; diff --git a/Userland/Libraries/LibGfx/PGMLoader.cpp b/Userland/Libraries/LibGfx/PGMLoader.cpp index eb04c311393..928892bbe70 100644 --- a/Userland/Libraries/LibGfx/PGMLoader.cpp +++ b/Userland/Libraries/LibGfx/PGMLoader.cpp @@ -8,8 +8,6 @@ #include "PortableImageLoaderCommon.h" #include "Streamer.h" #include -#include -#include #include namespace Gfx { @@ -99,11 +97,6 @@ static bool read_image_data(PGMLoadingContext& context, Streamer& streamer) return true; } -RefPtr load_pgm(StringView path) -{ - return load(path); -} - RefPtr load_pgm_from_memory(u8 const* data, size_t length, String const& mmap_name) { return load_from_memory(data, length, mmap_name); diff --git a/Userland/Libraries/LibGfx/PGMLoader.h b/Userland/Libraries/LibGfx/PGMLoader.h index a64259a66a2..019463fd161 100644 --- a/Userland/Libraries/LibGfx/PGMLoader.h +++ b/Userland/Libraries/LibGfx/PGMLoader.h @@ -12,7 +12,6 @@ namespace Gfx { -RefPtr load_pgm(StringView path); RefPtr load_pgm_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct PGMLoadingContext; diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index d92cbaf0a32..990356de780 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -6,8 +6,6 @@ #include #include -#include -#include #include #include #include @@ -169,14 +167,6 @@ private: static RefPtr load_png_impl(const u8*, size_t); static bool process_chunk(Streamer&, PNGLoadingContext& context); -RefPtr 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 load_png_from_memory(u8 const* data, size_t length, String const& mmap_name) { auto bitmap = load_png_impl(data, length); diff --git a/Userland/Libraries/LibGfx/PNGLoader.h b/Userland/Libraries/LibGfx/PNGLoader.h index 56b0860c3b9..21c570c5124 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.h +++ b/Userland/Libraries/LibGfx/PNGLoader.h @@ -7,12 +7,10 @@ #pragma once #include -#include #include namespace Gfx { -RefPtr load_png(String const& path); RefPtr load_png_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct PNGLoadingContext; diff --git a/Userland/Libraries/LibGfx/PPMLoader.cpp b/Userland/Libraries/LibGfx/PPMLoader.cpp index dc4c0fbdce6..d647160f828 100644 --- a/Userland/Libraries/LibGfx/PPMLoader.cpp +++ b/Userland/Libraries/LibGfx/PPMLoader.cpp @@ -101,11 +101,6 @@ static bool read_image_data(PPMLoadingContext& context, Streamer& streamer) return true; } -RefPtr load_ppm(StringView path) -{ - return load(path); -} - RefPtr load_ppm_from_memory(u8 const* data, size_t length, String const& mmap_name) { return load_from_memory(data, length, mmap_name); diff --git a/Userland/Libraries/LibGfx/PPMLoader.h b/Userland/Libraries/LibGfx/PPMLoader.h index 82824a7d8f7..bcbe7e90b8b 100644 --- a/Userland/Libraries/LibGfx/PPMLoader.h +++ b/Userland/Libraries/LibGfx/PPMLoader.h @@ -12,7 +12,6 @@ namespace Gfx { -RefPtr load_ppm(StringView path); RefPtr load_ppm_from_memory(u8 const*, size_t, String const& mmap_name = ""); struct PPMLoadingContext; diff --git a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h index fd901be4ac0..7c9cfc75f3e 100644 --- a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h +++ b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h @@ -10,8 +10,6 @@ #include #include #include -#include -#include #include #include #include @@ -272,13 +270,4 @@ static RefPtr load_from_memory(u8 const* data, size_t length, Strin return bitmap; } -template -static RefPtr load(StringView path) -{ - auto file_or_error = MappedFile::map(path); - if (file_or_error.is_error()) - return nullptr; - return load_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path)); -} - }