diff options
author | Isaac Freund <mail@isaacfreund.com> | 2021-12-13 17:23:47 +0100 |
---|---|---|
committer | Isaac Freund <mail@isaacfreund.com> | 2021-12-13 17:26:22 +0100 |
commit | 1c3e0816f3cc4c653b24256486234d02fcf59e02 (patch) | |
tree | 1697c36cc13635aa310885277a38811a0336d017 | |
parent | ad01cdf0b218a8d49698bf0ff85b84a4540a4f6f (diff) |
scene: fix wlr_scene_send_frame_done() API
This doesn't work if scene outputs are not used as the primary output of
scene surfaces will always be NULL.
Therefore, take a wlr_scene_output instead of separate wlr_scene and
wlr_output arguments and rename the function to
wlr_scene_output_send_frame_done().
The actual behavior of the function is unchanged.
-rw-r--r-- | include/wlr/types/wlr_scene.h | 15 | ||||
-rw-r--r-- | tinywl/tinywl.c | 2 | ||||
-rw-r--r-- | types/scene/wlr_scene.c | 51 |
3 files changed, 34 insertions, 34 deletions
diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index f388a658..d2af9c5a 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -201,13 +201,6 @@ 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. @@ -295,7 +288,13 @@ void wlr_scene_output_set_position(struct wlr_scene_output *scene_output, * Render and commit an output. */ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output); - +/** + * Call wlr_surface_send_frame_done() on all surfaces in the scene rendered by + * wlr_scene_output_commit() for which wlr_scene_surface->primary_output + * matches the given scene_output. + */ +void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output, + struct timespec *now); /** * Call `iterator` on each surface in the scene-graph visible on the output, * with the surface's position in layout coordinates. The function is called diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 581fcfca..faa0a9a1 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -524,7 +524,7 @@ static void output_frame(struct wl_listener *listener, void *data) { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); - wlr_scene_send_frame_done(scene, output->wlr_output, &now); + wlr_scene_output_send_frame_done(scene_output, &now); } static void server_new_output(struct wl_listener *listener, void *data) { diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index daaf8d97..3d19acef 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -876,31 +876,6 @@ 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); @@ -1121,6 +1096,32 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) { return wlr_output_commit(output); } +static void scene_output_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_output_send_frame_done_iterator(child, output, now); + } +} + +void wlr_scene_output_send_frame_done(struct wlr_scene_output *scene_output, + struct timespec *now) { + scene_output_send_frame_done_iterator(&scene_output->scene->node, + scene_output->output, now); +} + static void scene_output_for_each_surface(const struct wlr_box *output_box, struct wlr_scene_node *node, int lx, int ly, wlr_surface_iterator_func_t user_iterator, void *user_data) { |