From 4291288a316122f8701941e1de19d652d6160181 Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Mon, 17 Jul 2023 13:00:37 -0400 Subject: [PATCH] LibGfx: Remove `ImageDecoderPlugin::initialize()` No plugin is currently overriding the default implementation, which is a no-op. So we can safely delete it. --- Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp | 3 -- Meta/Lagom/Fuzzers/FuzzICOLoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzQOILoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzTGALoader.cpp | 4 +- Meta/Lagom/Fuzzers/FuzzWebPLoader.cpp | 4 +- Tests/LibGfx/TestICCProfile.cpp | 4 -- Tests/LibGfx/TestImageDecoder.cpp | 39 ------------------- .../Libraries/LibGUI/FileIconProvider.cpp | 6 +-- .../LibGfx/ImageFormats/ICOLoader.cpp | 1 - .../LibGfx/ImageFormats/ImageDecoder.cpp | 12 ++---- .../LibGfx/ImageFormats/ImageDecoder.h | 2 - Userland/Libraries/LibPDF/Filter.cpp | 1 - 18 files changed, 17 insertions(+), 91 deletions(-) diff --git a/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp b/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp index 94510de7b7..8b14b7dd76 100644 --- a/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzBMPLoader.cpp @@ -13,8 +13,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp b/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp index d8b44d79f7..c91d2a7d0b 100644 --- a/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp @@ -16,9 +16,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (decoder->initialize().is_error()) { - return 0; - } auto& gif_decoder = *decoder; auto bitmap_or_error = decoder->frame(0); if (!bitmap_or_error.is_error()) { diff --git a/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp b/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp index 70e0b98f42..e8cf50c51a 100644 --- a/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzICOLoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp b/Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp index 4785521518..2bca31aacc 100644 --- a/Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp index 87966e1014..c83e2ddd16 100644 --- a/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPBMLoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp index 6315893670..5e83fbbdf2 100644 --- a/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPGMLoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp index 83827668c3..256e250299 100644 --- a/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPNGLoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp b/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp index 8929e5098e..6a19338116 100644 --- a/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzPPMLoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzQOILoader.cpp b/Meta/Lagom/Fuzzers/FuzzQOILoader.cpp index 9bc7120642..6385a296ae 100644 --- a/Meta/Lagom/Fuzzers/FuzzQOILoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzQOILoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzTGALoader.cpp b/Meta/Lagom/Fuzzers/FuzzTGALoader.cpp index c3e5627c3f..23ee7773de 100644 --- a/Meta/Lagom/Fuzzers/FuzzTGALoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzTGALoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Meta/Lagom/Fuzzers/FuzzWebPLoader.cpp b/Meta/Lagom/Fuzzers/FuzzWebPLoader.cpp index 0c5682eace..452a64471a 100644 --- a/Meta/Lagom/Fuzzers/FuzzWebPLoader.cpp +++ b/Meta/Lagom/Fuzzers/FuzzWebPLoader.cpp @@ -14,8 +14,6 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) if (decoder_or_error.is_error()) return 0; auto decoder = decoder_or_error.release_value(); - if (!decoder->initialize().is_error()) { - (void)decoder->frame(0); - } + (void)decoder->frame(0); return 0; } diff --git a/Tests/LibGfx/TestICCProfile.cpp b/Tests/LibGfx/TestICCProfile.cpp index 4fed9b2b35..3dbf6cd108 100644 --- a/Tests/LibGfx/TestICCProfile.cpp +++ b/Tests/LibGfx/TestICCProfile.cpp @@ -25,7 +25,6 @@ TEST_CASE(png) { auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc/icc-v2.png"sv))); auto png = MUST(Gfx::PNGImageDecoderPlugin::create(file->bytes())); - MUST(png->initialize()); auto icc_bytes = MUST(png->icc_data()); EXPECT(icc_bytes.has_value()); @@ -37,7 +36,6 @@ TEST_CASE(jpg) { auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc/icc-v4.jpg"sv))); auto jpg = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(jpg->initialize()); auto icc_bytes = MUST(jpg->icc_data()); EXPECT(icc_bytes.has_value()); @@ -60,7 +58,6 @@ TEST_CASE(webp_extended_lossless) { auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc/extended-lossless.webp"sv))); auto webp = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(webp->initialize()); auto icc_bytes = MUST(webp->icc_data()); EXPECT(icc_bytes.has_value()); @@ -72,7 +69,6 @@ TEST_CASE(webp_extended_lossy) { auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc/extended-lossy.webp"sv))); auto webp = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(webp->initialize()); auto icc_bytes = MUST(webp->icc_data()); EXPECT(icc_bytes.has_value()); diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 17698568e8..aef92fed24 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -53,7 +53,6 @@ TEST_CASE(test_bmp) auto file = MUST(Core::MappedFile::map(TEST_INPUT("rgba32-1.bmp"sv))); EXPECT(Gfx::BMPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::BMPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -63,7 +62,6 @@ TEST_CASE(test_gif) auto file = MUST(Core::MappedFile::map(TEST_INPUT("download-animation.gif"sv))); EXPECT(Gfx::GIFImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::GIFImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); EXPECT(plugin_decoder->frame_count()); EXPECT(plugin_decoder->is_animated()); @@ -85,7 +83,6 @@ TEST_CASE(test_bmp_embedded_in_ico) auto file = MUST(Core::MappedFile::map(TEST_INPUT("serenity.ico"sv))); EXPECT(Gfx::ICOImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::ICOImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -95,7 +92,6 @@ TEST_CASE(test_jpeg_sof0_one_scan) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/rgb24.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -105,7 +101,6 @@ TEST_CASE(test_jpeg_sof0_several_scans) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/several_scans.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 592, 800 }); } @@ -115,7 +110,6 @@ TEST_CASE(test_jpeg_rgb_components) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/rgb_components.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 592, 800 }); } @@ -125,7 +119,6 @@ TEST_CASE(test_jpeg_sof2_spectral_selection) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/spectral_selection.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 592, 800 }); } @@ -135,7 +128,6 @@ TEST_CASE(test_jpeg_sof0_several_scans_odd_number_mcu) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/several_scans_odd_number_mcu.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 600, 600 }); } @@ -145,7 +137,6 @@ TEST_CASE(test_jpeg_sof2_successive_aproximation) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/successive_approximation.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 600, 800 }); } @@ -155,7 +146,6 @@ TEST_CASE(test_jpeg_sof1_12bits) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/12-bit.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 320, 240 }); } @@ -165,7 +155,6 @@ TEST_CASE(test_jpeg_sof2_12bits) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/12-bit-progressive.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 320, 240 }); } @@ -175,7 +164,6 @@ TEST_CASE(test_jpeg_empty_icc) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/gradient_empty_icc.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 80, 80 }); } @@ -185,7 +173,6 @@ TEST_CASE(test_jpeg_grayscale_with_app14) auto file = MUST(Core::MappedFile::map(TEST_INPUT("jpg/grayscale_app14.jpg"sv))); EXPECT(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 80, 80 }); } @@ -195,7 +182,6 @@ TEST_CASE(test_pbm) auto file = MUST(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.pbm"sv))); EXPECT(Gfx::PBMImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::PBMImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -205,7 +191,6 @@ TEST_CASE(test_pgm) auto file = MUST(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.pgm"sv))); EXPECT(Gfx::PGMImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::PGMImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -215,7 +200,6 @@ TEST_CASE(test_png) auto file = MUST(Core::MappedFile::map(TEST_INPUT("buggie.png"sv))); EXPECT(Gfx::PNGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::PNGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -225,7 +209,6 @@ TEST_CASE(test_ppm) auto file = MUST(Core::MappedFile::map(TEST_INPUT("pnm/buggie-raw.ppm"sv))); EXPECT(Gfx::PPMImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::PPMImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -235,7 +218,6 @@ TEST_CASE(test_targa_bottom_left) auto file = MUST(Core::MappedFile::map(TEST_INPUT("tga/buggie-bottom-left-uncompressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -245,7 +227,6 @@ TEST_CASE(test_targa_top_left) auto file = MUST(Core::MappedFile::map(TEST_INPUT("tga/buggie-top-left-uncompressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -255,7 +236,6 @@ TEST_CASE(test_targa_bottom_left_compressed) auto file = MUST(Core::MappedFile::map(TEST_INPUT("tga/buggie-bottom-left-compressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -265,7 +245,6 @@ TEST_CASE(test_targa_top_left_compressed) auto file = MUST(Core::MappedFile::map(TEST_INPUT("tga/buggie-top-left-compressed.tga"sv))); EXPECT(MUST(Gfx::TGAImageDecoderPlugin::validate_before_create(file->bytes()))); auto plugin_decoder = MUST(Gfx::TGAImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame(*plugin_decoder); } @@ -275,7 +254,6 @@ TEST_CASE(test_webp_simple_lossy) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/simple-vp8.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 240, 240 }); @@ -290,7 +268,6 @@ TEST_CASE(test_webp_simple_lossless) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/simple-vp8l.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); // Ironically, simple-vp8l.webp is a much more complex file than extended-lossless.webp tested below. // extended-lossless.webp tests the decoding basics. @@ -312,7 +289,6 @@ TEST_CASE(test_webp_simple_lossless_alpha_used_false) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/simple-vp8l-alpha-used-false.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 386, 395 }); EXPECT_EQ(frame.image->get_pixel(0, 0), Gfx::Color(0, 0, 0, 0xff)); @@ -324,7 +300,6 @@ TEST_CASE(test_webp_extended_lossy) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/extended-lossy.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 417, 223 }); @@ -352,7 +327,6 @@ TEST_CASE(test_webp_extended_lossy_alpha_horizontal_filter) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/smolkling-horizontal-alpha.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 264, 264 }); @@ -369,7 +343,6 @@ TEST_CASE(test_webp_extended_lossy_alpha_vertical_filter) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/smolkling-vertical-alpha.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 264, 264 }); @@ -386,7 +359,6 @@ TEST_CASE(test_webp_extended_lossy_alpha_gradient_filter) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/smolkling-gradient-alpha.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 264, 264 }); @@ -402,7 +374,6 @@ TEST_CASE(test_webp_extended_lossy_uncompressed_alpha) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/extended-lossy-uncompressed-alpha.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 417, 223 }); @@ -420,7 +391,6 @@ TEST_CASE(test_webp_extended_lossy_negative_quantization_offset) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/smolkling.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 264, 264 }); @@ -438,7 +408,6 @@ TEST_CASE(test_webp_lossy_4) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/4.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 1024, 772 }); @@ -452,7 +421,6 @@ TEST_CASE(test_webp_lossy_4_with_partitions) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/4-with-8-partitions.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 1024, 772 }); EXPECT_EQ(frame.image->get_pixel(780, 570), Gfx::Color(0x73, 0xc9, 0xf9, 255)); @@ -463,7 +431,6 @@ TEST_CASE(test_webp_extended_lossless) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/extended-lossless.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 417, 223 }); @@ -487,7 +454,6 @@ TEST_CASE(test_webp_simple_lossless_color_index_transform) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/Qpalette.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 256, 256 }); @@ -520,7 +486,6 @@ TEST_CASE(test_webp_simple_lossless_color_index_transform_pixel_bundling) auto file = MUST(Core::MappedFile::map(MUST(String::formatted("{}{}", TEST_INPUT(""), test_case.file_name)))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); auto frame = expect_single_frame_of_size(*plugin_decoder, { 32, 32 }); @@ -544,7 +509,6 @@ TEST_CASE(test_webp_simple_lossless_color_index_transform_pixel_bundling_odd_wid for (auto file_name : file_names) { auto file = MUST(Core::MappedFile::map(MUST(String::formatted("{}{}", TEST_INPUT(""), file_name)))); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 11, 11 }); } } @@ -554,7 +518,6 @@ TEST_CASE(test_webp_extended_lossless_animated) auto file = MUST(Core::MappedFile::map(TEST_INPUT("webp/extended-lossless-animated.webp"sv))); EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); EXPECT_EQ(plugin_decoder->frame_count(), 8u); EXPECT(plugin_decoder->is_animated()); @@ -579,7 +542,6 @@ TEST_CASE(test_tvg) auto file = MUST(Core::MappedFile::map(TEST_INPUT("tvg/yak.tvg"sv))); EXPECT(Gfx::TinyVGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::TinyVGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 1024, 1024 }); } @@ -595,7 +557,6 @@ TEST_CASE(test_everything_tvg) auto file = MUST(Core::MappedFile::map(file_name)); EXPECT(Gfx::TinyVGImageDecoderPlugin::sniff(file->bytes())); auto plugin_decoder = MUST(Gfx::TinyVGImageDecoderPlugin::create(file->bytes())); - MUST(plugin_decoder->initialize()); expect_single_frame_of_size(*plugin_decoder, { 400, 768 }); } diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp index 5891530bea..b4bbadcf6a 100644 --- a/Userland/Libraries/LibGUI/FileIconProvider.cpp +++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp @@ -212,9 +212,9 @@ Icon FileIconProvider::icon_for_executable(DeprecatedString const& path) } else { // FIXME: Use the ImageDecoder service. if (Gfx::PNGImageDecoderPlugin::sniff({ section->raw_data(), section->size() })) { - auto png_decoder = Gfx::PNGImageDecoderPlugin::create({ section->raw_data(), section->size() }).release_value_but_fixme_should_propagate_errors(); - if (!png_decoder->initialize().is_error()) { - auto frame_or_error = png_decoder->frame(0); + auto png_decoder = Gfx::PNGImageDecoderPlugin::create({ section->raw_data(), section->size() }); + if (!png_decoder.is_error()) { + auto frame_or_error = png_decoder.value()->frame(0); if (!frame_or_error.is_error()) { bitmap = frame_or_error.value().image; } diff --git a/Userland/Libraries/LibGfx/ImageFormats/ICOLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/ICOLoader.cpp index 832b7ce0e8..0e137f3c4b 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ICOLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ICOLoader.cpp @@ -149,7 +149,6 @@ ErrorOr ICOImageDecoderPlugin::load_ico_bitmap(ICOLoadingContext& context, ICOImageDescriptor& desc = context.images[real_index]; if (PNGImageDecoderPlugin::sniff({ context.data + desc.offset, desc.size })) { auto png_decoder = TRY(PNGImageDecoderPlugin::create({ context.data + desc.offset, desc.size })); - TRY(png_decoder->initialize()); auto decoded_png_frame = TRY(png_decoder->frame(0)); if (!decoded_png_frame.image) { dbgln_if(ICO_DEBUG, "load_ico_bitmap: failed to load PNG encoded image index: {}", real_index); diff --git a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp index d85c79e1f2..b117f22ce4 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.cpp @@ -49,10 +49,8 @@ static OwnPtr probe_and_sniff_for_appropriate_plugin(Readonl if (!sniff_result) continue; auto plugin_decoder = plugin.create(bytes); - if (!plugin_decoder.is_error()) { - if (!plugin_decoder.value()->initialize().is_error()) - return plugin_decoder.release_value(); - } + if (!plugin_decoder.is_error()) + return plugin_decoder.release_value(); } return {}; } @@ -76,10 +74,8 @@ static OwnPtr probe_and_sniff_for_appropriate_plugin_with_kn if (!validation_result) continue; auto plugin_decoder = plugin.create(bytes); - if (!plugin_decoder.is_error()) { - if (!plugin_decoder.value()->initialize().is_error()) - return plugin_decoder.release_value(); - } + if (!plugin_decoder.is_error()) + return plugin_decoder.release_value(); } return {}; } diff --git a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h index daefbbb00b..d16af1529d 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h +++ b/Userland/Libraries/LibGfx/ImageFormats/ImageDecoder.h @@ -37,8 +37,6 @@ public: virtual IntSize size() = 0; - virtual ErrorOr initialize() { return {}; } - virtual bool is_animated() = 0; virtual size_t loop_count() = 0; diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp index fc1a782351..31574d3377 100644 --- a/Userland/Libraries/LibPDF/Filter.cpp +++ b/Userland/Libraries/LibPDF/Filter.cpp @@ -272,7 +272,6 @@ PDFErrorOr Filter::decode_dct(ReadonlyBytes bytes) { if (Gfx::JPEGImageDecoderPlugin::sniff({ bytes.data(), bytes.size() })) { auto decoder = Gfx::JPEGImageDecoderPlugin::create({ bytes.data(), bytes.size() }).release_value_but_fixme_should_propagate_errors(); - TRY(decoder->initialize()); auto frame = TRY(decoder->frame(0)); return TRY(frame.image->serialize_to_byte_buffer()); }