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); +}