render: Moved shape_utils from core to render
This commit is contained in:
parent
b3afb59b53
commit
35082b687f
|
@ -3105,6 +3105,7 @@ dependencies = [
|
|||
"jpeg-decoder",
|
||||
"log",
|
||||
"png",
|
||||
"smallvec",
|
||||
"swf",
|
||||
]
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ use crate::display_object::{
|
|||
};
|
||||
use crate::ecma_conversions::f64_to_wrapping_i32;
|
||||
use crate::prelude::*;
|
||||
use crate::shape_utils::DrawCommand;
|
||||
use crate::vminterface::Instantiator;
|
||||
use gc_arena::MutationContext;
|
||||
use ruffle_render::shape_utils::DrawCommand;
|
||||
use swf::{
|
||||
FillStyle, Fixed8, Gradient, GradientInterpolation, GradientRecord, GradientSpread,
|
||||
LineCapStyle, LineJoinStyle, LineStyle, Twips,
|
||||
|
|
|
@ -10,9 +10,9 @@ use crate::avm2::Namespace;
|
|||
use crate::avm2::QName;
|
||||
use crate::display_object::TDisplayObject;
|
||||
use crate::drawing::Drawing;
|
||||
use crate::shape_utils::DrawCommand;
|
||||
use crate::string::WStr;
|
||||
use gc_arena::{GcCell, MutationContext};
|
||||
use ruffle_render::shape_utils::DrawCommand;
|
||||
use std::f64::consts::FRAC_1_SQRT_2;
|
||||
use swf::{Color, FillStyle, Fixed8, LineCapStyle, LineJoinStyle, LineStyle, Twips};
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@ mod null;
|
|||
pub use null::{NullBitmapSource, NullRenderer};
|
||||
pub use ruffle_render::utils::{determine_jpeg_tag_format, remove_invalid_jpeg_data};
|
||||
|
||||
use crate::shape_utils::DistilledShape;
|
||||
pub use crate::transform::Transform;
|
||||
use downcast_rs::Downcast;
|
||||
use ruffle_render::bitmap::{Bitmap, BitmapHandle, BitmapInfo, BitmapSource};
|
||||
use ruffle_render::matrix::Matrix;
|
||||
use ruffle_render::shape_utils::DistilledShape;
|
||||
use ruffle_render::utils;
|
||||
pub use swf;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::backend::render::{Error, RenderBackend, ShapeHandle};
|
||||
use crate::shape_utils::DistilledShape;
|
||||
use crate::transform::Transform;
|
||||
use ruffle_render::bitmap::{Bitmap, BitmapHandle, BitmapInfo, BitmapSource};
|
||||
use ruffle_render::matrix::Matrix;
|
||||
use ruffle_render::shape_utils::DistilledShape;
|
||||
use swf::Color;
|
||||
|
||||
pub struct NullBitmapSource;
|
||||
|
|
|
@ -20,13 +20,13 @@ use crate::events::{ButtonKeyCode, ClipEvent, ClipEventResult, KeyCode};
|
|||
use crate::font::{round_down_to_pixel, Glyph, TextRenderSettings};
|
||||
use crate::html::{BoxBounds, FormatSpans, LayoutBox, LayoutContent, TextFormat};
|
||||
use crate::prelude::*;
|
||||
use crate::shape_utils::DrawCommand;
|
||||
use crate::string::{utils as string_utils, AvmString, WStr, WString};
|
||||
use crate::tag_utils::SwfMovie;
|
||||
use crate::transform::Transform;
|
||||
use crate::vminterface::{AvmObject, AvmType, Instantiator};
|
||||
use chrono::Utc;
|
||||
use gc_arena::{Collect, Gc, GcCell, MutationContext};
|
||||
use ruffle_render::shape_utils::DrawCommand;
|
||||
use std::{cell::Ref, cell::RefMut, sync::Arc};
|
||||
use swf::Twips;
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> {
|
|||
}
|
||||
} else {
|
||||
let shape = &self.0.read().static_data.shape;
|
||||
return crate::shape_utils::shape_hit_test(shape, point, &local_matrix);
|
||||
return ruffle_render::shape_utils::shape_hit_test(shape, point, &local_matrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,11 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> {
|
|||
if let Some(frame) = self.0.read().static_data.frames.borrow().get(&self.ratio()) {
|
||||
let local_matrix = self.global_to_local_matrix();
|
||||
let point = local_matrix * point;
|
||||
return crate::shape_utils::shape_hit_test(&frame.shape, point, &local_matrix);
|
||||
return ruffle_render::shape_utils::shape_hit_test(
|
||||
&frame.shape,
|
||||
point,
|
||||
&local_matrix,
|
||||
);
|
||||
} else {
|
||||
log::warn!("Missing ratio for morph shape");
|
||||
}
|
||||
|
@ -293,7 +297,7 @@ impl MorphShapeStatic {
|
|||
line_styles,
|
||||
};
|
||||
|
||||
let bounds = crate::shape_utils::calculate_shape_bounds(&shape[..]);
|
||||
let bounds = ruffle_render::shape_utils::calculate_shape_bounds(&shape[..]);
|
||||
let shape = swf::Shape {
|
||||
version: 4,
|
||||
id: 0,
|
||||
|
|
|
@ -201,7 +201,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> {
|
|||
let glyph_shape = glyph.as_shape();
|
||||
let glyph_bounds: BoundingBox = (&glyph_shape.shape_bounds).into();
|
||||
if glyph_bounds.contains(point)
|
||||
&& crate::shape_utils::shape_hit_test(
|
||||
&& ruffle_render::shape_utils::shape_hit_test(
|
||||
&glyph_shape,
|
||||
point,
|
||||
&local_matrix,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::backend::render::ShapeHandle;
|
||||
use crate::context::RenderContext;
|
||||
use crate::shape_utils::{DistilledShape, DrawCommand, DrawPath};
|
||||
use gc_arena::Collect;
|
||||
use ruffle_render::bitmap::{BitmapInfo, BitmapSource};
|
||||
use ruffle_render::bounding_box::BoundingBox;
|
||||
use ruffle_render::shape_utils::{DistilledShape, DrawCommand, DrawPath};
|
||||
use std::cell::Cell;
|
||||
use swf::{FillStyle, LineStyle, Twips};
|
||||
|
||||
|
@ -304,7 +304,7 @@ impl Drawing {
|
|||
point: (Twips, Twips),
|
||||
local_matrix: &ruffle_render::matrix::Matrix,
|
||||
) -> bool {
|
||||
use crate::shape_utils;
|
||||
use ruffle_render::shape_utils;
|
||||
for path in &self.paths {
|
||||
match path {
|
||||
DrawingPath::Fill(fill) => {
|
||||
|
|
|
@ -432,7 +432,9 @@ impl Glyph {
|
|||
pub fn as_shape(&self) -> Ref<'_, swf::Shape> {
|
||||
let mut write = self.shape.borrow_mut();
|
||||
if write.is_none() {
|
||||
*write = Some(crate::shape_utils::swf_glyph_to_shape(&self.swf_glyph));
|
||||
*write = Some(ruffle_render::shape_utils::swf_glyph_to_shape(
|
||||
&self.swf_glyph,
|
||||
));
|
||||
}
|
||||
drop(write);
|
||||
let read = self.shape.borrow();
|
||||
|
|
|
@ -5,10 +5,10 @@ use crate::drawing::Drawing;
|
|||
use crate::font::{EvalParameters, Font};
|
||||
use crate::html::dimensions::{BoxBounds, Position, Size};
|
||||
use crate::html::text_format::{FormatSpans, TextFormat, TextSpan};
|
||||
use crate::shape_utils::DrawCommand;
|
||||
use crate::string::{utils as string_utils, WStr};
|
||||
use crate::tag_utils::SwfMovie;
|
||||
use gc_arena::Collect;
|
||||
use ruffle_render::shape_utils::DrawCommand;
|
||||
use std::cmp::{max, min};
|
||||
use std::sync::Arc;
|
||||
use swf::Twips;
|
||||
|
|
|
@ -32,7 +32,6 @@ pub mod loader;
|
|||
mod locale;
|
||||
mod player;
|
||||
mod prelude;
|
||||
pub mod shape_utils;
|
||||
pub mod string;
|
||||
pub mod tag_utils;
|
||||
pub mod timer;
|
||||
|
|
|
@ -12,6 +12,7 @@ log = "0.4"
|
|||
gif = "0.11.4"
|
||||
png = { version = "0.17.5" }
|
||||
flate2 = "1.0.24"
|
||||
smallvec = { version = "1.9.0", features = ["union"] }
|
||||
|
||||
[dependencies.jpeg-decoder]
|
||||
version = "0.2.6"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use fnv::FnvHashMap;
|
||||
use ruffle_core::backend::render::{NullBitmapSource, RenderBackend, ShapeHandle, Transform};
|
||||
use ruffle_core::color_transform::ColorTransform;
|
||||
use ruffle_core::shape_utils::{DistilledShape, DrawCommand, LineScaleMode, LineScales};
|
||||
use ruffle_core::swf::{self, Color};
|
||||
use ruffle_render::bitmap::{Bitmap, BitmapFormat, BitmapHandle, BitmapSource};
|
||||
use ruffle_render::matrix::Matrix;
|
||||
use ruffle_render::shape_utils::{DistilledShape, DrawCommand, LineScaleMode, LineScales};
|
||||
use ruffle_web_common::{JsError, JsResult};
|
||||
use wasm_bindgen::{Clamped, JsCast};
|
||||
use web_sys::{
|
||||
|
@ -375,7 +375,7 @@ impl RenderBackend for WebCanvasRenderBackend {
|
|||
}
|
||||
|
||||
fn register_glyph_shape(&mut self, glyph: &swf::Glyph) -> ShapeHandle {
|
||||
let shape = ruffle_core::shape_utils::swf_glyph_to_shape(glyph);
|
||||
let shape = ruffle_render::shape_utils::swf_glyph_to_shape(glyph);
|
||||
self.register_shape((&shape).into(), &NullBitmapSource)
|
||||
}
|
||||
|
||||
|
@ -740,7 +740,7 @@ fn swf_shape_to_canvas_commands(
|
|||
bitmaps: &FnvHashMap<BitmapHandle, BitmapData>,
|
||||
context: &CanvasRenderingContext2d,
|
||||
) -> ShapeData {
|
||||
use ruffle_core::shape_utils::DrawPath;
|
||||
use ruffle_render::shape_utils::DrawPath;
|
||||
use swf::{FillStyle, LineCapStyle, LineJoinStyle};
|
||||
|
||||
// Some browsers will vomit if you try to load/draw an image with 0 width/height.
|
||||
|
|
|
@ -5,9 +5,9 @@ use lyon::tessellation::{
|
|||
FillTessellator, FillVertex, StrokeTessellator, StrokeVertex, StrokeVertexConstructor,
|
||||
};
|
||||
use lyon::tessellation::{FillOptions, StrokeOptions};
|
||||
use ruffle_core::shape_utils::{DistilledShape, DrawCommand, DrawPath};
|
||||
use ruffle_core::swf;
|
||||
use ruffle_render::bitmap::{BitmapHandle, BitmapSource};
|
||||
use ruffle_render::shape_utils::{DistilledShape, DrawCommand, DrawPath};
|
||||
|
||||
pub struct ShapeTessellator {
|
||||
fill_tess: FillTessellator,
|
||||
|
|
|
@ -2,4 +2,5 @@ pub mod bitmap;
|
|||
pub mod bounding_box;
|
||||
pub mod error;
|
||||
pub mod matrix;
|
||||
pub mod shape_utils;
|
||||
pub mod utils;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use ruffle_render::bounding_box::BoundingBox;
|
||||
use ruffle_render::matrix::Matrix;
|
||||
use crate::bounding_box::BoundingBox;
|
||||
use crate::matrix::Matrix;
|
||||
use smallvec::SmallVec;
|
||||
use swf::{CharacterId, FillStyle, LineStyle, Shape, ShapeRecord, Twips};
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
use bytemuck::{Pod, Zeroable};
|
||||
use fnv::FnvHashMap;
|
||||
use ruffle_core::backend::render::{NullBitmapSource, RenderBackend, ShapeHandle, Transform};
|
||||
use ruffle_core::shape_utils::DistilledShape;
|
||||
use ruffle_core::swf::{self, Color};
|
||||
use ruffle_render::bitmap::{Bitmap, BitmapFormat, BitmapHandle, BitmapSource};
|
||||
use ruffle_render::shape_utils::DistilledShape;
|
||||
use ruffle_render_common_tess::{
|
||||
Gradient as TessGradient, GradientType, ShapeTessellator, Vertex as TessVertex,
|
||||
};
|
||||
|
@ -703,7 +703,7 @@ impl RenderBackend for WebGlRenderBackend {
|
|||
}
|
||||
|
||||
fn register_glyph_shape(&mut self, glyph: &swf::Glyph) -> ShapeHandle {
|
||||
let shape = ruffle_core::shape_utils::swf_glyph_to_shape(glyph);
|
||||
let shape = ruffle_render::shape_utils::swf_glyph_to_shape(glyph);
|
||||
let handle = ShapeHandle(self.meshes.len());
|
||||
let mesh = self.register_shape_internal((&shape).into(), &NullBitmapSource);
|
||||
self.meshes.push(mesh);
|
||||
|
|
|
@ -9,9 +9,9 @@ use enum_map::Enum;
|
|||
use fnv::FnvHashMap;
|
||||
use ruffle_core::backend::render::{RenderBackend, ShapeHandle, Transform};
|
||||
use ruffle_core::color_transform::ColorTransform;
|
||||
use ruffle_core::shape_utils::DistilledShape;
|
||||
use ruffle_core::swf::{self, Color};
|
||||
use ruffle_render::bitmap::{Bitmap, BitmapHandle, BitmapSource};
|
||||
use ruffle_render::shape_utils::DistilledShape;
|
||||
use ruffle_render_common_tess::{
|
||||
DrawType as TessDrawType, Gradient as TessGradient, GradientType, ShapeTessellator,
|
||||
Vertex as TessVertex,
|
||||
|
@ -897,7 +897,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
|||
}
|
||||
|
||||
fn register_glyph_shape(&mut self, glyph: &swf::Glyph) -> ShapeHandle {
|
||||
let shape = ruffle_core::shape_utils::swf_glyph_to_shape(glyph);
|
||||
let shape = ruffle_render::shape_utils::swf_glyph_to_shape(glyph);
|
||||
let handle = ShapeHandle(self.meshes.len());
|
||||
let mesh = self.register_shape_internal(
|
||||
(&shape).into(),
|
||||
|
|
Loading…
Reference in New Issue