From e0f93141b8327dcdf990393154884426fe171713 Mon Sep 17 00:00:00 2001 From: cepetr Date: Thu, 2 May 2024 19:35:44 +0200 Subject: [PATCH] fixup! feat(core): introduce new drawing library --- core/embed/rust/src/trezorhal/bitblt.rs | 4 ++-- core/embed/rust/src/ui/shape/cache/zlib_cache.rs | 5 +++++ core/embed/rust/src/ui/shape/display/nofb_rgb565.rs | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/embed/rust/src/trezorhal/bitblt.rs b/core/embed/rust/src/trezorhal/bitblt.rs index a474bf2ad..8d8828fd8 100644 --- a/core/embed/rust/src/trezorhal/bitblt.rs +++ b/core/embed/rust/src/trezorhal/bitblt.rs @@ -190,8 +190,8 @@ pub struct BitBltCopy<'a> { } impl<'a> BitBltCopy<'a> { - /// Prepares `BitBltCopy` structure for copying or blending a part of the source - /// bitmap to the destination bitmap or display. + /// Prepares `BitBltCopy` structure for copying or blending a part of the + /// source bitmap to the destination bitmap or display. /// /// - `r` is the rectangle in the destination bitmap. /// - `clip` is the clipping rectangle and must be completely inside the diff --git a/core/embed/rust/src/ui/shape/cache/zlib_cache.rs b/core/embed/rust/src/ui/shape/cache/zlib_cache.rs index 68332fa89..7311034cf 100644 --- a/core/embed/rust/src/ui/shape/cache/zlib_cache.rs +++ b/core/embed/rust/src/ui/shape/cache/zlib_cache.rs @@ -118,11 +118,16 @@ impl<'a> ZlibCache<'a> { fn select_slot_for_reuse(&self) -> Result { if self.slots.capacity() > 0 { + // Try to find a free slot. If there's no free slot, + // select the one that performed the least amount of work + // based on the offset in the uncompressed data. let mut selected = 0; for (i, slot) in self.slots.iter().enumerate() { if slot.dc.is_none() { selected = i; break; + } else if slot.offset < self.slots[selected].offset { + selected = i; } } Ok(selected) diff --git a/core/embed/rust/src/ui/shape/display/nofb_rgb565.rs b/core/embed/rust/src/ui/shape/display/nofb_rgb565.rs index 5039ce144..43a8c4f6a 100644 --- a/core/embed/rust/src/ui/shape/display/nofb_rgb565.rs +++ b/core/embed/rust/src/ui/shape/display/nofb_rgb565.rs @@ -1,4 +1,7 @@ -use crate::trezorhal::{bitblt::{BitBltCopy, BitBltFill}, display}; +use crate::trezorhal::{ + bitblt::{BitBltCopy, BitBltFill}, + display, +}; use crate::ui::{ display::Color,