2019-05-03 02:11:47 +00:00
|
|
|
use crate::backend::render::ShapeHandle;
|
2019-04-26 21:11:29 +00:00
|
|
|
use crate::color_transform::ColorTransform;
|
2019-05-24 17:25:03 +00:00
|
|
|
use crate::display_object::{DisplayObjectBase, DisplayObject};
|
2019-04-27 01:55:06 +00:00
|
|
|
use crate::matrix::Matrix;
|
|
|
|
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 {
|
2019-05-07 10:22:58 +00:00
|
|
|
pub fn from_swf_tag(swf_shape: &swf::Shape, context: &mut UpdateContext) -> Graphic {
|
|
|
|
let shape_handle = context.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
|
|
|
|
}
|
|
|
|
}
|