From 23202e192c2989621db564addd6a792d2c218d22 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Wed, 14 Aug 2024 12:51:15 -0400 Subject: [PATCH] wlr_scene: Introduce wlr_scene_output_needs_frame It seems that some scene compositors want to avoid wlr_scene_output_commit and use the lower lever wlr_scene_output_build_state. However, build state does not early return if a frame is not needed so compositors will implement the check themselves. Let's add a helper function that compositors can use to implement the check. Technically pending_commit_damage is a private interface, so this lets compositors not interface with private interfaces to implement the check. --- include/wlr/types/wlr_scene.h | 6 ++++++ types/scene/wlr_scene.c | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 7f3217baa..df9e93b9c 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -529,6 +529,12 @@ struct wlr_scene_output_state_options { struct wlr_swapchain *swapchain; }; +/** + * Returns true if scene wants to render a new frame. False, if no new frame + * is needed and an output commit can be skipped for the current frame. + */ +bool wlr_scene_output_needs_frame(struct wlr_scene_output *scene_output); + /** * Render and commit an output. */ diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index af9e243fa..1829ce542 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -1818,10 +1818,14 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry, return true; } +bool wlr_scene_output_needs_frame(struct wlr_scene_output *scene_output) { + return scene_output->output->needs_frame || pixman_region32_not_empty( + &scene_output->pending_commit_damage); +} + bool wlr_scene_output_commit(struct wlr_scene_output *scene_output, const struct wlr_scene_output_state_options *options) { - if (!scene_output->output->needs_frame && !pixman_region32_not_empty( - &scene_output->pending_commit_damage)) { + if (!wlr_scene_output_needs_frame(scene_output)) { return true; }