aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-07-28 10:47:20 +0200
committerSimon Ser <contact@emersion.fr>2020-11-15 22:48:42 +0100
commit8058e338eaf7c43df25735b0756983ff6b709eae (patch)
tree608d88059e3af19955d9e69d9bd0268d73d9cc9a /backend/drm
parent68a8d9905513c0277037cc74325bb2ea507ac012 (diff)
backend/drm: get rid of wlr_drm_fb_type
Since all DRM FBs are backed by a wlr_buffer, there's no need for this anymore.
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/drm.c20
-rw-r--r--backend/drm/renderer.c25
2 files changed, 19 insertions, 26 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index bd482be3..95f8c3d0 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -377,7 +377,7 @@ static bool drm_crtc_page_flip(struct wlr_drm_connector *conn) {
}
assert(crtc->pending.active);
- assert(plane_get_next_fb(crtc->primary)->type != WLR_DRM_FB_TYPE_NONE);
+ assert(plane_get_next_fb(crtc->primary)->bo);
if (!drm_crtc_commit(conn, DRM_MODE_PAGE_FLIP_EVENT)) {
return false;
}
@@ -650,10 +650,10 @@ static bool drm_connector_export_dmabuf(struct wlr_output *output,
}
struct wlr_drm_fb *fb = &crtc->primary->queued_fb;
- if (fb->type == WLR_DRM_FB_TYPE_NONE) {
+ if (fb->bo == NULL) {
fb = &crtc->primary->current_fb;
}
- if (fb->type == WLR_DRM_FB_TYPE_NONE) {
+ if (fb->bo == NULL) {
return false;
}
@@ -661,10 +661,10 @@ static bool drm_connector_export_dmabuf(struct wlr_output *output,
}
struct wlr_drm_fb *plane_get_next_fb(struct wlr_drm_plane *plane) {
- if (plane->pending_fb.type != WLR_DRM_FB_TYPE_NONE) {
+ if (plane->pending_fb.bo) {
return &plane->pending_fb;
}
- if (plane->queued_fb.type != WLR_DRM_FB_TYPE_NONE) {
+ if (plane->queued_fb.bo) {
return &plane->queued_fb;
}
return &plane->current_fb;
@@ -680,7 +680,7 @@ static bool drm_connector_pageflip_renderer(struct wlr_drm_connector *conn) {
// drm_crtc_page_flip expects a FB to be available
struct wlr_drm_plane *plane = crtc->primary;
- if (plane_get_next_fb(plane)->type == WLR_DRM_FB_TYPE_NONE) {
+ if (!plane_get_next_fb(plane)->bo) {
drm_surface_render_black_frame(&plane->surf);
if (!drm_fb_lock_surface(&plane->pending_fb, &plane->surf)) {
return false;
@@ -1507,11 +1507,10 @@ static void page_flip_handler(int fd, unsigned seq,
}
struct wlr_drm_plane *plane = conn->crtc->primary;
- if (plane->queued_fb.type != WLR_DRM_FB_TYPE_NONE) {
+ if (plane->queued_fb.bo) {
drm_fb_move(&plane->current_fb, &plane->queued_fb);
}
- if (conn->crtc->cursor &&
- conn->crtc->cursor->queued_fb.type != WLR_DRM_FB_TYPE_NONE) {
+ if (conn->crtc->cursor && conn->crtc->cursor->queued_fb.bo) {
drm_fb_move(&conn->crtc->cursor->current_fb,
&conn->crtc->cursor->queued_fb);
}
@@ -1522,7 +1521,8 @@ static void page_flip_handler(int fd, unsigned seq,
* data between the GPUs, even if we were using the direct scanout
* interface.
*/
- if (!drm->parent && plane->current_fb.type == WLR_DRM_FB_TYPE_WLR_BUFFER) {
+ if (!drm->parent && plane->current_fb.wlr_buf &&
+ wlr_client_buffer_get(plane->current_fb.wlr_buf)) {
present_flags |= WLR_OUTPUT_PRESENT_ZERO_COPY;
}
diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c
index 1d6a3277..a841aecf 100644
--- a/backend/drm/renderer.c
+++ b/backend/drm/renderer.c
@@ -280,21 +280,15 @@ bool drm_plane_init_surface(struct wlr_drm_plane *plane,
}
void drm_fb_clear(struct wlr_drm_fb *fb) {
- switch (fb->type) {
- case WLR_DRM_FB_TYPE_NONE:
- assert(!fb->bo);
- break;
- case WLR_DRM_FB_TYPE_SURFACE:
- abort(); // TODO: remove this case entirely
- break;
- case WLR_DRM_FB_TYPE_WLR_BUFFER:
- gbm_bo_destroy(fb->bo);
- wlr_buffer_unlock(fb->wlr_buf);
- fb->wlr_buf = NULL;
- break;
- }
-
- fb->type = WLR_DRM_FB_TYPE_NONE;
+ if (!fb->bo) {
+ assert(!fb->wlr_buf);
+ return;
+ }
+
+ gbm_bo_destroy(fb->bo);
+ wlr_buffer_unlock(fb->wlr_buf);
+
+ fb->wlr_buf = NULL;
fb->bo = NULL;
if (fb->mgpu_bo) {
@@ -376,7 +370,6 @@ bool drm_fb_import_wlr(struct wlr_drm_fb *fb, struct wlr_drm_renderer *renderer,
return false;
}
- fb->type = WLR_DRM_FB_TYPE_WLR_BUFFER;
fb->wlr_buf = wlr_buffer_lock(buf);
return true;