metal: implement tearing
This commit is contained in:
parent
d355059ad9
commit
49f6304716
31 changed files with 726 additions and 51 deletions
|
|
@ -25,7 +25,7 @@ use {
|
|||
timer::Timer,
|
||||
video::{
|
||||
connector_type::{ConnectorType, CON_UNKNOWN},
|
||||
Connector, DrmDevice, GfxApi, Mode, Transform, VrrMode,
|
||||
Connector, DrmDevice, GfxApi, Mode, TearingMode, Transform, VrrMode,
|
||||
},
|
||||
Axis, Direction, ModifiedKeySym, PciId, Workspace,
|
||||
},
|
||||
|
|
@ -808,6 +808,10 @@ impl Client {
|
|||
self.send(&ClientMessage::SetVrrCursorHz { connector, hz })
|
||||
}
|
||||
|
||||
pub fn set_tearing_mode(&self, connector: Option<Connector>, mode: TearingMode) {
|
||||
self.send(&ClientMessage::SetTearingMode { connector, mode })
|
||||
}
|
||||
|
||||
pub fn drm_devices(&self) -> Vec<DrmDevice> {
|
||||
let res = self.send_with_response(&ClientMessage::GetDrmDevices);
|
||||
get_response!(res, vec![], GetDrmDevices { devices });
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ use {
|
|||
logging::LogLevel,
|
||||
theme::{colors::Colorable, sized::Resizable, Color},
|
||||
timer::Timer,
|
||||
video::{connector_type::ConnectorType, Connector, DrmDevice, GfxApi, Transform, VrrMode},
|
||||
video::{
|
||||
connector_type::ConnectorType, Connector, DrmDevice, GfxApi, TearingMode, Transform,
|
||||
VrrMode,
|
||||
},
|
||||
Axis, Direction, PciId, Workspace,
|
||||
_private::{PollableId, WireMode},
|
||||
},
|
||||
|
|
@ -495,6 +498,10 @@ pub enum ClientMessage<'a> {
|
|||
connector: Option<Connector>,
|
||||
hz: f64,
|
||||
},
|
||||
SetTearingMode {
|
||||
connector: Option<Connector>,
|
||||
mode: TearingMode,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -262,6 +262,11 @@ impl Connector {
|
|||
pub fn set_vrr_cursor_hz(self, hz: f64) {
|
||||
get!().set_vrr_cursor_hz(Some(self), hz)
|
||||
}
|
||||
|
||||
/// Sets the tearing mode.
|
||||
pub fn set_tearing_mode(self, mode: TearingMode) {
|
||||
get!().set_tearing_mode(Some(self), mode)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns all available DRM devices.
|
||||
|
|
@ -580,3 +585,30 @@ pub fn set_vrr_mode(mode: VrrMode) {
|
|||
pub fn set_vrr_cursor_hz(hz: f64) {
|
||||
get!().set_vrr_cursor_hz(None, hz)
|
||||
}
|
||||
|
||||
/// The tearing mode of a connector.
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
|
||||
pub struct TearingMode(pub u32);
|
||||
|
||||
impl TearingMode {
|
||||
/// Tearing is never enabled.
|
||||
pub const NEVER: Self = Self(0);
|
||||
/// Tearing is always enabled.
|
||||
pub const ALWAYS: Self = Self(1);
|
||||
/// Tearing is enabled when one or more applications are displayed fullscreen.
|
||||
pub const VARIANT_1: Self = Self(2);
|
||||
/// Tearing is enabled when a single application is displayed fullscreen.
|
||||
pub const VARIANT_2: Self = Self(3);
|
||||
/// Tearing is enabled when a single application is displayed fullscreen and the
|
||||
/// application has requested tearing.
|
||||
///
|
||||
/// This is the default.
|
||||
pub const VARIANT_3: Self = Self(4);
|
||||
}
|
||||
|
||||
/// Sets the default tearing mode.
|
||||
///
|
||||
/// This setting can be overwritten on a per-connector basis with [Connector::set_tearing_mode].
|
||||
pub fn set_tearing_mode(mode: TearingMode) {
|
||||
get!().set_tearing_mode(None, mode)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue