ruffle/core/src/graphic.rs

46 lines
1.1 KiB
Rust
Raw Normal View History

2019-07-19 08:32:41 +00:00
use crate::backend::render::{RenderBackend, ShapeHandle};
use crate::display_object::{DisplayObject, DisplayObjectBase};
2019-04-27 01:55:06 +00:00
use crate::player::{RenderContext, UpdateContext};
2019-04-25 17:52:22 +00:00
2019-05-24 17:25:03 +00:00
#[derive(Clone)]
2019-04-25 17:52:22 +00:00
pub struct Graphic {
2019-04-29 05:55:44 +00:00
base: DisplayObjectBase,
2019-05-09 01:10:43 +00:00
2019-04-27 17:54:37 +00:00
shape_handle: ShapeHandle,
2019-04-25 17:52:22 +00:00
}
impl Graphic {
pub fn from_swf_tag(swf_shape: &swf::Shape, renderer: &mut dyn RenderBackend) -> Graphic {
2019-07-19 08:32:41 +00:00
let shape_handle = renderer.register_shape(swf_shape);
2019-04-25 17:52:22 +00:00
Graphic {
2019-04-29 05:55:44 +00:00
base: Default::default(),
2019-04-27 17:54:37 +00:00
shape_handle,
2019-04-25 17:52:22 +00:00
}
}
}
2019-05-24 17:25:03 +00:00
impl<'gc> DisplayObject<'gc> for Graphic {
2019-05-07 10:34:17 +00:00
impl_display_object!(base);
2019-04-29 05:55:44 +00:00
2019-04-26 03:27:44 +00:00
fn run_frame(&mut self, _context: &mut UpdateContext) {
2019-04-25 17:52:22 +00:00
// Noop
}
fn render(&self, context: &mut RenderContext) {
2019-05-01 16:55:54 +00:00
context.transform_stack.push(self.transform());
2019-04-26 21:11:29 +00:00
2019-04-27 17:54:37 +00:00
context
.renderer
2019-05-01 16:55:54 +00:00
.render_shape(self.shape_handle, context.transform_stack.transform());
2019-04-27 17:54:37 +00:00
2019-05-01 16:55:54 +00:00
context.transform_stack.pop();
2019-04-26 21:11:29 +00:00
}
2019-04-25 17:52:22 +00:00
}
2019-05-24 17:25:03 +00:00
unsafe impl<'gc> gc_arena::Collect for Graphic {
#[inline]
fn needs_trace() -> bool {
false
}
}