From 47edd6ae894c7c303e0ea2cec00b8519ff962bc4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 12 Nov 2021 15:51:53 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibGfx/BMPLoader.cpp | 26 +------------------------ Userland/Libraries/LibGfx/BMPLoader.h | 4 ---- Userland/Libraries/LibGfx/DDSLoader.cpp | 21 +------------------- Userland/Libraries/LibGfx/DDSLoader.h | 4 ---- Userland/Libraries/LibGfx/ICOLoader.cpp | 9 --------- Userland/Libraries/LibGfx/ICOLoader.h | 4 ---- Userland/Libraries/LibGfx/JPGLoader.cpp | 24 ----------------------- Userland/Libraries/LibGfx/JPGLoader.h | 3 --- Userland/Libraries/LibGfx/PBMLoader.cpp | 5 ----- Userland/Libraries/LibGfx/PBMLoader.h | 3 --- Userland/Libraries/LibGfx/PGMLoader.cpp | 5 ----- Userland/Libraries/LibGfx/PGMLoader.h | 4 ---- Userland/Libraries/LibGfx/PNGLoader.cpp | 24 ----------------------- Userland/Libraries/LibGfx/PNGLoader.h | 3 --- Userland/Libraries/LibGfx/PPMLoader.cpp | 5 ----- Userland/Libraries/LibGfx/PPMLoader.h | 4 ---- 16 files changed, 2 insertions(+), 146 deletions(-) diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp index f244c3aff28..f8056a0596b 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.cpp +++ b/Userland/Libraries/LibGfx/BMPLoader.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -163,16 +164,6 @@ struct BMPLoadingContext { } }; -static RefPtr load_bmp_impl(const u8*, size_t); - -RefPtr 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 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(); diff --git a/Userland/Libraries/LibGfx/BMPLoader.h b/Userland/Libraries/LibGfx/BMPLoader.h index ff6d6f48328..926b69377ba 100644 --- a/Userland/Libraries/LibGfx/BMPLoader.h +++ b/Userland/Libraries/LibGfx/BMPLoader.h @@ -6,14 +6,10 @@ #pragma once -#include -#include #include namespace Gfx { -RefPtr load_bmp_from_memory(u8 const*, size_t, String const& mmap_name = ""); - struct BMPLoadingContext; class BMPImageDecoderPlugin final : public ImageDecoderPlugin { diff --git a/Userland/Libraries/LibGfx/DDSLoader.cpp b/Userland/Libraries/LibGfx/DDSLoader.cpp index bebd31fde93..6553f413677 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.cpp +++ b/Userland/Libraries/LibGfx/DDSLoader.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -936,26 +937,6 @@ void DDSLoadingContext::dump_debug() dbgln("{}", builder.to_string()); } -static RefPtr 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 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(); diff --git a/Userland/Libraries/LibGfx/DDSLoader.h b/Userland/Libraries/LibGfx/DDSLoader.h index 73116a5b43f..96e1ce21d7d 100644 --- a/Userland/Libraries/LibGfx/DDSLoader.h +++ b/Userland/Libraries/LibGfx/DDSLoader.h @@ -6,8 +6,6 @@ #pragma once -#include -#include #include namespace Gfx { @@ -233,8 +231,6 @@ struct DDSHeaderDXT10 { u32 misc_flag2 {}; }; -RefPtr load_dds_from_memory(u8 const*, size_t, String const& mmap_name = ""); - struct DDSLoadingContext; class DDSImageDecoderPlugin final : public ImageDecoderPlugin { diff --git a/Userland/Libraries/LibGfx/ICOLoader.cpp b/Userland/Libraries/LibGfx/ICOLoader.cpp index ef928323448..42ad214a224 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.cpp +++ b/Userland/Libraries/LibGfx/ICOLoader.cpp @@ -89,15 +89,6 @@ struct ICOLoadingContext { size_t largest_index; }; -RefPtr 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 decode_ico_header(InputMemoryStream& stream) { ICONDIR header; diff --git a/Userland/Libraries/LibGfx/ICOLoader.h b/Userland/Libraries/LibGfx/ICOLoader.h index 4487e869171..d30939cc5c6 100644 --- a/Userland/Libraries/LibGfx/ICOLoader.h +++ b/Userland/Libraries/LibGfx/ICOLoader.h @@ -6,14 +6,10 @@ #pragma once -#include -#include #include namespace Gfx { -RefPtr load_ico_from_memory(u8 const*, size_t, String const& mmap_name = ""); - struct ICOLoadingContext; class ICOImageDecoderPlugin final : public ImageDecoderPlugin { diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp index 914e8deaa8d..0c2559e279d 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.cpp +++ b/Userland/Libraries/LibGfx/JPGLoader.cpp @@ -4,15 +4,11 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include -#include #include #include #include #include -#include #include -#include #include #define JPG_INVALID 0X0000 @@ -1222,26 +1218,6 @@ static bool decode_jpg(JPGLoadingContext& context) return true; } -static RefPtr 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 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(); diff --git a/Userland/Libraries/LibGfx/JPGLoader.h b/Userland/Libraries/LibGfx/JPGLoader.h index 284ae076f09..3dc67827ec8 100644 --- a/Userland/Libraries/LibGfx/JPGLoader.h +++ b/Userland/Libraries/LibGfx/JPGLoader.h @@ -6,13 +6,10 @@ #pragma once -#include #include namespace Gfx { -RefPtr load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name = ""); - struct JPGLoadingContext; class JPGImageDecoderPlugin : public ImageDecoderPlugin { diff --git a/Userland/Libraries/LibGfx/PBMLoader.cpp b/Userland/Libraries/LibGfx/PBMLoader.cpp index 242719abf03..49115a47b28 100644 --- a/Userland/Libraries/LibGfx/PBMLoader.cpp +++ b/Userland/Libraries/LibGfx/PBMLoader.cpp @@ -94,11 +94,6 @@ static bool read_image_data(PBMLoadingContext& context, Streamer& streamer) return true; } -RefPtr load_pbm_from_memory(u8 const* data, size_t length, String const& mmap_name) -{ - return load_from_memory(data, length, mmap_name); -} - PBMImageDecoderPlugin::PBMImageDecoderPlugin(const u8* data, size_t size) { m_context = make(); diff --git a/Userland/Libraries/LibGfx/PBMLoader.h b/Userland/Libraries/LibGfx/PBMLoader.h index ea15e46b482..5f3a512d80b 100644 --- a/Userland/Libraries/LibGfx/PBMLoader.h +++ b/Userland/Libraries/LibGfx/PBMLoader.h @@ -6,13 +6,10 @@ #pragma once -#include #include namespace Gfx { -RefPtr load_pbm_from_memory(u8 const*, size_t, String const& mmap_name = ""); - struct PBMLoadingContext; class PBMImageDecoderPlugin final : public ImageDecoderPlugin { diff --git a/Userland/Libraries/LibGfx/PGMLoader.cpp b/Userland/Libraries/LibGfx/PGMLoader.cpp index 928892bbe70..59c2ee95a4b 100644 --- a/Userland/Libraries/LibGfx/PGMLoader.cpp +++ b/Userland/Libraries/LibGfx/PGMLoader.cpp @@ -97,11 +97,6 @@ static bool read_image_data(PGMLoadingContext& context, Streamer& streamer) return true; } -RefPtr load_pgm_from_memory(u8 const* data, size_t length, String const& mmap_name) -{ - return load_from_memory(data, length, mmap_name); -} - PGMImageDecoderPlugin::PGMImageDecoderPlugin(const u8* data, size_t size) { m_context = make(); diff --git a/Userland/Libraries/LibGfx/PGMLoader.h b/Userland/Libraries/LibGfx/PGMLoader.h index 019463fd161..5815224e54a 100644 --- a/Userland/Libraries/LibGfx/PGMLoader.h +++ b/Userland/Libraries/LibGfx/PGMLoader.h @@ -6,14 +6,10 @@ #pragma once -#include -#include #include namespace Gfx { -RefPtr load_pgm_from_memory(u8 const*, size_t, String const& mmap_name = ""); - struct PGMLoadingContext; class PGMImageDecoderPlugin final : public ImageDecoderPlugin { diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp index fee064fde52..a0625cec712 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.cpp +++ b/Userland/Libraries/LibGfx/PNGLoader.cpp @@ -165,17 +165,8 @@ private: size_t m_size_remaining { 0 }; }; -static RefPtr load_png_impl(const u8*, size_t); static bool process_chunk(Streamer&, PNGLoadingContext& context); -RefPtr 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 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; diff --git a/Userland/Libraries/LibGfx/PNGLoader.h b/Userland/Libraries/LibGfx/PNGLoader.h index 21c570c5124..c98ab9be254 100644 --- a/Userland/Libraries/LibGfx/PNGLoader.h +++ b/Userland/Libraries/LibGfx/PNGLoader.h @@ -6,13 +6,10 @@ #pragma once -#include #include namespace Gfx { -RefPtr load_png_from_memory(u8 const*, size_t, String const& mmap_name = ""); - struct PNGLoadingContext; class PNGImageDecoderPlugin final : public ImageDecoderPlugin { diff --git a/Userland/Libraries/LibGfx/PPMLoader.cpp b/Userland/Libraries/LibGfx/PPMLoader.cpp index d647160f828..8a98683fabf 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_from_memory(u8 const* data, size_t length, String const& mmap_name) -{ - return load_from_memory(data, length, mmap_name); -} - PPMImageDecoderPlugin::PPMImageDecoderPlugin(const u8* data, size_t size) { m_context = make(); diff --git a/Userland/Libraries/LibGfx/PPMLoader.h b/Userland/Libraries/LibGfx/PPMLoader.h index bcbe7e90b8b..7d5e01928a5 100644 --- a/Userland/Libraries/LibGfx/PPMLoader.h +++ b/Userland/Libraries/LibGfx/PPMLoader.h @@ -6,14 +6,10 @@ #pragma once -#include -#include #include namespace Gfx { -RefPtr load_ppm_from_memory(u8 const*, size_t, String const& mmap_name = ""); - struct PPMLoadingContext; class PPMImageDecoderPlugin final : public ImageDecoderPlugin {