diff options
author | Isaac Freund <mail@isaacfreund.com> | 2021-12-13 16:11:19 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-12-13 15:21:05 +0000 |
commit | fecde72be3ebdc5ad0aa526db7405aaf1eddf847 (patch) | |
tree | 9e2ba2c11de5aca95dd693ffc94b98762f536688 | |
parent | fb1f613510b871bcc117179a9d3a32aabc4508c0 (diff) |
scene: add wlr_scene_send_frame_done()
-rw-r--r-- | include/wlr/types/wlr_scene.h | 7 | ||||
-rw-r--r-- | types/scene/wlr_scene.c | 25 |
2 files changed, 32 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 6c2928ee..f388a658 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -201,6 +201,13 @@ struct wlr_scene *wlr_scene_create(void); */ void wlr_scene_render_output(struct wlr_scene *scene, struct wlr_output *output, int lx, int ly, pixman_region32_t *damage); +/** + * Call wlr_surface_send_frame_done() on all surfaces in the scene rendered by + * wlr_scene_render_output() for which wlr_scene_surface->primary_output + * matches the given output. + */ +void wlr_scene_send_frame_done(struct wlr_scene *scene, + struct wlr_output *output, struct timespec *now); /** * Add a node displaying nothing but its children. diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 42697074..daaf8d97 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -876,6 +876,31 @@ void wlr_scene_render_output(struct wlr_scene *scene, struct wlr_output *output, pixman_region32_fini(&full_region); } +static void scene_send_frame_done_iterator(struct wlr_scene_node *node, + struct wlr_output *output, struct timespec *now) { + if (!node->state.enabled) { + return; + } + + if (node->type == WLR_SCENE_NODE_SURFACE) { + struct wlr_scene_surface *scene_surface = + wlr_scene_surface_from_node(node); + if (scene_surface->primary_output == output) { + wlr_surface_send_frame_done(scene_surface->surface, now); + } + } + + struct wlr_scene_node *child; + wl_list_for_each(child, &node->state.children, state.link) { + scene_send_frame_done_iterator(child, output, now); + } +} + +void wlr_scene_send_frame_done(struct wlr_scene *scene, + struct wlr_output *output, struct timespec *now) { + scene_send_frame_done_iterator(&scene->node, output, now); +} + static void scene_output_handle_destroy(struct wlr_addon *addon) { struct wlr_scene_output *scene_output = wl_container_of(addon, scene_output, addon); |