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