Skip to main content

felis_render_core/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use felis_protocol::{ImageId, messages::ImageFormat};
4
5pub mod appearance;
6pub mod atlas;
7#[cfg(feature = "glyphs")]
8pub mod box_drawing;
9pub mod display_list;
10#[cfg(feature = "glyphs")]
11pub mod glyphs;
12pub mod overlay;
13#[cfg(feature = "glyphs")]
14pub mod painter;
15pub mod palette;
16
17/// `start` / `end` are normalized by the client: row-major min/max for
18/// a linear selection, axis-aligned bounding box for a rectangle.
19#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub struct SelectionRange {
21    pub start: (u16, u16),
22    pub end: (u16, u16),
23    pub rectangle: bool,
24}
25
26/// `pixels.len()` equals `width * height * bytes_per_pixel(format)`;
27/// the daemon dispatcher enforces it.
28#[derive(Debug, Clone, Copy)]
29pub struct ImageData<'a> {
30    pub width: u32,
31    pub height: u32,
32    pub format: ImageFormat,
33    pub pixels: &'a [u8],
34}
35
36/// Supplies image pixels for GPU atlas re-uploads when the atlas recycles itself.
37///
38/// Images are held in `felis_client_core::ImageShadow`. Returns `None` if pixels have not
39/// fully arrived or were deleted, in which case placements paint nothing.
40pub trait ImageSource {
41    fn image_data(&self, id: ImageId) -> Option<ImageData<'_>>;
42}