Module tiny_skia::pipeline

source ·
Expand description

A raster pipeline implementation.

Despite having a lot of changes compared to SkRasterPipeline, the core principles are the same:

  1. A pipeline consists of stages.
  2. A pipeline has a global context shared by all stages. Unlike Skia, were each stage has it’s own, possibly shared, context.
  3. Each stage has a high precision implementation. See highp.rs.
  4. Some stages have a low precision implementation. See lowp.rs.
  5. Each stage calls the “next” stage after its done.
  6. During pipeline “compilation”, if all stages have a lowp implementation, the lowp pipeline will be used. Otherwise, the highp variant will be used.
  7. 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§

Modules§

  • blitter 🔒
  • highp 🔒
    A high precision raster pipeline implementation.
  • lowp 🔒
    A low precision raster pipeline implementation.

Structs§

Enums§

Constants§