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.
This commit is contained in:
Alexander Orzechowski 2024-08-14 12:51:15 -04:00
parent 2463a4723e
commit 23202e192c
2 changed files with 12 additions and 2 deletions

View File

@ -529,6 +529,12 @@ struct wlr_scene_output_state_options {
struct wlr_swapchain *swapchain; 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. * Render and commit an output.
*/ */

View File

@ -1818,10 +1818,14 @@ static bool scene_entry_try_direct_scanout(struct render_list_entry *entry,
return true; 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, bool wlr_scene_output_commit(struct wlr_scene_output *scene_output,
const struct wlr_scene_output_state_options *options) { const struct wlr_scene_output_state_options *options) {
if (!scene_output->output->needs_frame && !pixman_region32_not_empty( if (!wlr_scene_output_needs_frame(scene_output)) {
&scene_output->pending_commit_damage)) {
return true; return true;
} }