Skip to content

Commit

Permalink
feature checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed May 21, 2024
1 parent e10b162 commit a1ea61b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 12 additions & 3 deletions src/backend/renderer/utils/wayland.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "backend_drm")]
use crate::wayland::drm_syncobj::{DrmSyncPoint, DrmSyncobjCachedState};
use crate::{
backend::renderer::{buffer_dimensions, buffer_has_alpha, element::RenderElement, ImportAll, Renderer},
utils::{Buffer as BufferCoord, Coordinate, Logical, Physical, Point, Rectangle, Scale, Size, Transform},
Expand All @@ -7,7 +9,6 @@ use crate::{
with_surface_tree_upward, BufferAssignment, Damage, RectangleKind, SubsurfaceCachedState,
SurfaceAttributes, SurfaceData, TraversalAction,
},
drm_syncobj::{DrmSyncPoint, DrmSyncobjCachedState},
viewporter,
},
};
Expand Down Expand Up @@ -53,13 +54,15 @@ pub struct RendererSurfaceState {
#[derive(Debug)]
struct InnerBuffer {
buffer: WlBuffer,
#[cfg(feature = "backend_drm")]
release_point: Option<DrmSyncPoint>,
}

impl Drop for InnerBuffer {
#[inline]
fn drop(&mut self) {
self.buffer.release();
#[cfg(feature = "backend_drm")]
if let Some(release_point) = &self.release_point {
if let Err(err) = release_point.signal() {
tracing::error!("Failed to signal syncobj release point: {}", err);
Expand All @@ -75,10 +78,11 @@ pub struct Buffer {
}

impl Buffer {
fn new(buffer: WlBuffer, release_point: Option<DrmSyncPoint>) -> Self {
fn new(buffer: WlBuffer, #[cfg(feature = "backend_drm")] release_point: Option<DrmSyncPoint>) -> Self {
Buffer {
inner: Arc::new(InnerBuffer {
buffer,
#[cfg(feature = "backend_drm")]
release_point,
}),
}
Expand Down Expand Up @@ -111,6 +115,7 @@ impl PartialEq<WlBuffer> for &Buffer {
impl RendererSurfaceState {
#[profiling::function]
pub(crate) fn update_buffer(&mut self, states: &SurfaceData) {
#[cfg(feature = "backend_drm")]
let mut syncobj_state = states.cached_state.pending::<DrmSyncobjCachedState>();

let mut attrs = states.cached_state.current::<SurfaceAttributes>();
Expand All @@ -135,7 +140,11 @@ impl RendererSurfaceState {
self.buffer_transform = attrs.buffer_transform.into();

if !self.buffer.as_ref().map_or(false, |b| b == buffer) {
self.buffer = Some(Buffer::new(buffer, syncobj_state.release_point.take()));
self.buffer = Some(Buffer::new(
buffer,
#[cfg(feature = "backend_drm")]
syncobj_state.release_point.take(),
));
}

self.textures.clear();
Expand Down
9 changes: 5 additions & 4 deletions src/wayland/compositor/tree.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
utils::Serial,
wayland::{compositor::SUBSURFACE_ROLE, drm_syncobj::DrmSyncobjCachedState},
};
#[cfg(feature = "backend_drm")]
use crate::wayland::drm_syncobj::DrmSyncobjCachedState;
use crate::{utils::Serial, wayland::compositor::SUBSURFACE_ROLE};

use super::{
cache::MultiCache,
Expand Down Expand Up @@ -159,6 +158,7 @@ impl PrivateSurfaceData {
{
buffer.release();
};
#[cfg(feature = "backend_drm")]
if let Some(release_point) = &my_data
.public_data
.cached_state
Expand All @@ -169,6 +169,7 @@ impl PrivateSurfaceData {
tracing::error!("Failed to signal syncobj release point: {}", err);
}
}
#[cfg(feature = "backend_drm")]
if let Some(release_point) = &my_data
.public_data
.cached_state
Expand Down

0 comments on commit a1ea61b

Please sign in to comment.