diff --git a/core/Cargo.toml b/core/Cargo.toml index 539b11cd1ff1..42f26e4e200d 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -56,7 +56,7 @@ egui_extras = { git = "https://github.com/emilk/egui", rev = "98087029e020a1b2d7 png = { version = "0.17.10", optional = true } flv-rs = { path = "../flv" } async-channel = "1.9.0" -jpegxr = { git = "https://github.com/ruffle-rs/jpegxr", branch = "ruffle" } +jpegxr = { git = "https://github.com/ruffle-rs/jpegxr", branch = "ruffle", optional = true } image = { version = "0.24.7", default-features = false, features = ["tiff"] } [target.'cfg(not(target_family = "wasm"))'.dependencies.futures] @@ -78,6 +78,7 @@ audio = ["dasp"] known_stubs = ["linkme"] default_compatibility_rules = [] egui = ["dep:egui", "dep:egui_extras", "png"] +jpegxr = ["dep:jpegxr"] [build-dependencies] build_playerglobal = { path = "build_playerglobal" } diff --git a/core/src/avm2/globals/flash/display3D/textures/texture.rs b/core/src/avm2/globals/flash/display3D/textures/texture.rs index a363781408ff..6da52e606426 100644 --- a/core/src/avm2/globals/flash/display3D/textures/texture.rs +++ b/core/src/avm2/globals/flash/display3D/textures/texture.rs @@ -1,7 +1,4 @@ -use std::io::Cursor; - use gc_arena::GcCell; -use ruffle_render::atf::ATFTexture; use ruffle_render::backend::Context3DTextureFormat; use crate::avm2::object::TextureObject; @@ -69,6 +66,18 @@ pub fn do_copy<'gc>( Ok(()) } +#[cfg(not(feature = "jpegxr"))] +pub(super) fn do_compressed_upload<'gc>( + _: &mut Activation<'_, 'gc>, + _: TextureObject<'gc>, + _: Object<'gc>, + _: usize, + _: bool, +) -> Result<(), Error<'gc>> { + Err("Support for compressed textures not compiled in.".into()) +} + +#[cfg(feature = "jpegxr")] pub(super) fn do_compressed_upload<'gc>( activation: &mut Activation<'_, 'gc>, texture: TextureObject<'gc>, @@ -76,6 +85,9 @@ pub(super) fn do_compressed_upload<'gc>( byte_array_offset: usize, is_cube: bool, ) -> Result<(), Error<'gc>> { + use ruffle_render::atf::ATFTexture; + use std::io::Cursor; + let atf_texture = ATFTexture::from_bytes(&data.as_bytearray().unwrap().bytes()[byte_array_offset..]) .expect("Failed to parse ATF texture"); diff --git a/desktop/Cargo.toml b/desktop/Cargo.toml index 45135ea8bf88..cbb7a5573318 100644 --- a/desktop/Cargo.toml +++ b/desktop/Cargo.toml @@ -53,7 +53,7 @@ embed-resource = "2" vergen = { version = "8.2.5", features = ["build", "git", "gitcl", "cargo"] } [features] -default = ["software_video"] +default = ["software_video", "ruffle_core/jpegxr"] # core features avm_debug = ["ruffle_core/avm_debug"] diff --git a/tests/Cargo.toml b/tests/Cargo.toml index de4e351f744f..7b122396e680 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -23,7 +23,7 @@ url = "2.4.1" # Enable running image comparison tests. This is off by default, # since the images we compare against are generated on CI, and may # not match your local machine's Vulkan version / image output. -imgtests = ["ruffle_video_software"] +imgtests = ["ruffle_video_software", "ruffle_core/jpegxr"] lzma = ["ruffle_core/lzma"] [dev-dependencies] diff --git a/tests/tests/swfs/avm2/stage3d_texture_bytearray/output.expected.png b/tests/tests/swfs/avm2/stage3d_texture_bytearray/output.expected.png index 5bc1afec6b59..a5f704be3cc3 100644 Binary files a/tests/tests/swfs/avm2/stage3d_texture_bytearray/output.expected.png and b/tests/tests/swfs/avm2/stage3d_texture_bytearray/output.expected.png differ diff --git a/tests/tests/swfs/avm2/stage3d_texture_bytearray/test.toml b/tests/tests/swfs/avm2/stage3d_texture_bytearray/test.toml index 5f56a779e3be..4f58da2ea1ab 100644 --- a/tests/tests/swfs/avm2/stage3d_texture_bytearray/test.toml +++ b/tests/tests/swfs/avm2/stage3d_texture_bytearray/test.toml @@ -1,4 +1,7 @@ num_frames = 1 +[image_comparisons.output] +tolerance = 2 + [player_options] with_renderer = { optional = true, sample_count = 1 } \ No newline at end of file diff --git a/web/Cargo.toml b/web/Cargo.toml index e392b8718a3c..9671b503d710 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -13,7 +13,7 @@ publish = false # This crate is useless alone, people should use the npm package crate-type = ["cdylib", "rlib"] [features] -default = ["canvas", "console_error_panic_hook", "webgl", "wgpu-webgl"] +default = ["canvas", "console_error_panic_hook", "webgl", "wgpu-webgl", "ruffle_core/jpegxr"] # core features avm_debug = ["ruffle_core/avm_debug"]