Skip to main content

ObservingRenderer

Struct ObservingRenderer 

Source
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>

Source

pub fn new(inner: R, on_scene: F) -> ObservingRenderer<R, F>

Wraps inner, calling on_scene with each scene it is asked to draw.

Source

pub fn inner(&self) -> &R

The renderer being observed.

Source

pub fn inner_mut(&mut self) -> &mut R

The renderer being observed.

Source

pub fn into_inner(self) -> R

Takes back the observed renderer.

Trait Implementations§

Source§

impl<R, F> SceneRenderer for ObservingRenderer<R, F>
where R: SceneRenderer, F: FnMut(&Scene) + 'static,

Source§

fn draw(&mut self, scene: &Scene) -> bool

Encodes and submits scene, returning whether it was presented. Read more
Source§

fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas> ⓘ

Returns the sprite atlas used by this renderer.
Source§

fn set_viewport_size(&mut self, size: Size<DevicePixels>)

Sets the size of the target that draw renders into. Read more
Source§

fn render_scene( &mut self, scene: &Scene, size: Size<DevicePixels>, ) -> Result<(), Error>

Renders scene into an offscreen target of size, without reading it back. Read more
Source§

fn read_pixels(&mut self) -> Result<PixelBuffer, Error>

Reads the offscreen target of the last render_scene back. Read more
Source§

fn offscreen_surface_handle(&self) -> Option<Arc<dyn Any + Send + Sync>>

The offscreen target of the last render_scene, as a handle that may cross a thread boundary. Read more
Source§

fn render_scene_to_image( &mut self, scene: &Scene, size: Size<DevicePixels>, ) -> Result<PixelBuffer, Error>

Renders scene offscreen and reads the result back.

Auto Trait Implementations§

§

impl<R, F> Freeze for ObservingRenderer<R, F>
where R: Freeze, F: Freeze,

§

impl<R, F> RefUnwindSafe for ObservingRenderer<R, F>

§

impl<R, F> Send for ObservingRenderer<R, F>
where R: Send, F: Send,

§

impl<R, F> Sync for ObservingRenderer<R, F>
where R: Sync, F: Sync,

§

impl<R, F> Unpin for ObservingRenderer<R, F>
where R: Unpin, F: Unpin,

§

impl<R, F> UnsafeUnpin for ObservingRenderer<R, F>
where R: UnsafeUnpin, F: UnsafeUnpin,

§

impl<R, F> UnwindSafe for ObservingRenderer<R, F>
where R: UnwindSafe, F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> NativeSceneHooks for T
where T: SceneRenderer + ?Sized,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more