From d2ef03b7e28f931d9087a2537ce49901abb07f13 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 11 Mar 2021 22:32:05 +0800 Subject: [PATCH] intermediate commit to try and lock in a bug --- Cargo.lock | 17 +++++++++++++++++ services/gam/src/canvas.rs | 12 ++++++------ services/gam/src/main.rs | 7 +++++-- services/gam/src/status.rs | 2 +- services/graphics-server/src/api/text.rs | 11 ++++++----- services/ime-frontend/src/main.rs | 9 ++++++--- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93ab1095c..ed21811f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,6 +261,15 @@ dependencies = [ "com_rs", ] +[[package]] +name = "compiler_builtins" +version = "0.1.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3748f82c7d366a0b4950257d19db685d4958d2fa27c6d164a3f069fec42b748b" +dependencies = [ + "rustc-std-workspace-core", +] + [[package]] name = "content-plugin-api" version = "0.1.0" @@ -1028,6 +1037,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-std-workspace-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1956f5517128a2b6f23ab2dadf1a976f4f5b27962e7724c2bf3d45e539ec098c" + [[package]] name = "ryu" version = "1.0.5" @@ -1539,10 +1554,12 @@ name = "xous" version = "0.1.2" dependencies = [ "bitflags", + "compiler_builtins", "hex", "lazy_static", "log", "rkyv", + "rustc-std-workspace-core", "xous-macros", ] diff --git a/services/gam/src/canvas.rs b/services/gam/src/canvas.rs index c379bc629..fa6994a5f 100644 --- a/services/gam/src/canvas.rs +++ b/services/gam/src/canvas.rs @@ -22,21 +22,21 @@ pub enum CanvasState { /// A rectangular region that defines a top-left zero relative offset for graphical items /// and a bottom-right point that defines a clipping area for things drawn inside. #[derive(Debug, Copy, Clone)] -#[repr(C)] pub struct Canvas { + // unique, random identifier for the Canvas + gid: Gid, + // screen coordinates of the clipping region clip_rect: Rectangle, // trust level, 255 is most trusted trust_level: u8, - state: CanvasState, - - // unique, random identifier for the Canvas - gid: Gid, - // enables scroll/pan of objects within a region pan_offset: Point, + + // track the drawing state of the canvas + state: CanvasState, } #[allow(dead_code)] diff --git a/services/gam/src/main.rs b/services/gam/src/main.rs index 6f81163d4..6488dcb5e 100644 --- a/services/gam/src/main.rs +++ b/services/gam/src/main.rs @@ -25,6 +25,7 @@ use heapless::consts::*; use rkyv::{Unarchive, archived_value, archived_value_mut}; use core::pin::Pin; +#[derive(Debug)] // GIDs of canvases that are used the "Chat" layout. struct ChatLayout { // a set of GIDs to track the elements of the chat layout @@ -178,6 +179,7 @@ impl ModalCanvases { #[xous::xous_main] fn xmain() -> ! { let debug1 = false; // debug level 1 - most general level + let debugc = false; log_server::init_wait().unwrap(); info!("GAM: my PID is {}", xous::process::id()); @@ -194,7 +196,7 @@ fn xmain() -> ! { // a map of canvases accessable by Gid let mut canvases: FnvIndexMap = FnvIndexMap::new(); - let modallayout = ModalCanvases::init(trng_conn, &mut canvases).expect("GAM: can't add modal layouts"); + // let modallayout = ModalCanvases::init(trng_conn, &mut canvases).expect("GAM: can't add modal layouts"); let mut chatlayout = ChatLayout::init(gfx_conn, trng_conn, &mut canvases).expect("GAM: couldn't create chat layout"); chatlayout.clear(&mut canvases).expect("GAM: couldn't clear initial chatlayout"); @@ -217,6 +219,7 @@ fn xmain() -> ! { // no content canvas initially, but keep a placeholder for one let mut ccc: ContentCanvasConnection = ContentCanvasConnection{connection: None}; + if debugc{info!("GAM: chatlayout made st {:?} co {:?} pr {:?} in {:?}", chatlayout.status, chatlayout.content, chatlayout.predictive, chatlayout.input);} // make a thread to manage the status bar -- this needs to start after the IMEF is initialized // the status bar is a trusted element managed by the OS, and we are chosing to domicile this in the GAM process for now xous::create_thread_simple(status_thread, chatlayout.status.gid()).expect("GAM: couldn't create status thread"); @@ -327,7 +330,7 @@ fn xmain() -> ! { info!("GAM: attempt to draw TextView on non-drawable canvas. Not fatal, but request ignored."); } } else { - info!("GAM: bogus GID in TextView, not doing anything in response to draw request."); + info!("GAM: bogus GID {:?} in TextView {}, not doing anything in response to draw request.", tv.get_canvas_gid(), tv.text); // silently fail if a bogus Gid is given??? } }, diff --git a/services/gam/src/status.rs b/services/gam/src/status.rs index 6ad8ff169..d3ad58935 100644 --- a/services/gam/src/status.rs +++ b/services/gam/src/status.rs @@ -15,9 +15,9 @@ pub fn status_thread(canvas_gid: [u32; 4]) { if debug1{info!("GAM|status: registering GAM|status thread");} let status_sid = xous_names::register_name(xous::names::SERVER_NAME_STATUS).expect("GAM|status: can't register server"); + let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("GAM|status: can't connect to GAM"); let ticktimer_conn = xous::connect(xous::SID::from_bytes(b"ticktimer-server").unwrap()).unwrap(); let com_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_COM).expect("GAM|status: can't connect to COM"); - let gam_conn = xous_names::request_connection_blocking(xous::names::SERVER_NAME_GAM).expect("GAM|status: can't connect to GAM"); if debug1{info!("GAM|status: getting screen size");} let screensize = gam::get_canvas_bounds(gam_conn, status_gid).expect("GAM|status: Couldn't get canvas size"); diff --git a/services/graphics-server/src/api/text.rs b/services/graphics-server/src/api/text.rs index 6f77e2697..9e812561e 100644 --- a/services/graphics-server/src/api/text.rs +++ b/services/graphics-server/src/api/text.rs @@ -46,6 +46,9 @@ const TEXTVIEW_LEN: usize = 3072; #[derive(Copy, Clone, rkyv::Archive, rkyv::Unarchive)] pub struct TextView { + canvas: Gid, // GID of the canvas to draw on + pub clip_rect: Option, // this is set by the GAM to the canvas' clip_rect; needed by gfx for drawing. Note this is in screen coordinates. + // this is the operation as specified for the GAM. Note this is different from the "op" when sent to graphics-server // only the GAM should be sending TextViews to the graphics-server, and a different coding scheme is used for that link. operation: TextOp, @@ -62,7 +65,6 @@ pub struct TextView { pub dry_run: bool, // set to true if no drawing is desired and we just want to compute the bounds pub style: GlyphStyle, - pub text: xous::String::<3072>, pub cursor: Cursor, pub insertion: Option, // this is the insertion point offset, if it's to be drawn, on the string pub ellipsis: bool, @@ -76,12 +78,12 @@ pub struct TextView { // this field specifies the beginning and end of a "selected" region of text pub selected: Option<[u32; 2]>, - canvas: Gid, // GID of the canvas to draw on - pub clip_rect: Option, // this is set by the GAM to the canvas' clip_rect; needed by gfx for drawing. Note this is in screen coordinates. + pub text: xous::String::<3072>, } impl TextView { pub fn new(canvas: Gid, bounds_hint: TextBounds) -> Self { TextView { + canvas, operation: TextOp::Nop, untrusted: true, token: None, @@ -99,7 +101,6 @@ impl TextView { rounded_border: None, margin: Point { x: 4, y: 4 }, selected: None, - canvas, clear_area: true, overflow: None, dry_run: false, @@ -116,6 +117,7 @@ impl TextView { pub fn clear_str(&mut self) { self.text.clear() } pub fn populate_from(&mut self, t: &TextView) { + self.canvas = t.canvas; self.operation = t.operation; self.untrusted = t.untrusted; self.token = t.token; @@ -131,7 +133,6 @@ impl TextView { self.rounded_border = t.rounded_border; self.margin = t.margin; self.selected = t.selected; - self.canvas = t.canvas; self.overflow = t.overflow; self.clip_rect = t.clip_rect; self.dry_run = t.dry_run; diff --git a/services/ime-frontend/src/main.rs b/services/ime-frontend/src/main.rs index 4fa00804e..615d3f111 100644 --- a/services/ime-frontend/src/main.rs +++ b/services/ime-frontend/src/main.rs @@ -523,6 +523,7 @@ impl InputTracker { } } + let debug_canvas = false; if valid_predictions == 0 { let mut empty_tv = TextView::new(pc, TextBounds::BoundingBox(Rectangle::new(Point::new(0, 1), pc_bounds))); @@ -530,6 +531,7 @@ impl InputTracker { empty_tv.border_width = 1; empty_tv.clear_area = true; write!(empty_tv.text, "Ready for input...").expect("IMEF: couldn't set up empty TextView"); + if debug_canvas { info!("IMEF: pc canvas {:?}", pc) } gam::post_textview(self.gam_conn, &mut empty_tv).expect("IMEF: can't draw prediction TextView"); } else if update_predictor { // alright, first, let's clear the area @@ -578,7 +580,8 @@ impl InputTracker { #[xous::xous_main] fn xmain() -> ! { let debug1 = false; - let dbglistener = true; + let dbglistener = false; + let dbgcanvas = false; log_server::init_wait().unwrap(); info!("IMEF: my PID is {}", xous::process::id()); @@ -601,11 +604,11 @@ fn xmain() -> ! { if let Ok(opcode) = ImefOpcode::try_from(&envelope.body) { match opcode { ImefOpcode::SetInputCanvas(g) => { - if debug1{info!("IMEF: got input canvas {:?}", g);} + if debug1 || dbgcanvas {info!("IMEF: got input canvas {:?}", g);} tracker.set_input_canvas(g); }, ImefOpcode::SetPredictionCanvas(g) => { - if debug1{info!("IMEF: got prediction canvas {:?}", g);} + if debug1 || dbgcanvas {info!("IMEF: got prediction canvas {:?}", g);} tracker.set_pred_canvas(g); }, _ => info!("IMEF: expected canvas Gid, but got {:?}", opcode)