Expand description
A raster pipeline implementation.
Despite having a lot of changes compared to SkRasterPipeline
,
the core principles are the same:
- A pipeline consists of stages.
- A pipeline has a global context shared by all stages. Unlike Skia, were each stage has it’s own, possibly shared, context.
- Each stage has a high precision implementation. See
highp.rs
. - Some stages have a low precision implementation. See
lowp.rs
. - Each stage calls the “next” stage after its done.
- During pipeline “compilation”, if all stages have a lowp implementation, the lowp pipeline will be used. Otherwise, the highp variant will be used.
- The pipeline “compilation” produces a list of function pointer. The last pointer is a pointer to the “return” function, which simply stops the execution of the pipeline.
This implementation is a bit tricky, but it gives the maximum performance. A simple and straightforward implementation using traits and loops, like:
ⓘ
trait StageTrait {
fn apply(&mut self, pixels: &mut [Pixel]);
}
let stages: Vec<&mut dyn StageTrait>;
for stage in stages {
stage.apply(pixels);
}
will be at least 20-30% slower. Not really sure why.
Also, since this module is all about performance, any kind of branching is
strictly forbidden. All stage functions must not use if
, match
or loops.
There are still some exceptions, which are basically an imperfect implementations
and should be optimized out in the future.
Re-exports§
pub use blitter::RasterPipelineBlitter;
Modules§
- blitter 🔒
- highp 🔒A high precision raster pipeline implementation.
- lowp 🔒A low precision raster pipeline implementation.