add const VIRTGPU_XRES, VIRTGPU_YRES in boards/qemu.rs for X*Y resolution in virtio_gpu
This commit is contained in:
parent
35c4055dd0
commit
eddb2d345d
4 changed files with 13 additions and 7 deletions
|
@ -13,6 +13,9 @@ pub type CharDeviceImpl = crate::drivers::chardev::NS16550a<VIRT_UART>;
|
||||||
pub const VIRT_PLIC: usize = 0xC00_0000;
|
pub const VIRT_PLIC: usize = 0xC00_0000;
|
||||||
pub const VIRT_UART: usize = 0x1000_0000;
|
pub const VIRT_UART: usize = 0x1000_0000;
|
||||||
|
|
||||||
|
pub const VIRTGPU_XRES: u32 = 1280;
|
||||||
|
pub const VIRTGPU_YRES: u32 = 800;
|
||||||
|
|
||||||
use crate::drivers::block::BLOCK_DEVICE;
|
use crate::drivers::block::BLOCK_DEVICE;
|
||||||
use crate::drivers::chardev::{CharDevice, UART};
|
use crate::drivers::chardev::{CharDevice, UART};
|
||||||
use crate::drivers::plic::{IntrTargetPriority, PLIC};
|
use crate::drivers::plic::{IntrTargetPriority, PLIC};
|
||||||
|
|
|
@ -5,7 +5,8 @@ use embedded_graphics::{
|
||||||
prelude::{OriginDimensions, Point, RgbColor, Size},
|
prelude::{OriginDimensions, Point, RgbColor, Size},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::drivers::{GPUDevice, GPU_DEVICE};
|
use crate::drivers::{GPUDevice, GPU_DEVICE,};
|
||||||
|
use crate::board::{VIRTGPU_XRES, VIRTGPU_YRES};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Graphics {
|
pub struct Graphics {
|
||||||
|
@ -42,7 +43,7 @@ impl DrawTarget for Graphics {
|
||||||
let fb = self.drv.getfreambuffer();
|
let fb = self.drv.getfreambuffer();
|
||||||
|
|
||||||
pixels.into_iter().for_each(|px| {
|
pixels.into_iter().for_each(|px| {
|
||||||
let idx = ((self.point.y + px.0.y) * 1280 + self.point.x + px.0.x) as usize * 4;
|
let idx = ((self.point.y + px.0.y) * VIRTGPU_XRES as i32 + self.point.x + px.0.x) as usize * 4;
|
||||||
if idx + 2 >= fb.len() {
|
if idx + 2 >= fb.len() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ use embedded_graphics::{
|
||||||
use tinybmp::Bmp;
|
use tinybmp::Bmp;
|
||||||
|
|
||||||
use crate::{drivers::GPU_DEVICE, sync::UPIntrFreeCell};
|
use crate::{drivers::GPU_DEVICE, sync::UPIntrFreeCell};
|
||||||
|
use crate::board::{VIRTGPU_XRES, VIRTGPU_YRES};
|
||||||
use super::{Component, Graphics, ImageComp};
|
use super::{Component, Graphics, ImageComp};
|
||||||
|
|
||||||
static FILEICON: &[u8] = include_bytes!("../assert/file.bmp");
|
static FILEICON: &[u8] = include_bytes!("../assert/file.bmp");
|
||||||
|
@ -32,7 +32,7 @@ impl IconController {
|
||||||
UPIntrFreeCell::new(IconControllerInner {
|
UPIntrFreeCell::new(IconControllerInner {
|
||||||
files,
|
files,
|
||||||
graphic: Graphics {
|
graphic: Graphics {
|
||||||
size: Size::new(1280, 800),
|
size: Size::new(VIRTGPU_XRES, VIRTGPU_YRES),
|
||||||
point: Point::new(0, 0),
|
point: Point::new(0, 0),
|
||||||
drv: GPU_DEVICE.clone(),
|
drv: GPU_DEVICE.clone(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,11 +10,13 @@ use crate::{
|
||||||
sync::UPIntrFreeCell,
|
sync::UPIntrFreeCell,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::board::{VIRTGPU_XRES, VIRTGPU_YRES};
|
||||||
|
|
||||||
static DT: &[u8] = include_bytes!("../assert/desktop.bmp");
|
static DT: &[u8] = include_bytes!("../assert/desktop.bmp");
|
||||||
|
|
||||||
lazy_static::lazy_static!(
|
lazy_static::lazy_static!(
|
||||||
pub static ref DESKTOP:UPIntrFreeCell<Arc<dyn Component>> = unsafe {
|
pub static ref DESKTOP:UPIntrFreeCell<Arc<dyn Component>> = unsafe {
|
||||||
UPIntrFreeCell::new(Arc::new(Panel::new(Size::new(1280, 800), Point::new(0, 0))))
|
UPIntrFreeCell::new(Arc::new(Panel::new(Size::new(VIRTGPU_XRES, VIRTGPU_YRES), Point::new(0, 0))))
|
||||||
};
|
};
|
||||||
pub static ref PAD:UPIntrFreeCell<Option<Arc<Terminal>>> = unsafe {
|
pub static ref PAD:UPIntrFreeCell<Option<Arc<Terminal>>> = unsafe {
|
||||||
UPIntrFreeCell::new(None)
|
UPIntrFreeCell::new(None)
|
||||||
|
@ -23,8 +25,8 @@ lazy_static::lazy_static!(
|
||||||
|
|
||||||
pub fn create_desktop() -> isize {
|
pub fn create_desktop() -> isize {
|
||||||
let mut p: Arc<dyn Component + 'static> =
|
let mut p: Arc<dyn Component + 'static> =
|
||||||
Arc::new(Panel::new(Size::new(1280, 800), Point::new(0, 0)));
|
Arc::new(Panel::new(Size::new(VIRTGPU_XRES, VIRTGPU_YRES), Point::new(0, 0)));
|
||||||
let image = ImageComp::new(Size::new(1280, 800), Point::new(0, 0), DT, Some(p.clone()));
|
let image = ImageComp::new(Size::new(VIRTGPU_XRES, VIRTGPU_YRES), Point::new(0, 0), DT, Some(p.clone()));
|
||||||
let icon = IconController::new(ROOT_INODE.ls(), Some(p.clone()));
|
let icon = IconController::new(ROOT_INODE.ls(), Some(p.clone()));
|
||||||
p.add(Arc::new(image));
|
p.add(Arc::new(image));
|
||||||
p.add(Arc::new(icon));
|
p.add(Arc::new(icon));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue