core: Place jpegxr texture support behind feature flag (#13348)

This commit is contained in:
sleepycatcoding 2023-09-30 01:46:54 +03:00 committed by GitHub
parent c3d0540a6e
commit f140e7a14b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 7 deletions

View File

@ -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" }

View File

@ -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");

View File

@ -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"]

View File

@ -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]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -1,4 +1,7 @@
num_frames = 1
[image_comparisons.output]
tolerance = 2
[player_options]
with_renderer = { optional = true, sample_count = 1 }

View File

@ -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"]