backend/drm: add drm_fb_copy()

Similar to drm_fb_move(), but leaves old as-is.
This commit is contained in:
Simon Ser 2024-02-28 14:05:20 +01:00
parent 1a54d33e77
commit f6659414ba
3 changed files with 9 additions and 4 deletions

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);