scene: wire up frame schedulers

This commit is contained in:
Rose Hudson 2023-07-27 15:59:05 +01:00
parent 7ecafde6fd
commit ea11856851
3 changed files with 9 additions and 17 deletions

View file

@ -190,6 +190,7 @@ struct wlr_scene_output {
struct wlr_output *output; struct wlr_output *output;
struct wl_list link; // wlr_scene.outputs struct wl_list link; // wlr_scene.outputs
struct wlr_scene *scene; struct wlr_scene *scene;
struct wlr_frame_scheduler *frame_scheduler;
struct wlr_addon addon; struct wlr_addon addon;
struct wlr_damage_ring damage_ring; struct wlr_damage_ring damage_ring;
@ -207,7 +208,6 @@ struct wlr_scene_output {
struct wl_listener output_commit; struct wl_listener output_commit;
struct wl_listener output_damage; struct wl_listener output_damage;
struct wl_listener output_needs_frame;
struct wl_list damage_highlight_regions; struct wl_list damage_highlight_regions;

View file

@ -3,6 +3,7 @@
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_scene.h> #include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_fractional_scale_v1.h> #include <wlr/types/wlr_fractional_scale_v1.h>
#include <wlr/types/wlr_frame_scheduler.h>
#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_presentation_time.h>
#include "types/wlr_scene.h" #include "types/wlr_scene.h"
@ -143,7 +144,7 @@ static void handle_scene_surface_surface_commit(
if (!wl_list_empty(&surface->surface->current.frame_callback_list) && if (!wl_list_empty(&surface->surface->current.frame_callback_list) &&
surface->buffer->primary_output != NULL && enabled) { surface->buffer->primary_output != NULL && enabled) {
wlr_output_schedule_frame(surface->buffer->primary_output->output); wlr_frame_scheduler_schedule_frame(surface->buffer->primary_output->frame_scheduler);
} }
} }

View file

@ -7,6 +7,7 @@
#include <wlr/render/wlr_renderer.h> #include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_damage_ring.h> #include <wlr/types/wlr_damage_ring.h>
#include <wlr/types/wlr_frame_scheduler.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h> #include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_presentation_time.h>
@ -326,7 +327,7 @@ static void scene_damage_outputs(struct wlr_scene *scene, pixman_region32_t *dam
-scene_output->x, -scene_output->y); -scene_output->x, -scene_output->y);
scale_output_damage(&output_damage, scene_output->output->scale); scale_output_damage(&output_damage, scene_output->output->scale);
if (wlr_damage_ring_add(&scene_output->damage_ring, &output_damage)) { if (wlr_damage_ring_add(&scene_output->damage_ring, &output_damage)) {
wlr_output_schedule_frame(scene_output->output); wlr_frame_scheduler_schedule_frame(scene_output->frame_scheduler);
} }
pixman_region32_fini(&output_damage); pixman_region32_fini(&output_damage);
} }
@ -743,7 +744,7 @@ void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buff
(int)round((lx - scene_output->x) * output_scale), (int)round((lx - scene_output->x) * output_scale),
(int)round((ly - scene_output->y) * output_scale)); (int)round((ly - scene_output->y) * output_scale));
if (wlr_damage_ring_add(&scene_output->damage_ring, &output_damage)) { if (wlr_damage_ring_add(&scene_output->damage_ring, &output_damage)) {
wlr_output_schedule_frame(scene_output->output); wlr_frame_scheduler_schedule_frame(scene_output->frame_scheduler);
} }
pixman_region32_fini(&output_damage); pixman_region32_fini(&output_damage);
} }
@ -1256,7 +1257,7 @@ static void scene_node_output_update(struct wlr_scene_node *node,
static void scene_output_update_geometry(struct wlr_scene_output *scene_output) { static void scene_output_update_geometry(struct wlr_scene_output *scene_output) {
wlr_damage_ring_add_whole(&scene_output->damage_ring); wlr_damage_ring_add_whole(&scene_output->damage_ring);
wlr_output_schedule_frame(scene_output->output); wlr_frame_scheduler_schedule_frame(scene_output->frame_scheduler);
scene_node_output_update(&scene_output->scene->tree.node, scene_node_output_update(&scene_output->scene->tree.node,
&scene_output->scene->outputs, NULL); &scene_output->scene->outputs, NULL);
@ -1280,16 +1281,10 @@ static void scene_output_handle_damage(struct wl_listener *listener, void *data)
scene_output, output_damage); scene_output, output_damage);
struct wlr_output_event_damage *event = data; struct wlr_output_event_damage *event = data;
if (wlr_damage_ring_add(&scene_output->damage_ring, event->damage)) { if (wlr_damage_ring_add(&scene_output->damage_ring, event->damage)) {
wlr_output_schedule_frame(scene_output->output); wlr_frame_scheduler_schedule_frame(scene_output->frame_scheduler);
} }
} }
static void scene_output_handle_needs_frame(struct wl_listener *listener, void *data) {
struct wlr_scene_output *scene_output = wl_container_of(listener,
scene_output, output_needs_frame);
wlr_output_schedule_frame(scene_output->output);
}
struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene, struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene,
struct wlr_output *output) { struct wlr_output *output) {
struct wlr_scene_output *scene_output = calloc(1, sizeof(*scene_output)); struct wlr_scene_output *scene_output = calloc(1, sizeof(*scene_output));
@ -1329,9 +1324,6 @@ struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene,
scene_output->output_damage.notify = scene_output_handle_damage; scene_output->output_damage.notify = scene_output_handle_damage;
wl_signal_add(&output->events.damage, &scene_output->output_damage); wl_signal_add(&output->events.damage, &scene_output->output_damage);
scene_output->output_needs_frame.notify = scene_output_handle_needs_frame;
wl_signal_add(&output->events.needs_frame, &scene_output->output_needs_frame);
scene_output_update_geometry(scene_output); scene_output_update_geometry(scene_output);
return scene_output; return scene_output;
@ -1363,7 +1355,6 @@ void wlr_scene_output_destroy(struct wlr_scene_output *scene_output) {
wl_list_remove(&scene_output->link); wl_list_remove(&scene_output->link);
wl_list_remove(&scene_output->output_commit.link); wl_list_remove(&scene_output->output_commit.link);
wl_list_remove(&scene_output->output_damage.link); wl_list_remove(&scene_output->output_damage.link);
wl_list_remove(&scene_output->output_needs_frame.link);
wl_array_release(&scene_output->render_list); wl_array_release(&scene_output->render_list);
free(scene_output); free(scene_output);
@ -1892,7 +1883,7 @@ bool wlr_scene_output_build_state(struct wlr_scene_output *scene_output,
if (debug_damage == WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT && if (debug_damage == WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT &&
!wl_list_empty(&scene_output->damage_highlight_regions)) { !wl_list_empty(&scene_output->damage_highlight_regions)) {
wlr_output_schedule_frame(scene_output->output); wlr_frame_scheduler_schedule_frame(scene_output->frame_scheduler);
} }
return true; return true;