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§
Required Methods§
Sourcefn compile(
device: &Device,
text_view: &TextureView,
surface_config: &SurfaceConfiguration,
user_data: Self::UserData,
) -> Self
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
.
Sourcefn resize(
&mut self,
device: &Device,
text_view: &TextureView,
surface_config: &SurfaceConfiguration,
)
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).
Sourcefn process(
&mut self,
encoder: &mut CommandEncoder,
queue: &Queue,
text_view: &TextureView,
surface_config: &SurfaceConfiguration,
surface_view: &TextureView,
)
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§
Sourcefn needs_update(&self) -> bool
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.