metal: allow configuring framebuffer formats
This commit is contained in:
parent
9bab4f7ce1
commit
b4ca15fec0
24 changed files with 713 additions and 58 deletions
|
|
@ -70,7 +70,7 @@ impl Global for JayCompositorGlobal {
|
|||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
7
|
||||
8
|
||||
}
|
||||
|
||||
fn required_caps(&self) -> ClientCaps {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use {
|
|||
backend,
|
||||
client::{Client, ClientError},
|
||||
compositor::MAX_EXTENTS,
|
||||
format::named_formats,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
scale::Scale,
|
||||
|
|
@ -27,6 +28,7 @@ pub struct JayRandr {
|
|||
|
||||
const VRR_CAPABLE_SINCE: Version = Version(2);
|
||||
const TEARING_SINCE: Version = Version(3);
|
||||
const FORMAT_SINCE: Version = Version(8);
|
||||
|
||||
impl JayRandr {
|
||||
pub fn new(id: JayRandrId, client: &Rc<Client>, version: Version) -> Self {
|
||||
|
|
@ -125,6 +127,23 @@ impl JayRandr {
|
|||
mode: node.global.persistent.tearing_mode.get().to_config().0,
|
||||
});
|
||||
}
|
||||
if self.version >= FORMAT_SINCE {
|
||||
let current = node.global.format.get();
|
||||
self.client.event(FbFormat {
|
||||
self_id: self.id,
|
||||
name: current.name,
|
||||
current: 1,
|
||||
});
|
||||
for &format in &*node.global.formats.get() {
|
||||
if format != current {
|
||||
self.client.event(FbFormat {
|
||||
self_id: self.id,
|
||||
name: format.name,
|
||||
current: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
let current_mode = global.mode.get();
|
||||
for mode in &global.modes {
|
||||
self.client.event(Mode {
|
||||
|
|
@ -365,6 +384,17 @@ impl JayRandrRequestHandler for JayRandr {
|
|||
c.update_presentation_type();
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
fn set_fb_format(&self, req: SetFbFormat<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let Some(&format) = named_formats().get(req.format) else {
|
||||
return Err(JayRandrError::UnknownFormat(req.format.to_string()));
|
||||
};
|
||||
let Some(c) = self.get_output_node(req.output) else {
|
||||
return Ok(());
|
||||
};
|
||||
c.global.connector.connector.set_fb_format(format);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -384,5 +414,7 @@ pub enum JayRandrError {
|
|||
UnknownVrrMode(u32),
|
||||
#[error("Unknown tearing mode {0}")]
|
||||
UnknownTearingMode(u32),
|
||||
#[error("Unknown format {0}")]
|
||||
UnknownFormat(String),
|
||||
}
|
||||
efrom!(JayRandrError, ClientError);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use {
|
|||
crate::{
|
||||
backend,
|
||||
client::{Client, ClientError, ClientId},
|
||||
format::{Format, XRGB8888},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::{wl_surface::WlSurface, zxdg_output_v1::ZxdgOutputV1},
|
||||
leaks::Tracker,
|
||||
|
|
@ -57,6 +58,8 @@ pub struct WlOutputGlobal {
|
|||
pub output_id: Rc<OutputId>,
|
||||
pub mode: Cell<backend::Mode>,
|
||||
pub modes: Vec<backend::Mode>,
|
||||
pub formats: CloneCell<Rc<Vec<&'static Format>>>,
|
||||
pub format: Cell<&'static Format>,
|
||||
pub width_mm: i32,
|
||||
pub height_mm: i32,
|
||||
pub bindings: RefCell<AHashMap<ClientId, AHashMap<WlOutputId, Rc<WlOutput>>>>,
|
||||
|
|
@ -152,6 +155,8 @@ impl WlOutputGlobal {
|
|||
output_id: output_id.clone(),
|
||||
mode: Cell::new(*mode),
|
||||
modes,
|
||||
formats: CloneCell::new(Rc::new(vec![])),
|
||||
format: Cell::new(XRGB8888),
|
||||
width_mm,
|
||||
height_mm,
|
||||
bindings: Default::default(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue