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.
master
Alexander Orzechowski 4 months ago
parent 2463a4723e
commit 23202e192c

@ -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.
*/

@ -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;
}

Loading…
Cancel
Save