pub struct PipelineRegistry { /* private fields */ }
Expand description
Registry for managing and dispatching drawable pipelines.
The PipelineRegistry
serves as the central hub for all rendering pipelines in the
Tessera framework. It maintains a collection of registered pipelines and handles
the dispatch of draw commands to their appropriate pipelines.
§Architecture
The registry uses type erasure to store pipelines of different types in a single collection. When a draw command needs to be rendered, the registry iterates through all registered pipelines until it finds one that can handle the command type.
§Usage Pattern
- Create a new registry
- Register all required pipelines during application initialization
- The renderer uses the registry to dispatch commands during frame rendering
§Example
use tessera_ui::renderer::drawer::PipelineRegistry;
// Create registry and register pipelines
let mut registry = PipelineRegistry::new();
registry.register(my_shape_pipeline);
registry.register(my_text_pipeline);
registry.register(my_image_pipeline);
// Registry is now ready for use by the renderer
§Performance Considerations
- Pipeline lookup is O(n) where n is the number of registered pipelines
- Register frequently used pipelines first for better average performance
- Consider the order of registration based on command frequency
Implementations§
Source§impl PipelineRegistry
impl PipelineRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty pipeline registry.
§Example
use tessera_ui::renderer::drawer::PipelineRegistry;
let registry = PipelineRegistry::new();
Sourcepub fn register<T: DrawCommand + 'static, P: DrawablePipeline<T> + 'static>(
&mut self,
pipeline: P,
)
pub fn register<T: DrawCommand + 'static, P: DrawablePipeline<T> + 'static>( &mut self, pipeline: P, )
Registers a new drawable pipeline for a specific command type.
This method takes ownership of the pipeline and wraps it in a type-erased container that can be stored alongside other pipelines of different types.
§Type Parameters
T
- TheDrawCommand
type this pipeline handlesP
- The pipeline implementation type
§Parameters
pipeline
- The pipeline instance to register
§Panics
This method does not panic, but the registry will panic during dispatch if no pipeline is found for a given command type.
§Example
use tessera_ui::renderer::drawer::PipelineRegistry;
let mut registry = PipelineRegistry::new();
// Register a custom pipeline
let my_pipeline = MyCustomPipeline::new(&device, &config, sample_count);
registry.register(my_pipeline);
// Register multiple pipelines
registry.register(ShapePipeline::new(&device, &config, sample_count));
registry.register(TextPipeline::new(&device, &config, sample_count));
§Registration Order
The order of registration can affect performance since pipeline lookup is performed linearly. Consider registering more frequently used pipelines first.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PipelineRegistry
impl !RefUnwindSafe for PipelineRegistry
impl !Send for PipelineRegistry
impl !Sync for PipelineRegistry
impl Unpin for PipelineRegistry
impl !UnwindSafe for PipelineRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.