mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-18 12:38:37 +00:00
fixup! feat(core): introduce new drawing library
This commit is contained in:
parent
7105c4caa8
commit
fe2518e4e1
@ -27,6 +27,7 @@ pub type ImageBuffRef<'a> = RefMut<'a, ImageBuff>;
|
|||||||
pub type RenderBuffRef<'a> = RefMut<'a, RenderBuff>;
|
pub type RenderBuffRef<'a> = RefMut<'a, RenderBuff>;
|
||||||
|
|
||||||
pub struct DrawingCache<'a> {
|
pub struct DrawingCache<'a> {
|
||||||
|
image_buff: &'a RefCell<ImageBuff>,
|
||||||
zlib_cache: RefCell<ZlibCache<'a>>,
|
zlib_cache: RefCell<ZlibCache<'a>>,
|
||||||
|
|
||||||
#[cfg(feature = "ui_jpeg_decoder")]
|
#[cfg(feature = "ui_jpeg_decoder")]
|
||||||
@ -37,18 +38,13 @@ pub struct DrawingCache<'a> {
|
|||||||
|
|
||||||
#[cfg(not(feature = "xframebuff"))]
|
#[cfg(not(feature = "xframebuff"))]
|
||||||
render_buff: &'a RefCell<RenderBuff>,
|
render_buff: &'a RefCell<RenderBuff>,
|
||||||
image_buff: &'a RefCell<ImageBuff>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn alloc_buf<'a, const S: usize, B>(bump: &'a B) -> Option<&'a RefCell<[u8; S]>>
|
fn alloc_buf<'a, const S: usize, B>(bump: &'a B) -> Option<&'a RefCell<[u8; S]>>
|
||||||
where
|
where
|
||||||
B: LocalAllocLeakExt<'a>,
|
B: LocalAllocLeakExt<'a>,
|
||||||
{
|
{
|
||||||
Some(
|
Some(bump.alloc_t()?.uninit.init(RefCell::new([0; S])))
|
||||||
bump.alloc_t()?
|
|
||||||
.uninit
|
|
||||||
.init(RefCell::new([0; S])),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DrawingCache<'a> {
|
impl<'a> DrawingCache<'a> {
|
||||||
@ -58,6 +54,7 @@ impl<'a> DrawingCache<'a> {
|
|||||||
TB: LocalAllocLeakExt<'a>,
|
TB: LocalAllocLeakExt<'a>,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
|
image_buff: unwrap!(alloc_buf(bump_b), "Toif buff alloc"),
|
||||||
zlib_cache: RefCell::new(unwrap!(
|
zlib_cache: RefCell::new(unwrap!(
|
||||||
ZlibCache::new(bump_a, ZLIB_CACHE_SLOTS),
|
ZlibCache::new(bump_a, ZLIB_CACHE_SLOTS),
|
||||||
"ZLIB cache alloc"
|
"ZLIB cache alloc"
|
||||||
@ -72,7 +69,6 @@ impl<'a> DrawingCache<'a> {
|
|||||||
|
|
||||||
#[cfg(not(feature = "xframebuff"))]
|
#[cfg(not(feature = "xframebuff"))]
|
||||||
render_buff: unwrap!(alloc_buf(bump_b), "Render buff alloc"),
|
render_buff: unwrap!(alloc_buf(bump_b), "Render buff alloc"),
|
||||||
image_buff: unwrap!(alloc_buf(bump_b), "Toif buff alloc"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user