diff --git a/core/src/backend/render.rs b/core/src/backend/render.rs index 41aa6c42a..2b9cf35d0 100644 --- a/core/src/backend/render.rs +++ b/core/src/backend/render.rs @@ -1,9 +1,10 @@ use crate::shape_utils::DistilledShape; pub use crate::{transform::Transform, Color}; +use downcast_rs::Downcast; use std::io::Read; pub use swf; -pub trait RenderBackend { +pub trait RenderBackend: Downcast { fn set_viewport_dimensions(&mut self, width: u32, height: u32); fn register_shape(&mut self, shape: DistilledShape) -> ShapeHandle; fn register_glyph_shape(&mut self, shape: &swf::Glyph) -> ShapeHandle; @@ -31,6 +32,7 @@ pub trait RenderBackend { fn activate_mask(&mut self); fn pop_mask(&mut self); } +impl_downcast!(RenderBackend); #[derive(Copy, Clone, Debug)] pub struct ShapeHandle(pub usize); diff --git a/core/src/context.rs b/core/src/context.rs index a68b1d95a..c34158227 100644 --- a/core/src/context.rs +++ b/core/src/context.rs @@ -58,7 +58,7 @@ pub struct UpdateContext<'a, 'gc, 'gc_context> { pub navigator: &'a mut (dyn NavigatorBackend + 'a), /// The renderer, used by the display objects to draw themselves. - pub renderer: &'a mut (dyn RenderBackend + 'a), + pub renderer: &'a mut dyn RenderBackend, /// The input backend, used to detect user interactions. pub input: &'a mut dyn InputBackend, diff --git a/render/wgpu/src/target.rs b/render/wgpu/src/target.rs index a4326e844..8ff29efd2 100644 --- a/render/wgpu/src/target.rs +++ b/render/wgpu/src/target.rs @@ -5,7 +5,7 @@ pub trait RenderTargetFrame: Debug { fn view(&self) -> &wgpu::TextureView; } -pub trait RenderTarget: Debug { +pub trait RenderTarget: Debug + 'static { type Frame: RenderTargetFrame; fn resize(&mut self, device: &wgpu::Device, width: u32, height: u32);