1 use imgref::ImgVec;
2 use rgb::RGBA8;
3 
4 use std::fmt;
5 
6 /// A terminal frame
7 #[derive(Clone)]
8 pub(crate) struct TerminalFrame {
9     /// The index of the frame in the animation
10     pub index: u64,
11     /// The time the frame occurrs in the animation timeline
12     pub time: f32,
13     /// The terminal screen state at this frame
14     pub screen: vt100::Screen,
15 }
16 
17 impl fmt::Debug for TerminalFrame {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result18     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19         f.debug_struct("Frame")
20             .field("index", &self.index)
21             .field("time", &self.time)
22             .field("screen", &"...")
23             .finish()
24     }
25 }
26 
27 /// An SVG render of a terminal frame
28 #[derive(Clone)]
29 pub(crate) struct SvgFrame {
30     /// The index of the frame in the animation
31     pub index: u64,
32     /// The time the frame occurrs in the animation timeline
33     pub time: f32,
34     /// The SVG for the frame
35     pub doc: svg::Document,
36     /// The height of the SVG document in pixels
37     pub height: u16,
38     /// The width of the SVG document in pixels
39     pub width: u16,
40 }
41 
42 impl fmt::Debug for SvgFrame {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result43     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
44         f.debug_struct("Frame")
45             .field("index", &self.index)
46             .field("time", &self.time)
47             .field("doc", &"...")
48             .field("height", &self.height)
49             .field("width", &self.width)
50             .finish()
51     }
52 }
53 
54 /// An SVG render of a terminal frame
55 #[derive(Clone)]
56 pub(crate) struct RgbaFrame {
57     /// The index of the frame in the animation
58     pub index: u64,
59     /// The time the frame occurrs in the animation timeline
60     pub time: f32,
61     /// The RGBA image for the frame
62     pub image: ImgVec<RGBA8>,
63 }
64 
65 impl fmt::Debug for RgbaFrame {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result66     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
67         f.debug_struct("Frame")
68             .field("index", &self.index)
69             .field("time", &self.time)
70             .field("image", &"...")
71             .finish()
72     }
73 }
74 
75 /// The progress of a cast render job
76 #[derive(Default, Debug, Clone)]
77 pub struct CastRenderProgress {
78     /// The total number of frames to render
79     pub count: u64,
80     /// The progress of the terminal frame rasterization
81     pub raster_progress: u64,
82     /// The progress of the video sequencing
83     pub sequence_progress: u64,
84 }
85 
86 /// This types is used as a "command" to the progress thread to increment the progress
87 #[derive(Clone, Debug)]
88 #[allow(clippy::enum_variant_names)]
89 pub(crate) enum ProgressCmd {
90     IncrementCount,
91     IncrementRasterProgress,
92     IncrementSequenceProgress,
93 }
94 
95 /// The trait for a progress handler
96 pub trait CastProgressHandler: Send {
update_progress(&mut self, progress: &CastRenderProgress)97     fn update_progress(&mut self, progress: &CastRenderProgress);
98 }
99 
100 pub struct NullProgressHandler;
101 
102 impl CastProgressHandler for NullProgressHandler {
update_progress(&mut self, _progress: &CastRenderProgress)103     fn update_progress(&mut self, _progress: &CastRenderProgress) {}
104 }
105