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.
This commit is contained in:
Simon Ser 2020-05-06 17:24:18 +02:00
parent 33aaa24b6b
commit 68644f26bc
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 26 additions and 0 deletions

View file

@ -103,6 +103,11 @@ struct wlr_scene *wlr_scene_create(void);
*/ */
void wlr_scene_render(struct wlr_scene *scene, struct wlr_output *output, void wlr_scene_render(struct wlr_scene *scene, struct wlr_output *output,
int lx, int ly, pixman_region32_t *damage); 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. * Add a node displaying a surface (and its sub-surfaces) to the scene-graph.

View file

@ -308,3 +308,24 @@ void wlr_scene_render(struct wlr_scene *scene, struct wlr_output *output,
pixman_region32_fini(&full_region); 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);
}