pub struct ObservingRenderer<R, F> { /* private fields */ }Expand description
A renderer that hands every scene it is given to a closure before passing it on.
Observation belongs here rather than in a backend. It needs nothing from the platform, so a backend that learned about inspection would carry it once per API, and the scene is already an engine type: a scene optimiser, a culling pass, an assertion about what primitives a renderer is handed and in what order, are all statements about this layer.
What a window painted is observable one layer up, where the frame still holds the scene it
built (Window::painted_quads), so this is for observing a renderer rather than a frame.
This wraps a renderer in another renderer, and the choices that make it useful are the
forwarding ones: it observes draw and
render_scene, and it does not override
render_scene_to_image, so a readback is observed
once through the render_scene it composes rather than twice.
Implementations§
Source§impl<R, F> ObservingRenderer<R, F>
impl<R, F> ObservingRenderer<R, F>
Sourcepub fn new(inner: R, on_scene: F) -> Self
pub fn new(inner: R, on_scene: F) -> Self
Wraps inner, calling on_scene with each scene it is asked to draw.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Takes back the observed renderer.
Trait Implementations§
Source§impl<R, F> SceneRenderer for ObservingRenderer<R, F>
impl<R, F> SceneRenderer for ObservingRenderer<R, F>
Source§fn draw(&mut self, scene: &Scene) -> bool
fn draw(&mut self, scene: &Scene) -> bool
scene, returning whether it was presented. Read moreSource§fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas> ⓘ
fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas> ⓘ
Source§fn set_viewport_size(&mut self, size: Size<DevicePixels>)
fn set_viewport_size(&mut self, size: Size<DevicePixels>)
Source§fn render_scene(
&mut self,
scene: &Scene,
size: Size<DevicePixels>,
) -> Result<()>
fn render_scene( &mut self, scene: &Scene, size: Size<DevicePixels>, ) -> Result<()>
Source§fn read_pixels(&mut self) -> Result<PixelBuffer>
fn read_pixels(&mut self) -> Result<PixelBuffer>
render_scene back. Read moreSource§fn render_scene_to_image(
&mut self,
scene: &Scene,
size: Size<DevicePixels>,
) -> Result<PixelBuffer>
fn render_scene_to_image( &mut self, scene: &Scene, size: Size<DevicePixels>, ) -> Result<PixelBuffer>
scene offscreen and reads the result back.