Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
examples/scene-graph: use wlr_scene_output
Browse files Browse the repository at this point in the history
This allows us to get damage tracking for free™.
  • Loading branch information
emersion committed Aug 30, 2021
1 parent e2fa176 commit 7304a26
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions examples/scene-graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,15 @@ struct output {
struct wl_list link;
struct server *server;
struct wlr_output *wlr;
struct wlr_scene_output *scene_output;

struct wl_listener frame;
};

static void output_handle_frame(struct wl_listener *listener, void *data) {
struct output *output = wl_container_of(listener, output, frame);

if (!wlr_output_attach_render(output->wlr, NULL)) {
return;
}

struct wlr_renderer *renderer = wlr_backend_get_renderer(output->wlr->backend);
assert(renderer != NULL);

int width, height;
wlr_output_effective_resolution(output->wlr, &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_output(output->server->scene, output->wlr, 0, 0, NULL);
wlr_output_render_software_cursors(output->wlr, NULL);

wlr_renderer_end(renderer);

if (!wlr_output_commit(output->wlr)) {
if (!wlr_scene_output_commit(output->scene_output)) {
return;
}

Expand All @@ -93,6 +77,8 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wl_signal_add(&wlr_output->events.frame, &output->frame);
wl_list_insert(&server->outputs, &output->link);

output->scene_output = wlr_scene_output_create(server->scene, wlr_output);

if (!wl_list_empty(&wlr_output->modes)) {
struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
wlr_output_set_mode(wlr_output, mode);
Expand Down

0 comments on commit 7304a26

Please sign in to comment.