Trait PostProcessor

Source
pub trait PostProcessor {
    type UserData;

    // Required methods
    fn compile(
        device: &Device,
        text_view: &TextureView,
        surface_config: &SurfaceConfiguration,
        user_data: Self::UserData,
    ) -> Self;
    fn resize(
        &mut self,
        device: &Device,
        text_view: &TextureView,
        surface_config: &SurfaceConfiguration,
    );
    fn process(
        &mut self,
        encoder: &mut CommandEncoder,
        queue: &Queue,
        text_view: &TextureView,
        surface_config: &SurfaceConfiguration,
        surface_view: &TextureView,
    );

    // Provided method
    fn needs_update(&self) -> bool { ... }
}
Expand description

A pipeline for post-processing rendered text.

Required Associated Types§

Source

type UserData

Custom user data which will be supplied during creation of the post processor. Use this to pass in any external state your processor requires.

Required Methods§

Source

fn compile( device: &Device, text_view: &TextureView, surface_config: &SurfaceConfiguration, user_data: Self::UserData, ) -> Self

Called during initialization of the backend. This should fully initialize the post processor for rendering. Note that you are expected to render to the final surface during PostProcessor::process.

Source

fn resize( &mut self, device: &Device, text_view: &TextureView, surface_config: &SurfaceConfiguration, )

Called after the drawing dimensions have changed (e.g. the surface was resized).

Source

fn process( &mut self, encoder: &mut CommandEncoder, queue: &Queue, text_view: &TextureView, surface_config: &SurfaceConfiguration, surface_view: &TextureView, )

Called after text has finished compositing. The provided text_view is the composited text. The final output of your implementation should render to the provided surface_view.

Retaining a reference to the provided surface view will cause a panic if the swapchain is recreated.

Provided Methods§

Source

fn needs_update(&self) -> bool

Called to see if this post processor wants to update the screen. By default, the backend only runs the compositor and post processor when the text changes. Returning true from this will override that behavior and cause the processor to be invoked after a call to flush, even if no text changes occurred.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§