@@ -27,11 +27,12 @@ const RECT_SIZE: u32 = 40;
2727// pub static ref FB: Arc<Display> = Arc::new(Display::new(Size::new(VIRTGPU_XRES as u32, VIRTGPU_YRES as u32), Point::new(INIT_X, INIT_Y)));
2828// }
2929
30- #[ derive( Clone ) ]
30+ // #[derive(Clone)]
3131pub struct Display {
3232 pub size : Size ,
3333 pub point : Point ,
34- pub fb : Arc < & ' static mut [ u8 ] > ,
34+ //pub fb: Arc<&'static mut [u8]>,
35+ pub fb : & ' static mut [ u8 ] ,
3536}
3637
3738impl Display {
@@ -41,9 +42,9 @@ impl Display {
4142 "Hello world from user mode program! 0x{:X} , len {}" ,
4243 fb_ptr as usize , VIRTGPU_LEN
4344 ) ;
44- let fb =
45- unsafe { Arc :: new ( core:: slice:: from_raw_parts_mut ( fb_ptr as * mut u8 , VIRTGPU_LEN as usize ) ) } ;
46-
45+ // let fb =
46+ // unsafe { Arc::new(core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize)) };
47+ let fb= unsafe { core :: slice :: from_raw_parts_mut ( fb_ptr as * mut u8 , VIRTGPU_LEN as usize ) } ;
4748 Self { size, point, fb }
4849 }
4950 // pub fn reset(&self) {
@@ -67,18 +68,19 @@ impl DrawTarget for Display {
6768 where
6869 I : IntoIterator < Item = embedded_graphics:: Pixel < Self :: Color > > ,
6970 {
70- let fb = self . fb . clone ( ) ;
71+ //let fb = self.fb.clone();
72+ //let fb = self.fb;
7173 //let mut arc_data_mut = Arc::make_mut(fb);
7274 pixels. into_iter ( ) . for_each ( |px| {
7375 let idx = ( ( self . point . y + px. 0 . y ) * VIRTGPU_XRES as i32 + self . point . x + px. 0 . x )
7476 as usize
7577 * 4 ;
76- if idx + 2 >= fb. len ( ) {
78+ if idx + 2 >= self . fb . len ( ) {
7779 return ;
7880 }
79- fb[ idx] = px. 1 . b ( ) ;
80- fb[ idx + 1 ] = px. 1 . g ( ) ;
81- fb[ idx + 2 ] = px. 1 . r ( ) ;
81+ self . fb [ idx] = px. 1 . b ( ) ;
82+ self . fb [ idx + 1 ] = px. 1 . g ( ) ;
83+ self . fb [ idx + 2 ] = px. 1 . r ( ) ;
8284 } ) ;
8385 framebuffer_flush ( ) ;
8486 Ok ( ( ) )
0 commit comments