render: Moved render utils from core to render
This commit is contained in:
parent
bc0c7cbccb
commit
9fd8fd938e
|
@ -3025,12 +3025,10 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"gc-arena",
|
"gc-arena",
|
||||||
"generational-arena",
|
"generational-arena",
|
||||||
"gif",
|
|
||||||
"h263-rs",
|
"h263-rs",
|
||||||
"h263-rs-yuv",
|
"h263-rs-yuv",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"instant",
|
"instant",
|
||||||
"jpeg-decoder",
|
|
||||||
"log",
|
"log",
|
||||||
"lzma-rs",
|
"lzma-rs",
|
||||||
"minimp3",
|
"minimp3",
|
||||||
|
@ -3041,7 +3039,6 @@ dependencies = [
|
||||||
"num-derive",
|
"num-derive",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"png",
|
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
"rand",
|
"rand",
|
||||||
"regress",
|
"regress",
|
||||||
|
@ -3102,8 +3099,12 @@ dependencies = [
|
||||||
name = "ruffle_render"
|
name = "ruffle_render"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"flate2",
|
||||||
"gc-arena",
|
"gc-arena",
|
||||||
|
"gif",
|
||||||
|
"jpeg-decoder",
|
||||||
"log",
|
"log",
|
||||||
|
"png",
|
||||||
"swf",
|
"swf",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,9 @@ flate2 = "1.0.24"
|
||||||
fnv = "1.0.7"
|
fnv = "1.0.7"
|
||||||
gc-arena = { git = "https://github.com/ruffle-rs/gc-arena" }
|
gc-arena = { git = "https://github.com/ruffle-rs/gc-arena" }
|
||||||
generational-arena = "0.2.8"
|
generational-arena = "0.2.8"
|
||||||
gif = "0.11.4"
|
|
||||||
indexmap = "1.9.1"
|
indexmap = "1.9.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
minimp3 = { version = "0.5.1", optional = true }
|
minimp3 = { version = "0.5.1", optional = true }
|
||||||
png = { version = "0.17.5" }
|
|
||||||
ruffle_render = { path = "../render" }
|
ruffle_render = { path = "../render" }
|
||||||
ruffle_macros = { path = "macros" }
|
ruffle_macros = { path = "macros" }
|
||||||
ruffle_wstr = { path = "../wstr" }
|
ruffle_wstr = { path = "../wstr" }
|
||||||
|
@ -49,10 +47,6 @@ nihav_core = { git = "https://github.com/ruffle-rs/nihav-vp6", rev = "9416fcc9fc
|
||||||
nihav_codec_support = { git = "https://github.com/ruffle-rs/nihav-vp6", rev = "9416fcc9fc8aab8f4681aa9093b42922214abbd3", optional = true }
|
nihav_codec_support = { git = "https://github.com/ruffle-rs/nihav-vp6", rev = "9416fcc9fc8aab8f4681aa9093b42922214abbd3", optional = true }
|
||||||
nihav_duck = { git = "https://github.com/ruffle-rs/nihav-vp6", rev = "9416fcc9fc8aab8f4681aa9093b42922214abbd3", optional = true }
|
nihav_duck = { git = "https://github.com/ruffle-rs/nihav-vp6", rev = "9416fcc9fc8aab8f4681aa9093b42922214abbd3", optional = true }
|
||||||
|
|
||||||
[dependencies.jpeg-decoder]
|
|
||||||
version = "0.2.6"
|
|
||||||
default-features = false # can't use rayon on web
|
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies.futures]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies.futures]
|
||||||
version = "0.3.21"
|
version = "0.3.21"
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
mod null;
|
mod null;
|
||||||
mod utils;
|
|
||||||
|
|
||||||
pub use null::{NullBitmapSource, NullRenderer};
|
pub use null::{NullBitmapSource, NullRenderer};
|
||||||
pub use utils::{determine_jpeg_tag_format, remove_invalid_jpeg_data};
|
pub use ruffle_render::utils::{determine_jpeg_tag_format, remove_invalid_jpeg_data};
|
||||||
|
|
||||||
use crate::matrix::Matrix;
|
use crate::matrix::Matrix;
|
||||||
use crate::shape_utils::DistilledShape;
|
use crate::shape_utils::DistilledShape;
|
||||||
pub use crate::transform::Transform;
|
pub use crate::transform::Transform;
|
||||||
use downcast_rs::Downcast;
|
use downcast_rs::Downcast;
|
||||||
use ruffle_render::bitmap::{Bitmap, BitmapFormat, BitmapHandle, BitmapInfo, BitmapSource};
|
use ruffle_render::bitmap::{Bitmap, BitmapHandle, BitmapInfo, BitmapSource};
|
||||||
|
use ruffle_render::utils;
|
||||||
pub use swf;
|
pub use swf;
|
||||||
|
|
||||||
pub trait RenderBackend: Downcast {
|
pub trait RenderBackend: Downcast {
|
||||||
|
@ -107,14 +107,3 @@ type Error = Box<dyn std::error::Error>;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct ShapeHandle(pub usize);
|
pub struct ShapeHandle(pub usize);
|
||||||
|
|
||||||
/// The format of image data in a DefineBitsJpeg2/3 tag.
|
|
||||||
/// Generally this will be JPEG, but according to SWF19, these tags can also contain PNG and GIF data.
|
|
||||||
/// SWF19 pp.138-139
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
|
||||||
pub enum JpegTagFormat {
|
|
||||||
Jpeg,
|
|
||||||
Png,
|
|
||||||
Gif,
|
|
||||||
Unknown,
|
|
||||||
}
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ use crate::avm2::{
|
||||||
Value as Avm2Value,
|
Value as Avm2Value,
|
||||||
};
|
};
|
||||||
use crate::backend::navigator::{OwnedFuture, Request};
|
use crate::backend::navigator::{OwnedFuture, Request};
|
||||||
use crate::backend::render::{determine_jpeg_tag_format, JpegTagFormat};
|
|
||||||
use crate::context::{ActionQueue, ActionType, UpdateContext};
|
use crate::context::{ActionQueue, ActionType, UpdateContext};
|
||||||
use crate::display_object::{
|
use crate::display_object::{
|
||||||
Bitmap, DisplayObject, TDisplayObject, TDisplayObjectContainer, TInteractiveObject,
|
Bitmap, DisplayObject, TDisplayObject, TDisplayObjectContainer, TInteractiveObject,
|
||||||
|
@ -26,6 +25,7 @@ use crate::vminterface::Instantiator;
|
||||||
use encoding_rs::UTF_8;
|
use encoding_rs::UTF_8;
|
||||||
use gc_arena::{Collect, CollectionContext};
|
use gc_arena::{Collect, CollectionContext};
|
||||||
use generational_arena::{Arena, Index};
|
use generational_arena::{Arena, Index};
|
||||||
|
use ruffle_render::utils::{determine_jpeg_tag_format, JpegTagFormat};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::{Arc, Mutex, Weak};
|
use std::sync::{Arc, Mutex, Weak};
|
||||||
use swf::read::read_compression_type;
|
use swf::read::read_compression_type;
|
||||||
|
|
|
@ -9,4 +9,11 @@ license = "MIT OR Apache-2.0"
|
||||||
swf = {path = "../swf"}
|
swf = {path = "../swf"}
|
||||||
gc-arena = { git = "https://github.com/ruffle-rs/gc-arena" }
|
gc-arena = { git = "https://github.com/ruffle-rs/gc-arena" }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
gif = "0.11.4"
|
||||||
|
png = { version = "0.17.5" }
|
||||||
|
flate2 = "1.0.24"
|
||||||
|
|
||||||
|
[dependencies.jpeg-decoder]
|
||||||
|
version = "0.2.6"
|
||||||
|
default-features = false # can't use rayon on web
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
pub type Error = Box<dyn std::error::Error>;
|
|
@ -1 +1,3 @@
|
||||||
pub mod bitmap;
|
pub mod bitmap;
|
||||||
|
pub mod error;
|
||||||
|
pub mod utils;
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
use crate::backend::render::{Bitmap, BitmapFormat, Error, JpegTagFormat};
|
use crate::bitmap::{Bitmap, BitmapFormat};
|
||||||
|
use crate::error::Error;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use swf::Color;
|
use swf::Color;
|
||||||
|
|
||||||
|
/// The format of image data in a DefineBitsJpeg2/3 tag.
|
||||||
|
/// Generally this will be JPEG, but according to SWF19, these tags can also contain PNG and GIF data.
|
||||||
|
/// SWF19 pp.138-139
|
||||||
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
|
pub enum JpegTagFormat {
|
||||||
|
Jpeg,
|
||||||
|
Png,
|
||||||
|
Gif,
|
||||||
|
Unknown,
|
||||||
|
}
|
||||||
|
|
||||||
/// Determines the format of the image data in `data` from a DefineBitsJPEG2/3 tag.
|
/// Determines the format of the image data in `data` from a DefineBitsJPEG2/3 tag.
|
||||||
pub fn determine_jpeg_tag_format(data: &[u8]) -> JpegTagFormat {
|
pub fn determine_jpeg_tag_format(data: &[u8]) -> JpegTagFormat {
|
||||||
match data {
|
match data {
|
Loading…
Reference in New Issue