clean os/user codes for graph show
This commit is contained in:
parent
f2635c2dba
commit
2dfd195841
6 changed files with 7 additions and 224 deletions
|
@ -8,7 +8,6 @@ extern crate user_lib;
|
|||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::sync::Arc;
|
||||
use embedded_graphics::pixelcolor::Rgb888;
|
||||
use embedded_graphics::prelude::{Drawable, Point, RgbColor, Size};
|
||||
use embedded_graphics::primitives::Primitive;
|
||||
|
@ -23,11 +22,6 @@ const INIT_X: i32 = 640;
|
|||
const INIT_Y: i32 = 400;
|
||||
const RECT_SIZE: u32 = 40;
|
||||
|
||||
// lazy_static::lazy_static! {
|
||||
// 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)));
|
||||
// }
|
||||
|
||||
//#[derive(Clone)]
|
||||
pub struct Display {
|
||||
pub size: Size,
|
||||
pub point: Point,
|
||||
|
@ -42,15 +36,10 @@ impl Display {
|
|||
"Hello world from user mode program! 0x{:X} , len {}",
|
||||
fb_ptr as usize, VIRTGPU_LEN
|
||||
);
|
||||
// let fb =
|
||||
// unsafe { Arc::new(core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize)) };
|
||||
let fb= unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize) };
|
||||
let fb =
|
||||
unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize) };
|
||||
Self { size, point, fb }
|
||||
}
|
||||
// pub fn reset(&self) {
|
||||
// let fb = self.drv.get_framebuffer();
|
||||
// fb.fill(0u8);
|
||||
// }
|
||||
}
|
||||
|
||||
impl OriginDimensions for Display {
|
||||
|
@ -68,9 +57,6 @@ impl DrawTarget for Display {
|
|||
where
|
||||
I: IntoIterator<Item = embedded_graphics::Pixel<Self::Color>>,
|
||||
{
|
||||
//let fb = self.fb.clone();
|
||||
//let fb = self.fb;
|
||||
//let mut arc_data_mut = Arc::make_mut(fb);
|
||||
pixels.into_iter().for_each(|px| {
|
||||
let idx = ((self.point.y + px.0.y) * VIRTGPU_XRES as i32 + self.point.x + px.0.x)
|
||||
as usize
|
||||
|
@ -117,59 +103,16 @@ impl DrawingBoard {
|
|||
self.latest_pos.y += dy;
|
||||
self.paint();
|
||||
}
|
||||
|
||||
// pub fn reset(&mut self) {
|
||||
// self.latest_pos = Point::new(INIT_X, INIT_Y);
|
||||
// self.disp.reset();
|
||||
// }
|
||||
}
|
||||
|
||||
// lazy_static! {
|
||||
// pub static ref DRAWING_BOARD: UPIntrFreeCell<DrawingBoard> =
|
||||
// unsafe { UPIntrFreeCell::new(DrawingBoard::new()) };
|
||||
// }
|
||||
|
||||
// pub fn init_paint() {
|
||||
// DRAWING_BOARD.exclusive_session(|ripple| {
|
||||
// ripple.paint();
|
||||
// });
|
||||
// }
|
||||
|
||||
// pub fn move_rect(dx: i32, dy: i32) {
|
||||
// DRAWING_BOARD.exclusive_session(|ripple| {
|
||||
// ripple.move_rect(dx, dy);
|
||||
// });
|
||||
// }
|
||||
|
||||
// pub fn reset() {
|
||||
// DRAWING_BOARD.exclusive_session(|ripple| {
|
||||
// ripple.reset();
|
||||
// });
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub fn main() -> i32 {
|
||||
// let fb_ptr = framebuffer() as *mut u8;
|
||||
let mut board=DrawingBoard::new();
|
||||
board.paint();
|
||||
for i in 0..100 {
|
||||
let mut board = DrawingBoard::new();
|
||||
for i in 0..20 {
|
||||
board.latest_pos.x += i;
|
||||
board.latest_pos.y += i;
|
||||
board.paint();
|
||||
board.paint();
|
||||
}
|
||||
// println!(
|
||||
// "Hello world from user mode program! 0x{:X} , len {}",
|
||||
// fb_ptr as usize, VIRTGPU_LEN
|
||||
// );
|
||||
// let fb = unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize) };
|
||||
// for y in 0..800 {
|
||||
// for x in 0..1280 {
|
||||
// let idx = (y * 1280 + x) * 4;
|
||||
// fb[idx] = x as u8;
|
||||
// fb[idx + 1] = y as u8;
|
||||
// fb[idx + 2] = (x + y) as u8;
|
||||
// }
|
||||
// }
|
||||
// framebuffer_flush();
|
||||
0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue