mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
fix defacement ordering
This commit is contained in:
parent
63cf2d3292
commit
e968798fff
2 changed files with 11 additions and 2 deletions
|
|
@ -148,6 +148,7 @@ impl Eq for Canvas {}
|
|||
pub fn deface(gfx: &graphics_server::Gfx, trng: &trng::Trng, canvases: &mut FnvIndexMap<Gid, Canvas, 32>) -> bool {
|
||||
// first check if any need defacing, if not, then we're done
|
||||
let mut needs_defacing = false;
|
||||
let mut defaced = false; // this is set if any drawing actually happens
|
||||
for (_, c) in canvases.iter() {
|
||||
if c.needs_defacing() {
|
||||
needs_defacing = true;
|
||||
|
|
@ -217,6 +218,7 @@ pub fn deface(gfx: &graphics_server::Gfx, trng: &trng::Trng, canvases: &mut FnvI
|
|||
DrawStyle::new(PixelColor::Dark, PixelColor::Dark, 1)),
|
||||
clip_rect).unwrap();
|
||||
}
|
||||
defaced = true;
|
||||
}
|
||||
|
||||
// indicate that the defacement has happened to the canvas state machine
|
||||
|
|
@ -224,7 +226,7 @@ pub fn deface(gfx: &graphics_server::Gfx, trng: &trng::Trng, canvases: &mut FnvI
|
|||
}
|
||||
}
|
||||
}
|
||||
needs_defacing
|
||||
defaced
|
||||
}
|
||||
|
||||
// we use the "screen" parameter to determine when we can turn off drawing to canvases that are off-screen
|
||||
|
|
|
|||
|
|
@ -110,6 +110,8 @@ struct ContextManager {
|
|||
imef_active: bool,
|
||||
kbd: keyboard::Keyboard,
|
||||
main_menu_app_token: Option<[u32; 4]>, // app_token of the main menu, if it has been registered
|
||||
/// for internal generation of deface states
|
||||
pub trng: trng::Trng,
|
||||
}
|
||||
impl ContextManager {
|
||||
pub fn new(xns: &xous_names::XousNames) -> Self {
|
||||
|
|
@ -129,6 +131,7 @@ impl ContextManager {
|
|||
imef_active: false,
|
||||
kbd,
|
||||
main_menu_app_token: None,
|
||||
trng: trng::Trng::new(&xns).expect("couldn't connect to trng"),
|
||||
}
|
||||
}
|
||||
pub(crate) fn claim_token(&mut self, name: &str) -> Option<[u32; 4]> {
|
||||
|
|
@ -428,6 +431,8 @@ impl ContextManager {
|
|||
self.last_context = self.focused_context;
|
||||
self.focused_context = Some(last_token);
|
||||
}
|
||||
// run the defacement before we redraw all the canvases
|
||||
deface(gfx, &self.trng, canvases);
|
||||
self.redraw().expect("couldn't redraw the currently focused app");
|
||||
}
|
||||
}
|
||||
|
|
@ -705,7 +710,9 @@ fn xmain() -> ! {
|
|||
last_time = elapsed_time;
|
||||
|
||||
if deface(&gfx, &trng, &mut canvases) {
|
||||
// redraw the trusted foreground apps after a defacement
|
||||
// we keep this here because it's a fail-safe in case prior routines missed an edge case. shoot out a warning noting the issue.
|
||||
log::warn!("canvases were not defaced in order. running a defacement, but this could result in drawing optimizations failing.");
|
||||
// try to redraw the trusted foreground apps after a defacement
|
||||
context_mgr.redraw().expect("couldn't redraw after defacement");
|
||||
}
|
||||
log::trace!("flushing...");
|
||||
|
|
|
|||
Loading…
Reference in a new issue