aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-08-17 15:13:07 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-09-08 09:50:08 -0400
commite05c884891ecbc7d69bab25c8886b951d76fc685 (patch)
tree37ab72417df2d6b19bfa012e84de812c217f7a29
parent44f0f7a0a7ce856747d219c9e83159f741f5e912 (diff)
examples/scene-graph: use wlr_scene_output
This allows us to get damage tracking for freeā„¢.
-rw-r--r--examples/scene-graph.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/examples/scene-graph.c b/examples/scene-graph.c
index 960368eb..d5c23a16 100644
--- a/examples/scene-graph.c
+++ b/examples/scene-graph.c
@@ -48,6 +48,7 @@ struct output {
struct wl_list link;
struct server *server;
struct wlr_output *wlr;
+ struct wlr_scene_output *scene_output;
struct wl_listener frame;
};
@@ -55,24 +56,7 @@ struct output {
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;
}
@@ -97,6 +81,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);