hayro_interpret/
device.rs

1use crate::Paint;
2use crate::StrokeProps;
3use crate::font::Glyph;
4use crate::soft_mask::SoftMask;
5use crate::{ClipPath, FillRule};
6use crate::{LumaData, RgbData};
7use kurbo::{Affine, BezPath};
8
9/// A trait for a device that can be used to process PDF drawing instructions.
10pub trait Device<'a> {
11    /// Stroke a path.
12    fn stroke_path(
13        &mut self,
14        path: &BezPath,
15        transform: Affine,
16        paint: &Paint<'a>,
17        stroke_props: &StrokeProps,
18    );
19    /// Set the properties for future stroking operations.
20    /// Set a soft mask to be used for future drawing instructions.
21    fn set_soft_mask(&mut self, mask: Option<SoftMask<'a>>);
22    /// Fill a path.
23    fn fill_path(
24        &mut self,
25        path: &BezPath,
26        transform: Affine,
27        paint: &Paint<'a>,
28        fill_rule: FillRule,
29    );
30    /// Push a new clip path to the clip stack.
31    fn push_clip_path(&mut self, clip_path: &ClipPath);
32    /// Push a new transparency group to the blend stack.
33    fn push_transparency_group(&mut self, opacity: f32, mask: Option<SoftMask<'a>>);
34    /// Fill a glyph.
35    fn fill_glyph(
36        &mut self,
37        glyph: &Glyph<'a>,
38        transform: Affine,
39        glyph_transform: Affine,
40        paint: &Paint<'a>,
41    );
42    /// Stroke a glyph.
43    fn stroke_glyph(
44        &mut self,
45        glyph: &Glyph<'a>,
46        transform: Affine,
47        glyph_transform: Affine,
48        paint: &Paint<'a>,
49        stroke_props: &StrokeProps,
50    );
51    /// Draw an RGBA image.
52    fn draw_rgba_image(&mut self, image: RgbData, transform: Affine, alpha: Option<LumaData>);
53    /// Draw a stencil image with the given paint.
54    fn draw_stencil_image(&mut self, stencil: LumaData, transform: Affine, paint: &Paint<'a>);
55    /// Pop the last clip path from the clip stack.
56    fn pop_clip_path(&mut self);
57    /// Pop the last transparency group from the blend stack.
58    fn pop_transparency_group(&mut self);
59}