1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use embedded_graphics::primitives::Rectangle;
use crate::{TouchEvent, UiCanvas};
/// Drawing backend provided by an OEM target or simulator.
pub trait DisplayPort {
/// Canvas type used for drawing frames.
type Canvas: UiCanvas;
/// Backend-specific drawing error.
type Error;
/// Returns the drawable bounds of the target surface.
fn bounds(&self) -> Rectangle;
/// Draws a full frame.
fn draw_frame<F>(&mut self, draw: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self::Canvas);
/// Draws only the specified dirty area.
///
/// The default implementation falls back to [`Self::draw_frame`].
fn draw_dirty<F>(&mut self, dirty: Rectangle, draw: F) -> Result<(), Self::Error>
where
F: FnOnce(&mut Self::Canvas),
{
let _ = dirty;
self.draw_frame(draw)
}
}
/// Low-level touch polling source.
pub trait TouchPort {
/// Backend-specific touch error.
type Error;
/// Polls the next touch sample for the given time.
fn poll_touch(&mut self, now_ms: u32) -> Result<Option<TouchEvent>, Self::Error>;
}
/// Monotonic clock abstraction.
pub trait FrameClock {
/// Returns the current time in milliseconds.
fn now_ms(&self) -> u32;
}