forked from AbleOS/ableos_userland
add back buffer support to agl
This commit is contained in:
parent
7881ee2881
commit
9239fe7f9e
|
@ -7,6 +7,8 @@ use embedded_graphics::{
|
|||
|
||||
pub struct Display {
|
||||
pub fb: *mut u32,
|
||||
// Back buffer
|
||||
pub bb: *mut u32,
|
||||
pub size: Size,
|
||||
pub color: Rgb888,
|
||||
}
|
||||
|
@ -15,6 +17,15 @@ impl Display {
|
|||
pub fn set_color(&mut self, color: Rgb888) {
|
||||
self.color = color;
|
||||
}
|
||||
pub fn swap_buffers(&mut self) {
|
||||
let size: usize = (self.size.height * self.size.width).try_into().unwrap();
|
||||
|
||||
unsafe {
|
||||
let dst_ptr = self.fb;
|
||||
let src_ptr = self.bb;
|
||||
core::ptr::copy_nonoverlapping(src_ptr, dst_ptr, size);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn line(
|
||||
&mut self,
|
||||
|
@ -53,7 +64,7 @@ impl DrawTarget for Display {
|
|||
return Err(BlitOutOfBoundsError);
|
||||
}
|
||||
|
||||
self.fb
|
||||
self.bb
|
||||
.add(
|
||||
(pos_y * self.size.width + pos_x)
|
||||
.try_into()
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Type Coordinate = i32;
|
||||
Type Coordinates = (Coordinate, Coordinate);
|
||||
|
||||
|
||||
Function line Takes(Coordinates, Coordinates) Returns(Nothing);
|
Loading…
Reference in a new issue