scene: use wlr_frame_scheduler

This commit is contained in:
Simon Ser 2022-10-04 12:14:35 +02:00
parent 374a4a8d7e
commit 5424b2d44d
3 changed files with 16 additions and 7 deletions

View file

@ -23,6 +23,7 @@
#include <wayland-server-core.h> #include <wayland-server-core.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>
struct wlr_output; struct wlr_output;
struct wlr_output_layout; struct wlr_output_layout;
@ -165,6 +166,7 @@ struct wlr_scene_output {
struct wlr_addon addon; struct wlr_addon addon;
struct wlr_damage_ring damage_ring; struct wlr_damage_ring damage_ring;
struct wlr_frame_scheduler frame_scheduler;
int x, y; int x, y;

View file

@ -601,9 +601,6 @@ static void server_new_output(struct wl_listener *listener, void *data) {
calloc(1, sizeof(struct tinywl_output)); calloc(1, sizeof(struct tinywl_output));
output->wlr_output = wlr_output; output->wlr_output = wlr_output;
output->server = server; output->server = server;
/* Sets up a listener for the frame notify event. */
output->frame.notify = output_frame;
wl_signal_add(&wlr_output->events.frame, &output->frame);
/* Sets up a listener for the destroy notify event. */ /* Sets up a listener for the destroy notify event. */
output->destroy.notify = output_destroy; output->destroy.notify = output_destroy;
@ -621,6 +618,12 @@ static void server_new_output(struct wl_listener *listener, void *data) {
* output (such as DPI, scale factor, manufacturer, etc). * output (such as DPI, scale factor, manufacturer, etc).
*/ */
wlr_output_layout_add_auto(server->output_layout, wlr_output); wlr_output_layout_add_auto(server->output_layout, wlr_output);
struct wlr_scene_output *scene_output =
wlr_scene_get_scene_output(server->scene, wlr_output);
/* Sets up a listener for the frame notify event. */
output->frame.notify = output_frame;
wl_signal_add(&scene_output->frame_scheduler.events.frame, &output->frame);
} }
static void xdg_toplevel_map(struct wl_listener *listener, void *data) { static void xdg_toplevel_map(struct wl_listener *listener, void *data) {

View file

@ -185,7 +185,7 @@ static void scene_node_get_size(struct wlr_scene_node *node, int *lx, int *ly);
typedef bool (*scene_node_box_iterator_func_t)(struct wlr_scene_node *node, typedef bool (*scene_node_box_iterator_func_t)(struct wlr_scene_node *node,
int sx, int sy, void *data); int sx, int sy, void *data);
static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box, static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box,
scene_node_box_iterator_func_t iterator, void *user_data, int lx, int ly) { scene_node_box_iterator_func_t iterator, void *user_data, int lx, int ly) {
if (!node->enabled) { if (!node->enabled) {
return false; return false;
@ -216,7 +216,7 @@ static bool _scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box
return false; return false;
} }
static bool scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box, static bool scene_nodes_in_box(struct wlr_scene_node *node, struct wlr_box *box,
scene_node_box_iterator_func_t iterator, void *user_data) { scene_node_box_iterator_func_t iterator, void *user_data) {
int x, y; int x, y;
wlr_scene_node_coords(node, &x, &y); wlr_scene_node_coords(node, &x, &y);
@ -341,7 +341,7 @@ static void update_node_update_outputs(struct wlr_scene_node *node,
active_outputs |= 1ull << scene_output->index; active_outputs |= 1ull << scene_output->index;
} }
pixman_region32_fini(&intersection); pixman_region32_fini(&intersection);
} }
@ -556,7 +556,7 @@ void wlr_scene_buffer_set_buffer_with_damage(struct wlr_scene_buffer *scene_buff
struct wlr_buffer *buffer, pixman_region32_t *damage) { struct wlr_buffer *buffer, pixman_region32_t *damage) {
// specifying a region for a NULL buffer doesn't make sense. We need to know // specifying a region for a NULL buffer doesn't make sense. We need to know
// about the buffer to scale the buffer local coordinates down to scene // about the buffer to scale the buffer local coordinates down to scene
// coordinates. // coordinates.
assert(buffer || !damage); assert(buffer || !damage);
if (buffer == scene_buffer->buffer) { if (buffer == scene_buffer->buffer) {
@ -1204,6 +1204,7 @@ struct wlr_scene_output *wlr_scene_output_create(struct wlr_scene *scene,
wlr_addon_init(&scene_output->addon, &output->addons, scene, &output_addon_impl); wlr_addon_init(&scene_output->addon, &output->addons, scene, &output_addon_impl);
wlr_damage_ring_init(&scene_output->damage_ring); wlr_damage_ring_init(&scene_output->damage_ring);
wlr_frame_scheduler_init(&scene_output->frame_scheduler, output);
wl_list_init(&scene_output->damage_highlight_regions); wl_list_init(&scene_output->damage_highlight_regions);
int prev_output_index = -1; int prev_output_index = -1;
@ -1265,6 +1266,7 @@ void wlr_scene_output_destroy(struct wlr_scene_output *scene_output) {
wlr_addon_finish(&scene_output->addon); wlr_addon_finish(&scene_output->addon);
wlr_damage_ring_finish(&scene_output->damage_ring); wlr_damage_ring_finish(&scene_output->damage_ring);
wlr_frame_scheduler_finish(&scene_output->frame_scheduler);
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_mode.link); wl_list_remove(&scene_output->output_mode.link);
@ -1597,6 +1599,8 @@ bool wlr_scene_output_commit(struct wlr_scene_output *scene_output) {
wlr_output_render_software_cursors(output, &damage); wlr_output_render_software_cursors(output, &damage);
wlr_frame_scheduler_mark_render_submitted(&scene_output->frame_scheduler,
renderer);
wlr_renderer_end(renderer); wlr_renderer_end(renderer);
pixman_region32_fini(&damage); pixman_region32_fini(&damage);