From c4dcd172141cbe4a3a8a0821b8cccdbdb106362f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Wed, 27 Aug 2025 02:51:14 +0200 Subject: [PATCH] Update image to 0.25 (#38950) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Testing: These changes should be covered by existing web platform tests and `image`'s own test suite. --------- Signed-off-by: Simon Wülker --- Cargo.lock | 370 ++++++++++++++---- Cargo.toml | 2 +- components/pixels/lib.rs | 13 +- components/pixels/snapshot.rs | 41 +- deny.toml | 8 + .../animated-webp-update.tentative.html.ini | 2 - 6 files changed, 353 insertions(+), 83 deletions(-) delete mode 100644 tests/wpt/meta/html/semantics/embedded-content/the-img-element/animated-webp-update.tentative.html.ini diff --git a/Cargo.lock b/Cargo.lock index 5e40c36c2b6..0ce2361bb07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -198,6 +198,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned-vec" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" +dependencies = [ + "equator", +] + [[package]] name = "alloc-no-stdlib" version = "2.0.4" @@ -354,21 +363,28 @@ dependencies = [ ] [[package]] -name = "arboard" -version = "3.3.2" +name = "arbitrary" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2041f1943049c7978768d84e6d0fd95de98b76d6c4727b09e78ec253d29fa58" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" + +[[package]] +name = "arboard" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0348a1c054491f4bfe6ab86a7b6ab1e44e45d899005de92f58b3df180b36ddaf" dependencies = [ "clipboard-win", - "core-graphics", "image", "log", - "objc", - "objc-foundation", - "objc_id", + "objc2 0.6.1", + "objc2-app-kit 0.3.1", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.1", "parking_lot", - "thiserror 1.0.69", - "windows-sys 0.48.0", + "percent-encoding", + "windows-sys 0.52.0", "x11rb", ] @@ -378,6 +394,17 @@ version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "arkui-sys" version = "0.3.2" @@ -654,6 +681,29 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "av1-grain" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3efb2ca85bc610acfa917b5aaa36f3fcbebed5b3182d7f877b02531c4b80c8" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom 7.1.3", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c8fbc0f831f4519fe8b810b6a7a91410ec83031b8233f730a0480029f6a23f" +dependencies = [ + "arrayvec", +] + [[package]] name = "aws-lc-rs" version = "1.13.3" @@ -834,6 +884,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bitstream-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" + [[package]] name = "block" version = "0.1.6" @@ -975,6 +1031,12 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "built" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" + [[package]] name = "bumpalo" version = "3.19.0" @@ -1206,6 +1268,16 @@ dependencies = [ "nom 7.1.3", ] +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon 0.12.16", +] + [[package]] name = "cfg-expr" version = "0.20.2" @@ -1213,7 +1285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8d458d63f0f0f482c8da9b7c8b76c21bd885a02056cc94c6404d861ca2b8206" dependencies = [ "smallvec", - "target-lexicon", + "target-lexicon 0.13.2", ] [[package]] @@ -2416,6 +2488,26 @@ version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f6cf8ce0fb817000aa24f5e630bda904a353536bd430b83ebc1dceee95b4a3a" +[[package]] +name = "equator" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" +dependencies = [ + "equator-macro", +] + +[[package]] +name = "equator-macro" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -2439,7 +2531,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -3093,8 +3185,8 @@ dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", - "windows-sys 0.59.0", + "system-deps 7.0.5", + "windows-sys 0.52.0", ] [[package]] @@ -3158,7 +3250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ab79e1ed126803a8fb827e3de0e2ff95191912b8db65cee467edb56fc4cc215" dependencies = [ "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3205,7 +3297,7 @@ checksum = "ec9aca94bb73989e3cfdbf8f2e0f1f6da04db4d291c431f444838925c4c63eda" dependencies = [ "glib-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3315,7 +3407,7 @@ dependencies = [ "gstreamer-base-sys", "gstreamer-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3345,7 +3437,7 @@ dependencies = [ "gstreamer-base-sys", "gstreamer-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3372,7 +3464,7 @@ dependencies = [ "gobject-sys", "gstreamer-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3412,7 +3504,7 @@ dependencies = [ "glib-sys", "gstreamer-gl-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3427,7 +3519,7 @@ dependencies = [ "gstreamer-sys", "gstreamer-video-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3452,7 +3544,7 @@ dependencies = [ "glib-sys", "gstreamer-gl-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3479,7 +3571,7 @@ dependencies = [ "gstreamer-sys", "gstreamer-video-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3502,7 +3594,7 @@ dependencies = [ "glib-sys", "gstreamer-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3514,7 +3606,7 @@ dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3545,7 +3637,7 @@ dependencies = [ "gstreamer-base-sys", "gstreamer-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -3571,7 +3663,7 @@ dependencies = [ "gstreamer-sdp-sys", "gstreamer-sys", "libc", - "system-deps", + "system-deps 7.0.5", ] [[package]] @@ -4441,20 +4533,25 @@ dependencies = [ [[package]] name = "image" -version = "0.24.9" +version = "0.25.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a" dependencies = [ "bytemuck", - "byteorder", + "byteorder-lite", "color_quant", "exr", "gif", - "jpeg-decoder", + "image-webp", "num-traits", "png", "qoi", + "ravif", + "rayon", + "rgb", "tiff", + "zune-core", + "zune-jpeg", ] [[package]] @@ -4473,6 +4570,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285" +[[package]] +name = "imgref" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408" + [[package]] name = "imsz" version = "0.2.2" @@ -4530,6 +4633,17 @@ dependencies = [ "generic-array", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "io-kit-sys" version = "0.4.1" @@ -4577,7 +4691,7 @@ checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -4595,6 +4709,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -4671,9 +4794,6 @@ name = "jpeg-decoder" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00810f1d8b74be64b13dbf3db89ac67740615d6c891f0e7b6179326533011a07" -dependencies = [ - "rayon", -] [[package]] name = "js-sys" @@ -4859,6 +4979,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libfuzzer-sys" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5037190e1f70cbeef565bd267599242926f724d3b8a9f510fd7e0b540cfa4404" +dependencies = [ + "arbitrary", + "cc", +] + [[package]] name = "libloading" version = "0.8.8" @@ -4866,7 +4996,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -5027,6 +5157,15 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + [[package]] name = "lyon_geom" version = "1.0.6" @@ -5118,6 +5257,16 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "media" version = "0.0.1" @@ -5562,6 +5711,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -5689,17 +5844,6 @@ dependencies = [ "malloc_buf", ] -[[package]] -name = "objc-foundation" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" -dependencies = [ - "block", - "objc", - "objc_id", -] - [[package]] name = "objc-sys" version = "0.3.5" @@ -5750,6 +5894,7 @@ dependencies = [ "bitflags 2.9.3", "objc2 0.6.1", "objc2-core-foundation", + "objc2-core-graphics", "objc2-foundation 0.3.1", "objc2-quartz-core 0.3.1", ] @@ -5808,7 +5953,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "989c6c68c13021b5c2d6b71456ebb0f9dc78d752e86a98da7c716f4f9470f5a4" dependencies = [ "bitflags 2.9.3", + "dispatch2", + "objc2 0.6.1", "objc2-core-foundation", + "objc2-io-surface", ] [[package]] @@ -6013,15 +6161,6 @@ dependencies = [ "objc2-foundation 0.2.2", ] -[[package]] -name = "objc_id" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" -dependencies = [ - "objc", -] - [[package]] name = "object" version = "0.36.7" @@ -6660,6 +6799,19 @@ name = "profiling" version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" +dependencies = [ + "quote", + "syn", +] [[package]] name = "prost" @@ -6843,6 +6995,56 @@ dependencies = [ "typed-arena", ] +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools 0.12.1", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand 0.8.5", + "rand_chacha 0.3.1", + "simd_helpers", + "system-deps 6.2.2", + "thiserror 1.0.69", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5825c26fddd16ab9f515930d49028a630efec172e903483c94796cfe31893e6b" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + [[package]] name = "raw-window-handle" version = "0.6.2" @@ -7077,7 +7279,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -7090,7 +7292,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.9.4", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -7991,6 +8193,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "simplecss" version = "0.2.2" @@ -8452,13 +8663,26 @@ dependencies = [ "windows 0.61.3", ] +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr 0.15.8", + "heck 0.5.0", + "pkg-config", + "toml 0.8.23", + "version-compare", +] + [[package]] name = "system-deps" version = "7.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4be53aa0cba896d2dc615bd42bbc130acdcffa239e0a2d965ea5b3b2a86ffdb" dependencies = [ - "cfg-expr", + "cfg-expr 0.20.2", "heck 0.5.0", "pkg-config", "toml 0.8.23", @@ -8488,6 +8712,12 @@ dependencies = [ "xattr", ] +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + [[package]] name = "target-lexicon" version = "0.13.2" @@ -8511,7 +8741,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix 1.0.8", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -9250,6 +9480,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "v_frame" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + [[package]] name = "valuable" version = "0.1.1" @@ -10033,7 +10274,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0978bf7171b3d90bac376700cb56d606feb40f251a475a5d6634613564460b22" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -10217,15 +10458,6 @@ dependencies = [ "windows-targets 0.42.2", ] -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - [[package]] name = "windows-sys" version = "0.52.0" diff --git a/Cargo.toml b/Cargo.toml index f1e915c38b3..b7b84157a3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,7 @@ hyper-util = { version = "0.1", features = ["client-legacy", "http2", "tokio"] } hyper_serde = { path = "components/hyper_serde" } icu_locid = "1.5.0" icu_segmenter = "1.5.0" -image = "0.24" +image = "0.25" imsz = "0.2" indexmap = { version = "2.11.0", features = ["std"] } ipc-channel = "0.20" diff --git a/components/pixels/lib.rs b/components/pixels/lib.rs index a8f9075e595..52bf06aa12e 100644 --- a/components/pixels/lib.rs +++ b/components/pixels/lib.rs @@ -14,10 +14,9 @@ use euclid::default::{Point2D, Rect, Size2D}; use image::codecs::{bmp, gif, ico, jpeg, png, webp}; use image::error::ImageFormatHint; use image::imageops::{self, FilterType}; -use image::io::Limits; use image::{ AnimationDecoder, DynamicImage, ImageBuffer, ImageDecoder, ImageError, ImageFormat, - ImageResult, Rgba, + ImageResult, Limits, Rgba, }; use ipc_channel::ipc::IpcSharedMemory; use log::debug; @@ -366,8 +365,10 @@ pub fn load_from_memory(buffer: &[u8], cors_status: CorsStatus) -> Option { - if png_decoder.is_apng() { - let apng_decoder = png_decoder.apng(); + if png_decoder.is_apng().unwrap_or_default() { + let Ok(apng_decoder) = png_decoder.apng() else { + return None; + }; decode_animated_image(cors_status, apng_decoder) } else { decode_static_image(cors_status, *png_decoder) @@ -572,9 +573,9 @@ fn make_decoder( }) } -fn decode_static_image<'a>( +fn decode_static_image( cors_status: CorsStatus, - image_decoder: impl ImageDecoder<'a>, + image_decoder: impl ImageDecoder, ) -> Option { let Ok(dynamic_image) = DynamicImage::from_decoder(image_decoder) else { debug!("Image decoding error"); diff --git a/components/pixels/snapshot.rs b/components/pixels/snapshot.rs index 1fc7a7e1b44..42e72106c1f 100644 --- a/components/pixels/snapshot.rs +++ b/components/pixels/snapshot.rs @@ -8,7 +8,7 @@ use euclid::default::{Rect, Size2D}; use image::codecs::jpeg::JpegEncoder; use image::codecs::png::PngEncoder; use image::codecs::webp::WebPEncoder; -use image::{ColorType, ImageEncoder, ImageError}; +use image::{ExtendedColorType, GenericImageView, ImageEncoder, ImageError, Rgb}; use ipc_channel::ipc::IpcSharedMemory; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; @@ -325,10 +325,10 @@ impl Snapshot { EncodedImageType::Png => { // FIXME(nox): https://github.com/image-rs/image-png/issues/86 // FIXME(nox): https://github.com/image-rs/image-png/issues/87 - PngEncoder::new(encoder).write_image(data, width, height, ColorType::Rgba8) + PngEncoder::new(encoder).write_image(data, width, height, ExtendedColorType::Rgba8) }, EncodedImageType::Jpeg => { - let jpeg_encoder = if let Some(quality) = quality { + let mut jpeg_encoder = if let Some(quality) = quality { // The specification allows quality to be in [0.0..1.0] but the JPEG encoder // expects it to be in [1..100] if (0.0..=1.0).contains(&quality) { @@ -343,7 +343,38 @@ impl Snapshot { JpegEncoder::new(encoder) }; - jpeg_encoder.write_image(data, width, height, ColorType::Rgba8) + // JPEG doesn't support transparency, so simply calling jpeg_encoder.write_image fails here. + // Instead we have to create a struct to translate from rgba to rgb. + struct RgbaDataForJpegEncoder<'a> { + width: u32, + height: u32, + data: &'a [u8], + } + + impl<'a> GenericImageView for RgbaDataForJpegEncoder<'a> { + type Pixel = Rgb; + + fn dimensions(&self) -> (u32, u32) { + (self.width, self.height) + } + + fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel { + let offset = (self.width * y + x) as usize * 4; + Rgb([ + self.data[offset], + self.data[offset + 1], + self.data[offset + 2], + ]) + } + } + + let image = RgbaDataForJpegEncoder { + width, + height, + data, + }; + + jpeg_encoder.encode_image(&image) }, EncodedImageType::Webp => { // No quality support because of https://github.com/image-rs/image/issues/1984 @@ -351,7 +382,7 @@ impl Snapshot { data, width, height, - ColorType::Rgba8, + ExtendedColorType::Rgba8, ) }, } diff --git a/deny.toml b/deny.toml index af3b8314b20..1215c293fd1 100644 --- a/deny.toml +++ b/deny.toml @@ -48,6 +48,9 @@ confidence-threshold = 0.8 # Allow 1 or more licenses on a per-crate basis, so that particular licenses # aren't accepted for every possible crate as with the normal allow list exceptions = [ + # rav1e depends on libfuzzer-sys when cfg(fuzzing) is true, which it isn't for servo builds. + # cargo-deny is being run with --all-features, so we need to explicitly make an exception here. + { allow = ["NCSA"], crate = "libfuzzer-sys" }, ] @@ -194,6 +197,11 @@ skip = [ # Can be removed if `icu_capi` exposes the C include dir via the `DEP_` # variable in the future. "ordered-float", + + # duplicated by image 0.25 + "cfg-expr", + "system-deps", + "target-lexicon", ] # github.com organizations to allow git sources for diff --git a/tests/wpt/meta/html/semantics/embedded-content/the-img-element/animated-webp-update.tentative.html.ini b/tests/wpt/meta/html/semantics/embedded-content/the-img-element/animated-webp-update.tentative.html.ini deleted file mode 100644 index f8ddcc4e566..00000000000 --- a/tests/wpt/meta/html/semantics/embedded-content/the-img-element/animated-webp-update.tentative.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[animated-webp-update.tentative.html] - expected: FAIL