diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 3395bc695..cc90e99e3 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -467,10 +467,7 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn, struct wlr_drm_crtc *crtc = conn->crtc; bool ok = drm->iface->crtc_commit(conn, state, page_flip, flags, test_only); if (ok && !test_only) { - drm_fb_clear(&crtc->primary->queued_fb); - if (state->primary_fb != NULL) { - crtc->primary->queued_fb = drm_fb_lock(state->primary_fb); - } + drm_fb_copy(&crtc->primary->queued_fb, state->primary_fb); if (crtc->cursor != NULL && conn->cursor_pending_fb != NULL) { drm_fb_move(&crtc->cursor->queued_fb, &conn->cursor_pending_fb); } diff --git a/backend/drm/fb.c b/backend/drm/fb.c index 24d805832..575f32d91 100644 --- a/backend/drm/fb.c +++ b/backend/drm/fb.c @@ -249,3 +249,10 @@ void drm_fb_move(struct wlr_drm_fb **new, struct wlr_drm_fb **old) { *new = *old; *old = NULL; } + +void drm_fb_copy(struct wlr_drm_fb **new, struct wlr_drm_fb *old) { + drm_fb_clear(new); + if (old != NULL) { + *new = drm_fb_lock(old); + } +} diff --git a/include/backend/drm/fb.h b/include/backend/drm/fb.h index 7d451bc69..91d0fffcc 100644 --- a/include/backend/drm/fb.h +++ b/include/backend/drm/fb.h @@ -17,6 +17,7 @@ bool drm_fb_import(struct wlr_drm_fb **fb, struct wlr_drm_backend *drm, void drm_fb_destroy(struct wlr_drm_fb *fb); void drm_fb_clear(struct wlr_drm_fb **fb); +void drm_fb_copy(struct wlr_drm_fb **new, struct wlr_drm_fb *old); void drm_fb_move(struct wlr_drm_fb **new, struct wlr_drm_fb **old); struct wlr_drm_fb *drm_fb_lock(struct wlr_drm_fb *fb);