metal: allow configuring framebuffer formats
This commit is contained in:
parent
9bab4f7ce1
commit
b4ca15fec0
24 changed files with 713 additions and 58 deletions
|
|
@ -22,7 +22,7 @@ use {
|
|||
logging::LogLevel,
|
||||
status::MessageFormat,
|
||||
theme::Color,
|
||||
video::{GfxApi, TearingMode, Transform, VrrMode},
|
||||
video::{Format, GfxApi, TearingMode, Transform, VrrMode},
|
||||
Axis, Direction, Workspace,
|
||||
},
|
||||
std::{
|
||||
|
|
@ -208,6 +208,7 @@ pub struct Output {
|
|||
pub mode: Option<Mode>,
|
||||
pub vrr: Option<Vrr>,
|
||||
pub tearing: Option<Tearing>,
|
||||
pub format: Option<Format>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ mod drm_device;
|
|||
mod drm_device_match;
|
||||
mod env;
|
||||
pub mod exec;
|
||||
mod format;
|
||||
mod gfx_api;
|
||||
mod idle;
|
||||
mod input;
|
||||
|
|
|
|||
59
toml-config/src/config/parsers/format.rs
Normal file
59
toml-config/src/config/parsers/format.rs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
use {
|
||||
crate::{
|
||||
config::parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
toml::toml_span::{Span, SpannedExt},
|
||||
},
|
||||
jay_config::video::Format,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FormatParserError {
|
||||
#[error(transparent)]
|
||||
Expected(#[from] UnexpectedDataType),
|
||||
#[error("Unknown format {0}")]
|
||||
UnknownFormat(String),
|
||||
}
|
||||
|
||||
pub struct FormatParser;
|
||||
|
||||
impl Parser for FormatParser {
|
||||
type Value = Format;
|
||||
type Error = FormatParserError;
|
||||
const EXPECTED: &'static [DataType] = &[DataType::String];
|
||||
|
||||
fn parse_string(&mut self, span: Span, string: &str) -> ParseResult<Self> {
|
||||
let format = match string {
|
||||
"argb8888" => Format::ARGB8888,
|
||||
"xrgb8888" => Format::XRGB8888,
|
||||
"abgr8888" => Format::ABGR8888,
|
||||
"xbgr8888" => Format::XBGR8888,
|
||||
"r8" => Format::R8,
|
||||
"gr88" => Format::GR88,
|
||||
"rgb888" => Format::RGB888,
|
||||
"bgr888" => Format::BGR888,
|
||||
"rgba4444" => Format::RGBA4444,
|
||||
"rgbx4444" => Format::RGBX4444,
|
||||
"bgra4444" => Format::BGRA4444,
|
||||
"bgrx4444" => Format::BGRX4444,
|
||||
"rgb565" => Format::RGB565,
|
||||
"bgr565" => Format::BGR565,
|
||||
"rgba5551" => Format::RGBA5551,
|
||||
"rgbx5551" => Format::RGBX5551,
|
||||
"bgra5551" => Format::BGRA5551,
|
||||
"bgrx5551" => Format::BGRX5551,
|
||||
"argb1555" => Format::ARGB1555,
|
||||
"xrgb1555" => Format::XRGB1555,
|
||||
"argb2101010" => Format::ARGB2101010,
|
||||
"xrgb2101010" => Format::XRGB2101010,
|
||||
"abgr2101010" => Format::ABGR2101010,
|
||||
"xbgr2101010" => Format::XBGR2101010,
|
||||
"abgr16161616" => Format::ABGR16161616,
|
||||
"xbgr16161616" => Format::XBGR16161616,
|
||||
"abgr16161616f" => Format::ABGR16161616F,
|
||||
"xbgr16161616f" => Format::XBGR16161616F,
|
||||
_ => return Err(FormatParserError::UnknownFormat(string.to_string()).spanned(span)),
|
||||
};
|
||||
Ok(format)
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ use {
|
|||
extractor::{fltorint, opt, recover, s32, str, val, Extractor, ExtractorError},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
parsers::{
|
||||
format::FormatParser,
|
||||
mode::ModeParser,
|
||||
output_match::{OutputMatchParser, OutputMatchParserError},
|
||||
tearing::TearingParser,
|
||||
|
|
@ -48,8 +49,8 @@ impl<'a> Parser for OutputParser<'a> {
|
|||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.cx, span, table);
|
||||
let (name, match_val, x, y, scale, transform, mode, vrr_val, tearing_val) =
|
||||
ext.extract((
|
||||
let (name, match_val, x, y, scale, transform, mode, vrr_val, tearing_val, format_val) = ext
|
||||
.extract((
|
||||
opt(str("name")),
|
||||
val("match"),
|
||||
recover(opt(s32("x"))),
|
||||
|
|
@ -59,6 +60,7 @@ impl<'a> Parser for OutputParser<'a> {
|
|||
opt(val("mode")),
|
||||
opt(val("vrr")),
|
||||
opt(val("tearing")),
|
||||
opt(val("format")),
|
||||
))?;
|
||||
let transform = match transform {
|
||||
None => None,
|
||||
|
|
@ -119,6 +121,18 @@ impl<'a> Parser for OutputParser<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut format = None;
|
||||
if let Some(value) = format_val {
|
||||
match value.parse(&mut FormatParser) {
|
||||
Ok(v) => format = Some(v),
|
||||
Err(e) => {
|
||||
log::warn!(
|
||||
"Could not parse framebuffer format setting: {}",
|
||||
self.cx.error(e)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Output {
|
||||
name: name.despan().map(|v| v.to_string()),
|
||||
match_: match_val.parse_map(&mut OutputMatchParser(self.cx))?,
|
||||
|
|
@ -129,6 +143,7 @@ impl<'a> Parser for OutputParser<'a> {
|
|||
mode,
|
||||
vrr,
|
||||
tearing,
|
||||
format,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -573,6 +573,9 @@ impl Output {
|
|||
c.set_tearing_mode(mode);
|
||||
}
|
||||
}
|
||||
if let Some(format) = self.format {
|
||||
c.set_format(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue