mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
refactor redraw to be on-demand
seems to make the performance much better
This commit is contained in:
parent
4f295eea0f
commit
71e45c4bf8
5 changed files with 32 additions and 14 deletions
|
|
@ -41,6 +41,9 @@ pub enum Opcode {
|
|||
// renders a TextView
|
||||
RenderTextView(TextView),
|
||||
|
||||
// forces a redraw (which also does defacement, etc.)
|
||||
Redraw,
|
||||
|
||||
/////// planned
|
||||
|
||||
// returns a GID to the "content" Canvas; requires an authentication token
|
||||
|
|
@ -63,6 +66,7 @@ impl core::convert::TryFrom<&Message> for Opcode {
|
|||
match message {
|
||||
Message::Scalar(m) => match m.id {
|
||||
0 => Ok(Opcode::ClearCanvas(Gid::new([m.arg1 as _, m.arg2 as _, m.arg3 as _, m.arg4 as _]))),
|
||||
1 => Ok(Opcode::Redraw),
|
||||
_ => Err("GAM api: unknown Scalar ID"),
|
||||
},
|
||||
Message::BlockingScalar(m) => match m.id {
|
||||
|
|
@ -80,6 +84,9 @@ impl Into<Message> for Opcode {
|
|||
Opcode::ClearCanvas(gid) => Message::Scalar(ScalarMessage {
|
||||
id: 0, arg1: gid.gid()[0] as _, arg2: gid.gid()[1] as _, arg3: gid.gid()[2] as _, arg4: gid.gid()[3] as _
|
||||
}),
|
||||
Opcode::Redraw => Message::Scalar(ScalarMessage {
|
||||
id: 1, arg1: 0, arg2: 0, arg3: 0, arg4: 0
|
||||
}),
|
||||
Opcode::GetCanvasBounds(gid) => Message::BlockingScalar(ScalarMessage {
|
||||
id: 0, arg1: gid.gid()[0] as _, arg2: gid.gid()[1] as _, arg3: gid.gid()[2] as _, arg4: gid.gid()[3] as _
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ use graphics_server::api::{TextOp, TextView};
|
|||
use graphics_server::api::{Point, Gid, Line, Rectangle, Circle, RoundedRectangle};
|
||||
use log::info;
|
||||
|
||||
pub fn redraw(gam_cid: xous::CID) -> Result<(), xous::Error> {
|
||||
xous::send_message(gam_cid, api::Opcode::Redraw.into()).map(|_|())
|
||||
}
|
||||
|
||||
/// this "posts" a textview -- it's not a "draw" as the update is neither guaranteed nor instantaneous
|
||||
/// the GAM first has to check that the textview is allowed to be updated, and then it will decide when
|
||||
/// the actual screen update is allowed
|
||||
|
|
|
|||
|
|
@ -251,6 +251,20 @@ fn xmain() -> ! {
|
|||
None => info!("GAM: attempt to get bounds on bogus canvas, ignored."),
|
||||
}
|
||||
}
|
||||
Opcode::Redraw => {
|
||||
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
||||
if elapsed_time - last_time > 33 { // rate limit updates, no point in going faster than the eye can see
|
||||
last_time = elapsed_time;
|
||||
|
||||
deface(gfx_conn, &mut canvases);
|
||||
graphics_server::flush(gfx_conn).expect("GAM: couldn't flush buffer to screen");
|
||||
/* // this throws errors right now because deface() doesn't work.
|
||||
for (_, c) in canvases.iter_mut() {
|
||||
c.do_flushed();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => todo!("GAM: opcode not yet implemented"),
|
||||
}
|
||||
} else if let xous::Message::MutableBorrow(m) = &envelope.body {
|
||||
|
|
@ -391,18 +405,7 @@ fn xmain() -> ! {
|
|||
// envelope implements Drop(), which includes a call to syscall::return_memory(self.sender, message.buf)
|
||||
}
|
||||
|
||||
if let Ok(elapsed_time) = ticktimer_server::elapsed_ms(ticktimer_conn) {
|
||||
if elapsed_time - last_time > 33 { // rate limit updates to 30fps
|
||||
last_time = elapsed_time;
|
||||
|
||||
deface(gfx_conn, &mut canvases);
|
||||
graphics_server::flush(gfx_conn).expect("GAM: couldn't flush buffer to screen");
|
||||
/* // this throws errors right now because deface() doesn't work.
|
||||
for (_, c) in canvases.iter_mut() {
|
||||
c.do_flushed();
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
// auto-redraw code used to be here, but I think it's a bad idea....causes more
|
||||
// graphics traffic than necessary? Trying out redraw-on-demand by clients.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
|
|||
}
|
||||
stats_phase = (stats_phase + 1) % 8;
|
||||
gam::post_textview(gam_conn, &mut battstats_tv).expect("GAM|status: can't draw battery stats");
|
||||
gam::redraw(gam_conn);
|
||||
},
|
||||
_ => error!("GAM|status received COM event opcode that wasn't expected"),
|
||||
}
|
||||
|
|
@ -98,6 +99,7 @@ pub fn status_thread(canvas_gid: [u32; 4]) {
|
|||
(elapsed_time / 3_600_000), (elapsed_time / 60_000) % 60, now_seconds).expect("GAM|status: can't write string");
|
||||
if debug1{info!("GAM|status: requesting draw of '{}'", uptime_tv);}
|
||||
gam::post_textview(gam_conn, &mut uptime_tv).expect("GAM|status: can't draw uptime");
|
||||
gam::redraw(gam_conn);
|
||||
}
|
||||
|
||||
if elapsed_time - last_time > 500 {
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ impl InputTracker {
|
|||
}
|
||||
|
||||
pub fn update(&mut self, newkeys: [char; 4]) -> Result<(), xous::Error> {
|
||||
let debug1= true;
|
||||
let debug1= false;
|
||||
let mut update_predictor = false;
|
||||
if let Some(ic) = self.input_canvas {
|
||||
if debug1{info!("IMEF: updating input area");}
|
||||
|
|
@ -557,6 +557,8 @@ impl InputTracker {
|
|||
}
|
||||
}
|
||||
|
||||
gam::redraw(self.gam_conn).expect("IMEF: couldn't redraw screen");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue