Skip to content

Commit 7929e25

Browse files
committed
kms: Support screen filters
1 parent 18335c6 commit 7929e25

File tree

5 files changed

+197
-79
lines changed

5 files changed

+197
-79
lines changed

src/backend/kms/device.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use crate::{
44
backend::render::{output_elements, CursorMode, GlMultiRenderer, CLEAR_COLOR},
5-
config::{AdaptiveSync, OutputConfig, OutputState},
5+
config::{AdaptiveSync, OutputConfig, OutputState, ScreenFilter},
66
shell::Shell,
77
utils::prelude::*,
88
wayland::protocols::screencopy::Frame as ScreencopyFrame,
@@ -272,6 +272,7 @@ impl State {
272272
maybe_crtc,
273273
(w, 0),
274274
&self.common.event_loop_handle,
275+
self.common.config.dynamic_conf.screen_filter().clone(),
275276
self.common.shell.clone(),
276277
self.common.startup_done.clone(),
277278
) {
@@ -365,6 +366,7 @@ impl State {
365366
maybe_crtc,
366367
(w, 0),
367368
&self.common.event_loop_handle,
369+
self.common.config.dynamic_conf.screen_filter().clone(),
368370
self.common.shell.clone(),
369371
self.common.startup_done.clone(),
370372
) {
@@ -516,6 +518,7 @@ impl Device {
516518
maybe_crtc: Option<crtc::Handle>,
517519
position: (u32, u32),
518520
evlh: &LoopHandle<'static, State>,
521+
screen_filter: ScreenFilter,
519522
shell: Arc<RwLock<Shell>>,
520523
startup_done: Arc<AtomicBool>,
521524
) -> Result<(Output, bool)> {
@@ -579,6 +582,7 @@ impl Device {
579582
self.dev_node,
580583
self.render_node,
581584
evlh,
585+
screen_filter,
582586
shell,
583587
startup_done,
584588
) {

src/backend/kms/mod.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-3.0-only
22

33
use crate::{
4-
config::{AdaptiveSync, OutputState},
4+
config::{AdaptiveSync, OutputState, ScreenFilter},
55
shell::Shell,
66
state::BackendData,
77
utils::prelude::*,
@@ -558,6 +558,7 @@ impl KmsState {
558558
&mut self,
559559
test_only: bool,
560560
loop_handle: &LoopHandle<'static, State>,
561+
screen_filter: &ScreenFilter,
561562
shell: Arc<RwLock<Shell>>,
562563
startup_done: Arc<AtomicBool>,
563564
clock: &Clock<Monotonic>,
@@ -658,6 +659,7 @@ impl KmsState {
658659
Some(crtc),
659660
(w, 0),
660661
loop_handle,
662+
screen_filter.clone(),
661663
shell.clone(),
662664
startup_done.clone(),
663665
)?;
@@ -927,4 +929,19 @@ impl KmsState {
927929

928930
Ok(all_outputs)
929931
}
932+
933+
pub fn update_screen_filter(&mut self, screen_filter: &ScreenFilter) -> Result<()> {
934+
for device in self.drm_devices.values_mut() {
935+
for surface in device.surfaces.values_mut() {
936+
surface.set_screen_filter(screen_filter.clone());
937+
}
938+
}
939+
940+
// We don't expect this to fail in a meaningful way.
941+
// The shader is already compiled at this point and we don't rely on any features,
942+
// that might not be available for any filters we currently expose.
943+
//
944+
// But we might conditionally fail here in the future.
945+
Ok(())
946+
}
930947
}

0 commit comments

Comments
 (0)