Skip to main content

PatchedKitty

Struct PatchedKitty 

Source
pub struct PatchedKitty { /* private fields */ }
Expand description

The patched kitty surface presenter: transmits the whole surface once, then per frame retransmits only the tiles whose pixels changed, each as its own small image under a stable tile id, placed over the base. The kitty protocol has no in-place pixel update (retransmitting an id replaces the image and its placements), so a tile id is simply retransmitted and its placement replaced without flicker. A frame with more damaged tiles than the patch budget, a resize, or anything that loses the base image falls back to one whole retransmit. An unchanged frame writes nothing.

The default tile side is cell.width * cell.height pixels, a multiple of both cell axes, so every tile maps to whole cells and patch edges never tear.

Implementations§

Source§

impl PatchedKitty

Source

pub fn new(base: u32, cell: CellPixels) -> Self

A presenter for surfaces drawn at cell pixel resolution, handing out image ids from base upward, tiling at the cell-derived side with the sprite-friendly budget of 64 tiles.

Source

pub fn with_tiles( base: u32, cell: CellPixels, tile_side: u32, budget: usize, ) -> Self

A presenter with an explicit tile_side in surface pixels and budget, the damaged-tile count past which one whole retransmit wins. Fine-grained surfaces want small tiles and a high budget; the tile’s cell span always follows the surface-to-area scale.

Source

pub fn with_stash(self, stash: Box<dyn Stash>) -> Self

Send pixels through stash, for a terminal on this machine that reads them from there.

Source

pub fn set_cell(&mut self, cell: CellPixels)

Draw placeholder tiles for cells of cell pixels from now on, after a font zoom changed them.

Source

pub fn repaint(&mut self)

Send every pixel again on the next frame, for when the terminal may have lost what it was showing.

Source

pub fn free<W: Sink>(&mut self, out: &mut W) -> Result<()>

Free every image this presenter sent and repaint on the next frame.

Source

pub fn for_multiplexer(self, space: IdSpace, relative_placements: bool) -> Self

Send every frame as small tiles for a multiplexer, which drops uploads bigger than it buffers and hides placeholder text with its pane. With relative_placements every tile sits on one placeholder anchor and stretches to its cells; without, each tile shows through placeholder text of its own, which keeps its aspect and so needs the true cell size.

Source

pub fn render_frame<W: Sink>( &mut self, out: &mut W, surface: &Surface, area: CellRect, ) -> Result<usize>

Write one frame into area cells and return the bytes written.

Trait Implementations§

Source§

impl Debug for PatchedKitty

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.