From 68644f26bcf9fed2dc1efd50e18950ea5783013d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 6 May 2020 17:24:18 +0200 Subject: [PATCH] scene: add wlr_scene_commit_output This function performs an output commit. Since it's higher level than wlr_scene_render, it can take care of damage tracking and output layers. --- include/wlr/types/wlr_scene.h | 5 +++++ types/wlr_scene.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/wlr/types/wlr_scene.h b/include/wlr/types/wlr_scene.h index 800ceb437..300807fa7 100644 --- a/include/wlr/types/wlr_scene.h +++ b/include/wlr/types/wlr_scene.h @@ -103,6 +103,11 @@ struct wlr_scene *wlr_scene_create(void); */ void wlr_scene_render(struct wlr_scene *scene, struct wlr_output *output, int lx, int ly, pixman_region32_t *damage); +/** + * Perform an output commit. + */ +bool wlr_scene_commit_output(struct wlr_scene *scene, struct wlr_output *output, + int lx, int ly); /** * Add a node displaying a surface (and its sub-surfaces) to the scene-graph. diff --git a/types/wlr_scene.c b/types/wlr_scene.c index ad4a4818d..626edf52d 100644 --- a/types/wlr_scene.c +++ b/types/wlr_scene.c @@ -308,3 +308,24 @@ void wlr_scene_render(struct wlr_scene *scene, struct wlr_output *output, pixman_region32_fini(&full_region); } + +bool wlr_scene_commit_output(struct wlr_scene *scene, struct wlr_output *output, + int lx, int ly) { + if (!wlr_output_attach_render(output, NULL)) { + return false; + } + + struct wlr_renderer *renderer = wlr_backend_get_renderer(output->backend); + assert(renderer != NULL); + + int width, height; + wlr_output_effective_resolution(output, &width, &height); + wlr_renderer_begin(renderer, width, height); + wlr_renderer_clear(renderer, (float[4]){ 0.3, 0.3, 0.3, 1.0 }); + + wlr_scene_render(scene, output, lx, ly, NULL); + + wlr_renderer_end(renderer); + + return wlr_output_commit(output); +}