mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add a clear, modals & text bounds api calls
the text bounds api call is needed in v2 because there is no gam to mediate this call clear allows for a fast clear operation that may have hardware dependent consequences acquire/release of modals mode is added to the graphics server as well to implement a feature previously handled by the gam
This commit is contained in:
parent
b1ce74faa0
commit
433d632926
1 changed files with 40 additions and 0 deletions
|
|
@ -310,6 +310,31 @@ impl Gfx {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Bounds computation does no checks on security since it's a non-drawing operation. While normal drawing
|
||||
/// always takes the bounds from the canvas, the caller can specify a clip_rect in this tv, instead of
|
||||
/// drawing the clip_rect from the Canvas associated with the tv.
|
||||
pub fn bounds_compute_textview(&self, tv: &mut TextView) -> Result<(), xous::Error> {
|
||||
let mut tv_query = tv.clone();
|
||||
tv_query.set_dry_run(true);
|
||||
let mut buf = Buffer::into_buf(tv_query).or(Err(xous::Error::InternalError))?;
|
||||
buf.lend_mut(self.conn, GfxOpcode::DrawTextView.to_u32().unwrap())
|
||||
.or(Err(xous::Error::InternalError))?;
|
||||
let tvr = buf.to_original::<TextView, _>().unwrap();
|
||||
|
||||
tv.cursor = tvr.cursor;
|
||||
tv.bounds_computed = tvr.bounds_computed;
|
||||
tv.overflow = tvr.overflow;
|
||||
// don't update the animation state when just computing the textview bounds
|
||||
// tv.busy_animation_state = tvr.busy_animation_state;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Clear the screen in a device-optimized fashion. The exact background color depends on the device.
|
||||
pub fn clear(&self) -> Result<(), xous::Error> {
|
||||
send_message(self.conn, Message::new_scalar(GfxOpcode::Clear.to_usize().unwrap(), 0, 0, 0, 0))
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
/// Draws a line with clipping.
|
||||
///
|
||||
/// This function sends a message to the graphics server to draw the specified `Line` within the specified
|
||||
|
|
@ -665,6 +690,21 @@ impl Gfx {
|
|||
.expect("couldn't pop");
|
||||
}
|
||||
}
|
||||
|
||||
/// This will cause the caller to block until it is granted a lock on the modal state.
|
||||
///
|
||||
/// This is a v2-only API. Calling it on a v1 system will cause a panic.
|
||||
pub fn acquire_modal(&self) -> Result<xous::Result, xous::Error> {
|
||||
send_message(
|
||||
self.conn,
|
||||
Message::new_blocking_scalar(GfxOpcode::AcquireModal.to_usize().unwrap(), 0, 0, 0, 0),
|
||||
)
|
||||
}
|
||||
|
||||
/// This is a v2-only API. Calling it on a v1 system will cause a panic.
|
||||
pub fn release_modal(&self) -> Result<xous::Result, xous::Error> {
|
||||
send_message(self.conn, Message::new_scalar(GfxOpcode::ReleaseModal.to_usize().unwrap(), 0, 0, 0, 0))
|
||||
}
|
||||
}
|
||||
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
|
|
|
|||
Loading…
Reference in a new issue