backend/drm: Track page flips in list

master
Alexander Orzechowski 1 year ago
parent 3b53d1cbf1
commit 3aed24b8d4

@ -207,6 +207,7 @@ struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,
drm->session = session; drm->session = session;
wl_list_init(&drm->fbs); wl_list_init(&drm->fbs);
wl_list_init(&drm->connectors); wl_list_init(&drm->connectors);
wl_list_init(&drm->page_flips);
drm->dev = dev; drm->dev = dev;
drm->fd = dev->fd; drm->fd = dev->fd;

@ -420,6 +420,15 @@ static void drm_connector_set_pending_page_flip(struct wlr_drm_connector *conn,
conn->pending_page_flip = page_flip; conn->pending_page_flip = page_flip;
} }
static void page_flip_destroy(struct wlr_drm_page_flip *page_flip) {
if (!page_flip) {
return;
}
wl_list_remove(&page_flip->link);
free(page_flip);
}
static bool drm_crtc_commit(struct wlr_drm_connector *conn, static bool drm_crtc_commit(struct wlr_drm_connector *conn,
const struct wlr_drm_connector_state *state, const struct wlr_drm_connector_state *state,
uint32_t flags, bool test_only) { uint32_t flags, bool test_only) {
@ -433,6 +442,7 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn,
return false; return false;
} }
page_flip->conn = conn; page_flip->conn = conn;
wl_list_insert(&conn->backend->page_flips, &page_flip->link);
} }
struct wlr_drm_backend *drm = conn->backend; struct wlr_drm_backend *drm = conn->backend;
@ -466,7 +476,7 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn,
drm_fb_clear(&layer->pending_fb); drm_fb_clear(&layer->pending_fb);
} }
free(page_flip); page_flip_destroy(page_flip);
} }
return ok; return ok;
} }
@ -1686,7 +1696,7 @@ static void handle_page_flip(int fd, unsigned seq,
if (conn != NULL) { if (conn != NULL) {
conn->pending_page_flip = NULL; conn->pending_page_flip = NULL;
} }
free(page_flip); page_flip_destroy(page_flip);
if (conn == NULL) { if (conn == NULL) {
return; return;

@ -104,6 +104,8 @@ struct wlr_drm_backend {
struct wl_list fbs; // wlr_drm_fb.link struct wl_list fbs; // wlr_drm_fb.link
struct wl_list connectors; // wlr_drm_connector.link struct wl_list connectors; // wlr_drm_connector.link
struct wl_list page_flips; // wlr_drm_page_flip.link
/* Only initialized on multi-GPU setups */ /* Only initialized on multi-GPU setups */
struct wlr_drm_renderer mgpu_renderer; struct wlr_drm_renderer mgpu_renderer;
@ -142,6 +144,7 @@ struct wlr_drm_connector_state {
* that it's been superseded. * that it's been superseded.
*/ */
struct wlr_drm_page_flip { struct wlr_drm_page_flip {
struct wl_list link; // wlr_drm_connector.page_flips
struct wlr_drm_connector *conn; struct wlr_drm_connector *conn;
}; };

Loading…
Cancel
Save