core: Make RenderBackend downcastable
This commit is contained in:
parent
a4905536b9
commit
2343074c56
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue