From 5f05e1510504d143da43a06755e8dc4041051ab5 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 13 Jun 2024 22:05:20 +0800 Subject: [PATCH] add backing storage this is used to accelerate menu foreground/background as well as susres --- .../graphics-server/src/backend/cramium.rs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/services/graphics-server/src/backend/cramium.rs b/services/graphics-server/src/backend/cramium.rs index f80686ba5..e3b1b65da 100644 --- a/services/graphics-server/src/backend/cramium.rs +++ b/services/graphics-server/src/backend/cramium.rs @@ -92,6 +92,7 @@ pub fn claim_main_thread(f: impl FnOnce(MainThreadToken) -> Never + Send + 'stat pub struct XousDisplay { fb: [u32; FB_SIZE], + srfb: [u32; FB_SIZE], next_free_line: usize, spim: udma::Spim, devboot: bool, @@ -219,8 +220,13 @@ impl XousDisplay { .expect("Couldn't allocate SPI channel for LCD") }; - let mut display = - XousDisplay { fb: [0xFFFF_FFFFu32; FB_SIZE], spim, next_free_line: 0, devboot: false }; + let mut display = XousDisplay { + fb: [0xFFFF_FFFFu32; FB_SIZE], + srfb: [0xFFFF_FFFFu32; FB_SIZE], + spim, + next_free_line: 0, + devboot: false, + }; // initialize the DMA buffer with valid mode/address lines & blank data for line in 0..FB_LINES { @@ -263,11 +269,19 @@ impl XousDisplay { } pub fn stash(&mut self) { - unimplemented!("Cramium platform does not yet support suspend/resume"); + self.srfb.copy_from_slice(&self.fb); + + for lines in 0..FB_LINES { + // set the dirty bits prior to stashing the frame buffer + self.srfb[lines * FB_WIDTH_WORDS + (FB_WIDTH_WORDS - 1)] |= 0x1_0000; + } } pub fn pop(&mut self) { - unimplemented!("Cramium platform does not yet support suspend/resume"); + // skip copying the status bar, so that the status info is not overwritten by the pop. + // this is "fixed" at 34 pixels high (2 * Tall glyph height hint) per line 79 in gam/src/main.rs + self.fb[FB_WIDTH_WORDS * 34..FB_SIZE].copy_from_slice(&self.srfb[FB_WIDTH_WORDS * 34..FB_SIZE]); + self.redraw(); } #[allow(dead_code)]