vello_cpu/dispatch/
mod.rs

1// Copyright 2025 the Vello Authors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3
4#[cfg(feature = "multithreading")]
5pub(crate) mod multi_threaded;
6pub(crate) mod single_threaded;
7
8use crate::RenderMode;
9use crate::kurbo::{Affine, BezPath, Stroke};
10use crate::peniko::{BlendMode, Fill};
11use core::fmt::Debug;
12use vello_common::coarse::Wide;
13use vello_common::encode::EncodedPaint;
14use vello_common::mask::Mask;
15use vello_common::paint::Paint;
16use vello_common::strip::Strip;
17use vello_common::strip_generator::StripStorage;
18
19pub(crate) trait Dispatcher: Debug + Send + Sync {
20    fn wide(&self) -> &Wide;
21    fn generate_wide_cmd(&mut self, strip_buf: &[Strip], paint: Paint);
22    fn fill_path(
23        &mut self,
24        path: &BezPath,
25        fill_rule: Fill,
26        transform: Affine,
27        paint: Paint,
28        aliasing_threshold: Option<u8>,
29    );
30    fn stroke_path(
31        &mut self,
32        path: &BezPath,
33        stroke: &Stroke,
34        transform: Affine,
35        paint: Paint,
36        aliasing_threshold: Option<u8>,
37    );
38    fn push_layer(
39        &mut self,
40        clip_path: Option<&BezPath>,
41        fill_rule: Fill,
42        clip_transform: Affine,
43        blend_mode: BlendMode,
44        opacity: f32,
45        aliasing_threshold: Option<u8>,
46        mask: Option<Mask>,
47    );
48    fn pop_layer(&mut self);
49    fn reset(&mut self);
50    fn flush(&mut self);
51    fn rasterize(
52        &self,
53        buffer: &mut [u8],
54        render_mode: RenderMode,
55        width: u16,
56        height: u16,
57        encoded_paints: &[EncodedPaint],
58    );
59    fn strip_storage_mut(&mut self) -> &mut StripStorage;
60}