mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
trim out some excess redraw calls that are slowing down boot
This commit is contained in:
parent
a7c9027d05
commit
fd5c6568d1
14 changed files with 60 additions and 40 deletions
|
|
@ -142,6 +142,7 @@ impl Ball {
|
|||
self.ball.style = DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 1);
|
||||
draw_list.push(GamObjectType::Circ(self.ball)).unwrap();
|
||||
self.gam.draw_list(draw_list).expect("couldn't execute draw list");
|
||||
log::trace!("ball app redraw##");
|
||||
self.gam.redraw().unwrap();
|
||||
}
|
||||
pub(crate) fn focus(&mut self) {
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ impl Repl{
|
|||
break; // we get None on the bounds computed if the text view fell off the top of the screen
|
||||
}
|
||||
}
|
||||
log::trace!("repl app redraw##");
|
||||
self.gam.redraw().expect("couldn't redraw screen");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,6 +341,10 @@ fn xmain() -> ! {
|
|||
info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
// reset the EC so we're in sync at boot on state
|
||||
let llio = llio::Llio::new(&xns);
|
||||
llio.ec_reset().unwrap();
|
||||
|
||||
// unlimited connections allowed -- any server is currently allowed to talk to COM. This might need to be revisited.
|
||||
let com_sid = xns.register_name(api::SERVER_NAME_COM, None).expect("can't register server");
|
||||
trace!("registered with NS -- {:?}", com_sid);
|
||||
|
|
@ -349,24 +353,22 @@ fn xmain() -> ! {
|
|||
let mut com = XousCom::new();
|
||||
let ticktimer = ticktimer_server::Ticktimer::new().unwrap();
|
||||
|
||||
// reset the EC so we're in sync at boot on state
|
||||
let llio = llio::Llio::new(&xns);
|
||||
llio.ec_reset().unwrap();
|
||||
ticktimer.sleep_ms(250).unwrap();
|
||||
#[cfg(not(any(windows, unix)))] // avoid errors in hosted mode
|
||||
{
|
||||
ticktimer.sleep_ms(100).unwrap(); // give the EC a moment to de-chatter
|
||||
let mut attempts = 0;
|
||||
let ping_value = 0xaeedu16; // for various reasons, this is a string that is "unlikely" to happen randomly
|
||||
loop {
|
||||
com.txrx(ComState::LINK_PING.verb);
|
||||
com.txrx(ping_value);
|
||||
let pong = com.wait_txrx(ComState::LINK_READ.verb, Some(5000)); // this should "stall" until the EC comes out of reset
|
||||
let phase = com.wait_txrx(ComState::LINK_READ.verb, Some(500));
|
||||
let pong = com.wait_txrx(ComState::LINK_READ.verb, Some(150)); // this should "stall" until the EC comes out of reset
|
||||
let phase = com.wait_txrx(ComState::LINK_READ.verb, Some(150));
|
||||
if pong == !ping_value &&
|
||||
phase == 0x600d { // 0x600d is a hard-coded constant. It's included to confirm that we aren't "wedged" just sending one value back at us
|
||||
log::info!("EC rebooting: link established");
|
||||
break;
|
||||
} else {
|
||||
log::warn!("Wf200 reset: establishing link sync, attempt {} [{:04x}/{:04x}]", attempts, pong, phase);
|
||||
log::info!("EC rebooting: establishing link sync, attempt {} [{:04x}/{:04x}]", attempts, pong, phase);
|
||||
com.txrx(ComState::LINK_SYNC.verb);
|
||||
ticktimer.sleep_ms(200).unwrap();
|
||||
attempts += 1;
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ fn remap_rand(end_range: i32, rand: i16, source_range: i32) -> i16 {
|
|||
}
|
||||
|
||||
// we use the "screen" parameter to determine when we can turn off drawing to canvases that are off-screen
|
||||
pub fn recompute_canvases(canvases: &HashMap<Gid, Canvas>, screen: Rectangle) -> HashMap<Gid, Canvas> {
|
||||
pub(crate) fn recompute_canvases(canvases: &HashMap<Gid, Canvas>, screen: Rectangle) -> HashMap<Gid, Canvas> {
|
||||
let debug = false; // keep this around, it's really convenient for turning off just this specific subset of debug messages
|
||||
// first, sort canvases by trust_level. Canvas implements ord/eq based on the trust_level attribute
|
||||
// so jush pushing it into a max binary heap does the trick.
|
||||
|
|
|
|||
|
|
@ -435,9 +435,10 @@ impl ContextManager {
|
|||
self.last_context = self.focused_context;
|
||||
self.focused_context = Some(last_token);
|
||||
}
|
||||
log::trace!("defacing old canvases prior to redraw");
|
||||
// run the defacement before we redraw all the canvases
|
||||
deface(gfx, &self.trng, canvases);
|
||||
if deface(gfx, &self.trng, canvases) {
|
||||
log::info!("activate triggered a defacement");
|
||||
}
|
||||
log::trace!("activate redraw");
|
||||
self.redraw().expect("couldn't redraw the currently focused app");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,8 +281,9 @@ fn xmain() -> ! {
|
|||
// recompute the canvas orders based on the new layout
|
||||
let recomp_canvases = recompute_canvases(&canvases, Rectangle::new(Point::new(0, 0), screensize));
|
||||
canvases = recomp_canvases;
|
||||
log::trace!("canvas bounds redraw");
|
||||
context_mgr.redraw().expect("can't redraw after new canvas bounds");
|
||||
// this set of redraw commands is not needed because every context will call redraw after it has finished fitting its bounds
|
||||
// log::info!("canvas bounds redraw");
|
||||
// context_mgr.redraw().expect("can't redraw after new canvas bounds");
|
||||
}
|
||||
cb.granted = granted;
|
||||
let ret = api::Return::SetCanvasBoundsReturn(cb);
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ impl<'a> Menu<'a> {
|
|||
self.draw_divider(cur_index as _);
|
||||
}
|
||||
}
|
||||
log::trace!("menu redraw##");
|
||||
self.gam.redraw().unwrap();
|
||||
}
|
||||
fn num_items(&self) -> usize {
|
||||
|
|
@ -297,6 +298,7 @@ impl<'a> Menu<'a> {
|
|||
}
|
||||
}
|
||||
self.index = 0; // reset the index to 0
|
||||
log::trace!("menu redraw## select key");
|
||||
self.gam.redraw().unwrap();
|
||||
break; // drop any characters that happened to trail the select key, it's probably a fat-finger error.
|
||||
},
|
||||
|
|
@ -310,10 +312,12 @@ impl<'a> Menu<'a> {
|
|||
}
|
||||
'↑' => {
|
||||
self.prev_item();
|
||||
log::trace!("menu redraw## up key");
|
||||
self.gam.redraw().unwrap();
|
||||
}
|
||||
'↓' => {
|
||||
self.next_item();
|
||||
log::trace!("menu redraw## down key");
|
||||
self.gam.redraw().unwrap();
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -440,6 +440,7 @@ impl<'a> Modal<'a> {
|
|||
self.bot_dirty = false;
|
||||
}
|
||||
log::trace!("total height: {}", cur_height);
|
||||
log::trace!("modal redraw##");
|
||||
self.gam.redraw().unwrap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,6 @@ impl XousDisplay {
|
|||
}
|
||||
|
||||
pub fn redraw(&mut self) {
|
||||
log::info!("**update**");
|
||||
let mut busy_count = 0;
|
||||
let mut dirty_count = 0;
|
||||
while self.busy() {
|
||||
|
|
|
|||
|
|
@ -350,6 +350,7 @@ fn xmain() -> ! {
|
|||
buffer.replace(tv).unwrap();
|
||||
}
|
||||
Some(Opcode::Flush) => {
|
||||
log::trace!("***gfx flush*** redraw##");
|
||||
display.update();
|
||||
display.redraw();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,6 +600,7 @@ impl InputTracker {
|
|||
}
|
||||
}
|
||||
|
||||
log::trace!("imef: redraw##");
|
||||
self.gam.redraw().expect("couldn't redraw screen");
|
||||
|
||||
Ok(retstring)
|
||||
|
|
|
|||
|
|
@ -460,28 +460,25 @@ fn xmain() -> ! {
|
|||
}
|
||||
});
|
||||
// our menu handler
|
||||
let my_cid = xous::connect(pddb_sid).unwrap();
|
||||
let _ = thread::spawn({
|
||||
let my_cid = xous::connect(pddb_sid).unwrap();
|
||||
let my_cid = my_cid.clone();
|
||||
move || {
|
||||
pddb_menu(my_cid);
|
||||
}
|
||||
});
|
||||
// try to mount the PDDB automatically before starting the server
|
||||
#[cfg(not(any(windows, unix)))] // avoid errors in hosted mode
|
||||
let tt = ticktimer_server::Ticktimer::new().unwrap();
|
||||
#[cfg(not(any(windows, unix)))] // skip this step if running in hosted mode, for now...
|
||||
if pddb_os.rootkeys_initialized() {
|
||||
tt.sleep_ms(6000).unwrap(); // wait after boot before attempting to mount, to let the boot screen finish redrawing (cosmetic issue).
|
||||
match ensure_password(&modals, &mut pddb_os) {
|
||||
PasswordState::Correct => {
|
||||
try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Correct);
|
||||
},
|
||||
PasswordState::Uninit => {
|
||||
try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Uninit);
|
||||
},
|
||||
_ => (), // continue without mounting if the user opts out
|
||||
// spawn a delayed mount command, shortly after boot. There's too much going on at boot, and it blocks other things from coming up.
|
||||
#[cfg(not(any(windows, unix)))] // skip this step if running in hosted mode
|
||||
let _ = thread::spawn({
|
||||
let my_cid = my_cid.clone();
|
||||
move || {
|
||||
let tt = ticktimer_server::Ticktimer::new().unwrap();
|
||||
tt.sleep_ms(5000).unwrap(); // wait after boot before attempting to mount, to let the boot screen finish redrawing
|
||||
send_message(my_cid,
|
||||
Message::new_blocking_scalar(Opcode::TryMount.to_usize().unwrap(), 0, 0, 0, 0)
|
||||
).expect("couldn't send mount request");
|
||||
}
|
||||
}
|
||||
});
|
||||
// main server loop
|
||||
let mut key_list = Vec::<String>::new(); // storage for key lists
|
||||
let mut key_token: Option<[u32; 4]> = None;
|
||||
|
|
@ -489,9 +486,8 @@ fn xmain() -> ! {
|
|||
let mut dict_token: Option<[u32; 4]> = None;
|
||||
|
||||
// register a suspend/resume listener
|
||||
let sr_cid = xous::connect(pddb_sid).expect("couldn't create suspend callback connection");
|
||||
let mut susres = susres::Susres::new(Some(susres::SuspendOrder::Early), &xns,
|
||||
Opcode::SuspendResume as u32, sr_cid).expect("couldn't create suspend/resume object");
|
||||
Opcode::SuspendResume as u32, my_cid).expect("couldn't create suspend/resume object");
|
||||
loop {
|
||||
let mut msg = xous::receive_message(pddb_sid).unwrap();
|
||||
match FromPrimitive::from_usize(msg.body.id()) {
|
||||
|
|
@ -514,14 +510,23 @@ fn xmain() -> ! {
|
|||
// can't mount if we have no root keys
|
||||
xous::return_scalar(msg.sender, 0).expect("could't return scalar");
|
||||
} else {
|
||||
if ensure_password(&modals, &mut pddb_os) == PasswordState::Correct {
|
||||
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Correct) {
|
||||
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
||||
} else {
|
||||
xous::return_scalar(msg.sender, 0).expect("couldn't return scalar");
|
||||
}
|
||||
} else {
|
||||
xous::return_scalar(msg.sender, 0).expect("couldn't return scalar");
|
||||
match ensure_password(&modals, &mut pddb_os) {
|
||||
PasswordState::Correct => {
|
||||
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Correct) {
|
||||
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
||||
} else {
|
||||
xous::return_scalar(msg.sender, 0).expect("couldn't return scalar");
|
||||
}
|
||||
},
|
||||
PasswordState::Uninit => {
|
||||
if try_mount_or_format(&modals, &mut pddb_os, &mut basis_cache, PasswordState::Uninit) {
|
||||
xous::return_scalar(msg.sender, 1).expect("couldn't return scalar");
|
||||
} else {
|
||||
xous::return_scalar(msg.sender, 0).expect("couldn't return scalar");
|
||||
}
|
||||
},
|
||||
// user aborted procedure
|
||||
_ => xous::return_scalar(msg.sender, 0).expect("couldn't return scalar"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ impl Repl{
|
|||
break; // we get None on the bounds computed if the text view fell off the top of the screen
|
||||
}
|
||||
}
|
||||
log::trace!("shellchat redraw##");
|
||||
self.gam.redraw().expect("couldn't redraw screen");
|
||||
// self.gam.request_ime_redraw().expect("couldn't redraw the IME area");
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub fn pump_thread(conn: usize, pump_run: Arc<AtomicBool>) {
|
|||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Debug);
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
log::info!("my PID is {}", xous::process::id());
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
|
|
@ -259,6 +259,7 @@ fn xmain() -> ! {
|
|||
gam.draw_line(status_gid, Line::new_with_style(
|
||||
Point::new(0, screensize.y), screensize,
|
||||
DrawStyle::new(PixelColor::Light, PixelColor::Light, 1))).unwrap();
|
||||
log::trace!("status redraw## initial");
|
||||
gam.redraw().unwrap(); // initial boot redraw
|
||||
|
||||
let sec_notes = Arc::new(Mutex::new(HashMap::new()));
|
||||
|
|
@ -575,6 +576,7 @@ fn xmain() -> ! {
|
|||
gam.post_textview(&mut uptime_tv)
|
||||
.expect("|status: can't draw uptime");
|
||||
}
|
||||
log::trace!("status redraw## update");
|
||||
gam.redraw().expect("|status: couldn't redraw");
|
||||
|
||||
stats_phase = stats_phase.wrapping_add(1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue