Share visibility checks and test client presentation lifecycle
This commit is contained in:
1 parent
bb78801720
commit
aecf54bc76
4 files changed
+302
-12
No files matched your search
@@ -1,7 +1,9 @@
|
||||
//! Visibility of client content on displayed outputs, independent of capture.
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
use smithay::backend::renderer::element::{Id, RenderElementPresentationState, RenderElementStates};
|
||||
use smithay::backend::renderer::element::{
|
||||
Id, RenderElementPresentationState, RenderElementState, RenderElementStates,
|
||||
};
|
||||
use smithay::output::Output;
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -15,14 +17,15 @@ pub(crate) struct DisplayPresentation {
|
||||
outputs: HashMap<Output, OutputPresentation>,
|
||||
}
|
||||
|
||||
pub(crate) fn is_visible(state: RenderElementState) -> bool {
|
||||
state.visible_area > 0 && state.presentation_state != RenderElementPresentationState::Skipped
|
||||
}
|
||||
|
||||
fn visible(states: &RenderElementStates) -> HashSet<Id> {
|
||||
states
|
||||
.states
|
||||
.iter()
|
||||
.filter_map(|(id, state)| {
|
||||
(state.visible_area > 0 && state.presentation_state != RenderElementPresentationState::Skipped)
|
||||
.then(|| id.clone())
|
||||
})
|
||||
.filter_map(|(id, state)| is_visible(*state).then(|| id.clone()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -113,6 +116,8 @@ mod tests {
|
||||
assert!(!record.visible(&id));
|
||||
record.presented(&output);
|
||||
assert!(record.visible(&id));
|
||||
record.presented(&output); // No new submission keeps the last displayed scene.
|
||||
assert!(record.visible(&id));
|
||||
|
||||
record.queued(&output, &RenderElementStates::default());
|
||||
assert!(record.visible(&id));
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
//! logical pixels. Content, clips and decorations share those exact edges.
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use smithay::backend::renderer::element::{
|
||||
Element, Id, Kind, RenderElement, RenderElementPresentationState, RenderElementStates,
|
||||
};
|
||||
use smithay::backend::renderer::element::{Element, Id, Kind, RenderElement, RenderElementStates};
|
||||
use smithay::backend::renderer::gles::{GlesError, GlesFrame, GlesRenderer, GlesTexProgram, GlesTexture, Uniform};
|
||||
use smithay::backend::renderer::utils::{CommitCounter, DamageSet};
|
||||
use smithay::desktop::utils::OutputPresentationFeedback;
|
||||
@@ -55,9 +53,7 @@ pub(crate) fn take_output_feedback(
|
||||
fn rendered_feedback_output(output: &Output, id: Id, rendered: &RenderElementStates) -> Option<Output> {
|
||||
rendered
|
||||
.element_render_state(id)
|
||||
.is_some_and(|state| {
|
||||
state.visible_area > 0 && state.presentation_state != RenderElementPresentationState::Skipped
|
||||
})
|
||||
.is_some_and(crate::display_presentation::is_visible)
|
||||
.then(|| output.clone())
|
||||
}
|
||||
|
||||
@@ -330,7 +326,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn presentation_feedback_excludes_missing_and_occluded_surfaces() {
|
||||
use smithay::backend::renderer::element::RenderElementState;
|
||||
use smithay::backend::renderer::element::{RenderElementPresentationState, RenderElementState};
|
||||
use smithay::output::{PhysicalProperties, Subpixel};
|
||||
|
||||
let output = Output::new(
|
||||
|
||||
Reference in new issue
Block a user