1use crate::font::Glyph;
2use crate::soft_mask::SoftMask;
3use crate::{BlendMode, ClipPath, Image};
4use crate::{GlyphDrawMode, Paint, PathDrawMode};
5use kurbo::{Affine, BezPath, Rect, Shape};
6
7pub trait Device<'a> {
9 fn set_soft_mask(&mut self, mask: Option<SoftMask<'a>>);
12 fn set_blend_mode(&mut self, blend_mode: BlendMode);
14 fn draw_path(
16 &mut self,
17 path: &BezPath,
18 transform: Affine,
19 paint: &Paint<'a>,
20 draw_mode: &PathDrawMode,
21 );
22 fn push_clip_path(&mut self, clip_path: &ClipPath);
24 fn push_transparency_group(
26 &mut self,
27 opacity: f32,
28 mask: Option<SoftMask<'a>>,
29 blend_mode: BlendMode,
30 );
31 fn draw_glyph(
33 &mut self,
34 glyph: &Glyph<'a>,
35 transform: Affine,
36 glyph_transform: Affine,
37 paint: &Paint<'a>,
38 draw_mode: &GlyphDrawMode,
40 );
41 fn draw_image(&mut self, image: Image<'a, '_>, transform: Affine);
43 fn pop_clip_path(&mut self);
45 fn pop_transparency_group(&mut self);
47 fn draw_rect(
49 &mut self,
50 rect: &Rect,
51 transform: Affine,
52 paint: &Paint<'a>,
53 draw_mode: &PathDrawMode,
54 ) {
55 self.draw_path(&rect.to_path(0.1), transform, paint, draw_mode);
56 }
57 fn begin_marked_content(&mut self, _tag: &[u8], _mcid: Option<i32>) {}
62 fn end_marked_content(&mut self) {}
64 fn text_adjustment(&mut self, _amount: f32) {}
72}
73
74pub struct DummyDevice;
76
77impl Device<'_> for DummyDevice {
78 fn set_soft_mask(&mut self, _: Option<SoftMask<'_>>) {}
79 fn set_blend_mode(&mut self, _: BlendMode) {}
80 fn draw_path(&mut self, _: &BezPath, _: Affine, _: &Paint<'_>, _: &PathDrawMode) {}
81 fn push_clip_path(&mut self, _: &ClipPath) {}
82 fn push_transparency_group(&mut self, _: f32, _: Option<SoftMask<'_>>, _: BlendMode) {}
83 fn draw_glyph(
84 &mut self,
85 _: &Glyph<'_>,
86 _: Affine,
87 _: Affine,
88 _: &Paint<'_>,
89 _: &GlyphDrawMode,
90 ) {
91 }
92 fn draw_image(&mut self, _: Image<'_, '_>, _: Affine) {}
93 fn pop_clip_path(&mut self) {}
94 fn pop_transparency_group(&mut self) {}
95}