graphics: Move Damage from inputd to graphics-ipc

This commit is contained in:
bjorn3
2024-12-28 16:26:18 +01:00
parent 7b11acbc46
commit 5fc04c332d
15 changed files with 47 additions and 44 deletions
Generated
+4 -2
View File
@@ -326,7 +326,7 @@ dependencies = [
name = "console-draw"
version = "0.1.0"
dependencies = [
"inputd",
"graphics-ipc",
"orbclient",
"ransid",
]
@@ -401,6 +401,7 @@ name = "driver-graphics"
version = "0.1.0"
dependencies = [
"common",
"graphics-ipc",
"inputd",
"libredox",
"log",
@@ -609,7 +610,6 @@ name = "graphics-ipc"
version = "0.1.0"
dependencies = [
"common",
"inputd",
"libredox",
"log",
]
@@ -1725,6 +1725,7 @@ version = "0.1.0"
dependencies = [
"common",
"driver-graphics",
"graphics-ipc",
"inputd",
"libredox",
"orbclient",
@@ -1780,6 +1781,7 @@ dependencies = [
"common",
"driver-graphics",
"futures",
"graphics-ipc",
"inputd",
"libredox",
"log",
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2021"
orbclient = "0.3.27"
ransid = "0.4"
inputd = { path = "../../inputd" }
graphics-ipc = { path = "../graphics-ipc" }
[features]
default = []
+1 -1
View File
@@ -4,7 +4,7 @@ use std::collections::{BTreeSet, VecDeque};
use std::convert::{TryFrom, TryInto};
use std::{cmp, ptr};
use inputd::Damage;
use graphics_ipc::legacy::Damage;
use orbclient::FONT;
pub struct DisplayMap {
+1
View File
@@ -10,4 +10,5 @@ redox_syscall = "0.5"
libredox = "0.1.3"
common = { path = "../../common" }
graphics-ipc = { path = "../graphics-ipc" }
inputd = { path = "../../inputd" }
+2 -1
View File
@@ -1,7 +1,8 @@
use std::collections::{BTreeMap, HashMap};
use std::io;
use inputd::{Damage, VtEvent, VtEventKind};
use graphics_ipc::legacy::Damage;
use inputd::{VtEvent, VtEventKind};
use libredox::errno::EOPNOTSUPP;
use libredox::Fd;
use redox_scheme::{RequestKind, Response, Scheme, SignalBehavior, Socket};
+2 -2
View File
@@ -1,6 +1,6 @@
use event::{user_data, EventQueue};
use graphics_ipc::legacy::LegacyGraphicsHandle;
use inputd::{ConsumerHandle, Damage};
use graphics_ipc::legacy::{Damage, LegacyGraphicsHandle};
use inputd::ConsumerHandle;
use libredox::errno::ESTALE;
use orbclient::Event;
use std::mem;
+2 -2
View File
@@ -1,5 +1,5 @@
use graphics_ipc::legacy::{DisplayMap, LegacyGraphicsHandle};
use inputd::{ConsumerHandle, Damage};
use graphics_ipc::legacy::{Damage, DisplayMap, LegacyGraphicsHandle};
use inputd::ConsumerHandle;
use std::io;
pub struct Display {
-1
View File
@@ -8,4 +8,3 @@ log = "0.4"
libredox = "0.1.3"
common = { path = "../../common" }
inputd = { path = "../../inputd" }
+27 -2
View File
@@ -1,8 +1,7 @@
use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::{io, mem, ptr, slice};
use std::{cmp, io, mem, ptr, slice};
use inputd::Damage;
use libredox::flag;
/// A graphics handle using the legacy graphics API.
@@ -110,3 +109,29 @@ impl Drop for DisplayMap {
}
}
}
// Keep synced with orbital's SyncRect
#[derive(Debug, Copy, Clone)]
#[repr(packed)]
pub struct Damage {
pub x: i32,
pub y: i32,
pub width: i32,
pub height: i32,
}
impl Damage {
#[must_use]
pub fn clip(mut self, width: i32, height: i32) -> Self {
// Clip damage
self.x = cmp::min(self.x, width);
if self.x + self.width > width {
self.width -= cmp::min(self.width, width - self.x);
}
self.y = cmp::min(self.y, height);
if self.y + self.height > height {
self.height = cmp::min(self.height, height - self.y);
}
self
}
}
+1
View File
@@ -12,6 +12,7 @@ redox_event = "0.4.1"
common = { path = "../../common" }
driver-graphics = { path = "../driver-graphics" }
graphics-ipc = { path = "../graphics-ipc" }
inputd = { path = "../../inputd" }
libredox = "0.1.3"
+2 -1
View File
@@ -1,4 +1,5 @@
use driver_graphics::GraphicsAdapter;
use graphics_ipc::legacy::Damage;
use crate::{framebuffer::FrameBuffer, screen::GraphicScreen};
@@ -36,7 +37,7 @@ impl GraphicsAdapter for FbAdapter {
&mut self,
display_id: usize,
resource: &Self::Resource,
damage: Option<&[inputd::Damage]>,
damage: Option<&[Damage]>,
) {
if let Some(damage) = damage {
resource.sync(&mut self.framebuffers[display_id], damage)
+1 -1
View File
@@ -3,7 +3,7 @@ use std::convert::TryInto;
use std::ptr::{self, NonNull};
use driver_graphics::Resource;
use inputd::Damage;
use graphics_ipc::legacy::Damage;
use syscall::PAGE_SIZE;
use crate::framebuffer::FrameBuffer;
+1
View File
@@ -12,6 +12,7 @@ anyhow = "1.0.71"
common = { path = "../../common" }
driver-graphics = { path = "../driver-graphics" }
graphics-ipc = { path = "../graphics-ipc" }
virtio-core = { path = "../../virtio-core" }
pcid = { path = "../../pcid" }
inputd = { path = "../../inputd" }
+2 -1
View File
@@ -2,7 +2,8 @@ use std::sync::Arc;
use common::{dma::Dma, sgl};
use driver_graphics::{GraphicsAdapter, GraphicsScheme, Resource};
use inputd::{Damage, DisplayHandle};
use graphics_ipc::legacy::Damage;
use inputd::DisplayHandle;
use syscall::PAGE_SIZE;
-29
View File
@@ -1,6 +1,3 @@
#![feature(iter_next_chunk)]
use std::cmp;
use std::fs::{File, OpenOptions};
use std::io::{Error, Read, Write};
use std::mem::size_of;
@@ -137,32 +134,6 @@ pub struct VtEvent {
pub stride: u32,
}
// Keep synced with orbital's SyncRect
#[derive(Debug, Copy, Clone)]
#[repr(packed)]
pub struct Damage {
pub x: i32,
pub y: i32,
pub width: i32,
pub height: i32,
}
impl Damage {
#[must_use]
pub fn clip(mut self, width: i32, height: i32) -> Self {
// Clip damage
self.x = cmp::min(self.x, width);
if self.x + self.width > width {
self.width -= cmp::min(self.width, width - self.x);
}
self.y = cmp::min(self.y, height);
if self.y + self.height > height {
self.height = cmp::min(self.height, height - self.y);
}
self
}
}
pub struct ProducerHandle(File);
impl ProducerHandle {