@@ -310,6 +310,31 @@ impl Gfx {
310
310
Ok ( ( ) )
311
311
}
312
312
313
+ /// Bounds computation does no checks on security since it's a non-drawing operation. While normal drawing
314
+ /// always takes the bounds from the canvas, the caller can specify a clip_rect in this tv, instead of
315
+ /// drawing the clip_rect from the Canvas associated with the tv.
316
+ pub fn bounds_compute_textview ( & self , tv : & mut TextView ) -> Result < ( ) , xous:: Error > {
317
+ let mut tv_query = tv. clone ( ) ;
318
+ tv_query. set_dry_run ( true ) ;
319
+ let mut buf = Buffer :: into_buf ( tv_query) . or ( Err ( xous:: Error :: InternalError ) ) ?;
320
+ buf. lend_mut ( self . conn , GfxOpcode :: DrawTextView . to_u32 ( ) . unwrap ( ) )
321
+ . or ( Err ( xous:: Error :: InternalError ) ) ?;
322
+ let tvr = buf. to_original :: < TextView , _ > ( ) . unwrap ( ) ;
323
+
324
+ tv. cursor = tvr. cursor ;
325
+ tv. bounds_computed = tvr. bounds_computed ;
326
+ tv. overflow = tvr. overflow ;
327
+ // don't update the animation state when just computing the textview bounds
328
+ // tv.busy_animation_state = tvr.busy_animation_state;
329
+ Ok ( ( ) )
330
+ }
331
+
332
+ /// Clear the screen in a device-optimized fashion. The exact background color depends on the device.
333
+ pub fn clear ( & self ) -> Result < ( ) , xous:: Error > {
334
+ send_message ( self . conn , Message :: new_scalar ( GfxOpcode :: Clear . to_usize ( ) . unwrap ( ) , 0 , 0 , 0 , 0 ) )
335
+ . map ( |_| ( ) )
336
+ }
337
+
313
338
/// Draws a line with clipping.
314
339
///
315
340
/// This function sends a message to the graphics server to draw the specified `Line` within the specified
@@ -665,6 +690,33 @@ impl Gfx {
665
690
. expect ( "couldn't pop" ) ;
666
691
}
667
692
}
693
+
694
+ /// This will cause the caller to block until it is granted a lock on the modal state.
695
+ ///
696
+ /// This is a v2-only API. Calling it on a v1 system will cause a panic.
697
+ pub fn acquire_modal ( & self ) -> Result < xous:: Result , xous:: Error > {
698
+ send_message (
699
+ self . conn ,
700
+ Message :: new_blocking_scalar ( GfxOpcode :: AcquireModal . to_usize ( ) . unwrap ( ) , 0 , 0 , 0 , 0 ) ,
701
+ )
702
+ }
703
+
704
+ /// This is a v2-only API. Calling it on a v1 system will cause a panic.
705
+ pub fn release_modal ( & self ) -> Result < xous:: Result , xous:: Error > {
706
+ send_message ( self . conn , Message :: new_scalar ( GfxOpcode :: ReleaseModal . to_usize ( ) . unwrap ( ) , 0 , 0 , 0 , 0 ) )
707
+ }
708
+
709
+ /// V2-only API
710
+ pub fn draw_object_list ( & self , list : ObjectList ) -> Result < ( ) , xous:: Error > {
711
+ let buf = match Buffer :: into_buf ( list) {
712
+ Ok ( b) => b,
713
+ Err ( e) => {
714
+ log:: error!( "err: {:?}" , e) ;
715
+ panic ! ( "error" )
716
+ }
717
+ } ;
718
+ buf. lend ( self . conn , GfxOpcode :: UnclippedObjectList . to_u32 ( ) . unwrap ( ) ) . map ( |_| ( ) )
719
+ }
668
720
}
669
721
670
722
use core:: sync:: atomic:: { AtomicU32 , Ordering } ;
0 commit comments