render: Move canvas renderer to separate subcrate

This commit is contained in:
Mike Welsh 2020-04-23 15:04:07 -07:00
parent 97d1eb5eb9
commit 87bf0f44c4
10 changed files with 82 additions and 24 deletions

37
Cargo.lock generated
View File

@ -1618,6 +1618,24 @@ dependencies = [
"syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ruffle_render_canvas"
version = "0.1.0"
dependencies = [
"base64 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"jpeg-decoder 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.16.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ruffle_core 0.1.0",
"ruffle_web_common 0.1.0",
"svg 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
"web-sys 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ruffle_scanner"
version = "0.1.0"
@ -1637,19 +1655,16 @@ dependencies = [
name = "ruffle_web"
version = "0.1.0"
dependencies = [
"base64 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"console_log 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"generational-arena 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"jpeg-decoder 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.16.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ruffle_core 0.1.0",
"svg 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"ruffle_render_canvas 0.1.0",
"ruffle_web_common 0.1.0",
"url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-futures 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1657,6 +1672,14 @@ dependencies = [
"web-sys 0.3.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ruffle_web_common"
version = "0.1.0"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.57 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-demangle"
version = "0.1.16"
@ -1878,7 +1901,7 @@ dependencies = [
[[package]]
name = "svg"
version = "0.8.0"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -2601,7 +2624,7 @@ dependencies = [
"checksum strsim 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "032c03039aae92b350aad2e3779c352e104d919cb192ba2fabbd7b831ce4f0f6"
"checksum structopt 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "863246aaf5ddd0d6928dfeb1a9ca65f505599e4e1b399935ef7e75107516b4ef"
"checksum structopt-derive 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d239ca4b13aee7a2142e6795cbd69e457665ff8037aed33b3effdc430d2f927a"
"checksum svg 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0b65a64d32a41db2a8081aa03c1ccca26f246ff681add693f8b01307b137da79"
"checksum svg 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3685c82a045a6af0c488f0550b0f52b4c77d2a52b0ca8aba719f9d268fa96965"
"checksum syn 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213"
"checksum syn-mid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338a"
"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545"

View File

@ -6,6 +6,8 @@ members = [
"swf",
"web",
"scanner",
"render/canvas",
]
# Don't optimize build scripts and macros.

34
render/canvas/Cargo.toml Normal file
View File

@ -0,0 +1,34 @@
[package]
name = "ruffle_render_canvas"
version = "0.1.0"
authors = ["Mike Welsh <mwelsh@gmail.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
base64 = "0.12.0"
fnv = "1.0.3"
js-sys = "0.3.25"
log = "0.4"
ruffle_web_common = { path = "../../web/common" }
svg = "0.7.2"
percent-encoding = "2.1.0"
png = "0.16.3"
wasm-bindgen = "0.2.57"
[dependencies.jpeg-decoder]
version = "0.1.18"
default-features = false # can't use rayon on web
[dependencies.ruffle_core]
path = "../../core"
default-features = false
[dependencies.web-sys]
version = "0.3.34"
features = [
"CanvasRenderingContext2d", "CssStyleDeclaration", "Document", "Element", "HtmlCanvasElement", "HtmlElement", "HtmlImageElement",
"Navigator", "Node", "UiEvent", "Window", "Path2d", "CanvasGradient", "CanvasPattern", "SvgMatrix", "SvgsvgElement"
]

View File

@ -1,10 +1,10 @@
use crate::utils::JsResult;
use ruffle_core::backend::render::{
swf, swf::CharacterId, BitmapHandle, BitmapInfo, Color, Letterbox, RenderBackend, ShapeHandle,
Transform,
};
use ruffle_core::color_transform::ColorTransform;
use ruffle_core::shape_utils::DrawCommand;
use ruffle_web_common::JsResult;
use std::collections::HashMap;
use std::convert::TryInto;
use wasm_bindgen::{JsCast, JsValue};

View File

@ -12,7 +12,6 @@ lzma = ["ruffle_core/lzma"]
default = ["console_error_panic_hook", "console_log"]
[dependencies]
base64 = "0.12.0"
byteorder = "1.3.4"
console_error_panic_hook = { version = "0.1.1", optional = true }
console_log = { version = "0.2", optional = true }
@ -20,17 +19,12 @@ fnv = "1.0.3"
generational-arena = "0.2.7"
js-sys = "0.3.25"
log = "0.4"
png = "0.16.3"
svg = "0.8.0"
percent-encoding = "2.1.0"
ruffle_render_canvas = { path = "../render/canvas" }
ruffle_web_common = { path = "common" }
url = "2.1.1"
wasm-bindgen = "0.2.57"
wasm-bindgen-futures = "0.4.4"
[dependencies.jpeg-decoder]
version = "0.1.19"
default-features = false # can't use rayon on web
[dependencies.ruffle_core]
path = "../core"
default-features = false

9
web/common/Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "ruffle_web_common"
version = "0.1.0"
authors = ["Mike Welsh <mwelsh@gmail.com>"]
edition = "2018"
[dependencies]
log = "0.4"
wasm-bindgen = "0.2.57"

View File

@ -1,4 +1,3 @@
use crate::utils::JsResult;
use fnv::FnvHashMap;
use generational_arena::Arena;
use ruffle_core::backend::audio::decoders::{AdpcmDecoder, Mp3Decoder};
@ -6,6 +5,7 @@ use ruffle_core::backend::audio::swf::{self, AudioCompression};
use ruffle_core::backend::audio::{
AudioBackend, AudioStreamHandle, SoundHandle, SoundInstanceHandle,
};
use ruffle_web_common::JsResult;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use wasm_bindgen::{closure::Closure, prelude::*, JsCast};

View File

@ -1,6 +1,6 @@
use crate::utils::JsResult;
use ruffle_core::backend::input::{InputBackend, MouseCursor};
use ruffle_core::events::KeyCode;
use ruffle_web_common::JsResult;
use std::collections::HashSet;
use web_sys::HtmlCanvasElement;

View File

@ -2,16 +2,12 @@
mod audio;
mod input;
mod navigator;
mod render;
mod utils;
use crate::{
audio::WebAudioBackend, input::WebInputBackend, navigator::WebNavigatorBackend,
render::WebCanvasRenderBackend,
};
use crate::{audio::WebAudioBackend, input::WebInputBackend, navigator::WebNavigatorBackend};
use generational_arena::{Arena, Index};
use js_sys::Uint8Array;
use ruffle_core::PlayerEvent;
use ruffle_render_canvas::WebCanvasRenderBackend;
use std::mem::drop;
use std::sync::{Arc, Mutex};
use std::{cell::RefCell, error::Error, num::NonZeroI32};