@@ -8,7 +8,6 @@ extern crate user_lib;
88
99extern crate alloc;
1010
11- use alloc:: sync:: Arc ;
1211use embedded_graphics:: pixelcolor:: Rgb888 ;
1312use embedded_graphics:: prelude:: { Drawable , Point , RgbColor , Size } ;
1413use embedded_graphics:: primitives:: Primitive ;
@@ -23,11 +22,6 @@ const INIT_X: i32 = 640;
2322const INIT_Y : i32 = 400 ;
2423const RECT_SIZE : u32 = 40 ;
2524
26- // lazy_static::lazy_static! {
27- // 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)));
28- // }
29-
30- //#[derive(Clone)]
3125pub struct Display {
3226 pub size : Size ,
3327 pub point : Point ,
@@ -42,15 +36,10 @@ impl Display {
4236 "Hello world from user mode program! 0x{:X} , len {}" ,
4337 fb_ptr as usize , VIRTGPU_LEN
4438 ) ;
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 ) } ;
39+ let fb =
40+ unsafe { core:: slice:: from_raw_parts_mut ( fb_ptr as * mut u8 , VIRTGPU_LEN as usize ) } ;
4841 Self { size, point, fb }
4942 }
50- // pub fn reset(&self) {
51- // let fb = self.drv.get_framebuffer();
52- // fb.fill(0u8);
53- // }
5443}
5544
5645impl OriginDimensions for Display {
@@ -68,9 +57,6 @@ impl DrawTarget for Display {
6857 where
6958 I : IntoIterator < Item = embedded_graphics:: Pixel < Self :: Color > > ,
7059 {
71- //let fb = self.fb.clone();
72- //let fb = self.fb;
73- //let mut arc_data_mut = Arc::make_mut(fb);
7460 pixels. into_iter ( ) . for_each ( |px| {
7561 let idx = ( ( self . point . y + px. 0 . y ) * VIRTGPU_XRES as i32 + self . point . x + px. 0 . x )
7662 as usize
@@ -117,59 +103,16 @@ impl DrawingBoard {
117103 self . latest_pos . y += dy;
118104 self . paint ( ) ;
119105 }
120-
121- // pub fn reset(&mut self) {
122- // self.latest_pos = Point::new(INIT_X, INIT_Y);
123- // self.disp.reset();
124- // }
125106}
126107
127- // lazy_static! {
128- // pub static ref DRAWING_BOARD: UPIntrFreeCell<DrawingBoard> =
129- // unsafe { UPIntrFreeCell::new(DrawingBoard::new()) };
130- // }
131-
132- // pub fn init_paint() {
133- // DRAWING_BOARD.exclusive_session(|ripple| {
134- // ripple.paint();
135- // });
136- // }
137-
138- // pub fn move_rect(dx: i32, dy: i32) {
139- // DRAWING_BOARD.exclusive_session(|ripple| {
140- // ripple.move_rect(dx, dy);
141- // });
142- // }
143-
144- // pub fn reset() {
145- // DRAWING_BOARD.exclusive_session(|ripple| {
146- // ripple.reset();
147- // });
148- // }
149-
150108#[ no_mangle]
151109pub fn main ( ) -> i32 {
152110 // let fb_ptr = framebuffer() as *mut u8;
153- let mut board=DrawingBoard :: new ( ) ;
154- board. paint ( ) ;
155- for i in 0 ..100 {
111+ let mut board = DrawingBoard :: new ( ) ;
112+ for i in 0 ..20 {
156113 board. latest_pos . x += i;
157114 board. latest_pos . y += i;
158- board. paint ( ) ;
115+ board. paint ( ) ;
159116 }
160- // println!(
161- // "Hello world from user mode program! 0x{:X} , len {}",
162- // fb_ptr as usize, VIRTGPU_LEN
163- // );
164- // let fb = unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize) };
165- // for y in 0..800 {
166- // for x in 0..1280 {
167- // let idx = (y * 1280 + x) * 4;
168- // fb[idx] = x as u8;
169- // fb[idx + 1] = y as u8;
170- // fb[idx + 2] = (x + y) as u8;
171- // }
172- // }
173- // framebuffer_flush();
174117 0
175118}
0 commit comments