Merge pull request #1526 from VincentVanlaer/cursor-dmabuf

Allow cursor render surface to be used as fb
This commit is contained in:
Scott Anderson 2019-02-04 21:34:40 +00:00 committed by GitHub
commit b2f56ad4a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 33 deletions

View File

@ -104,7 +104,7 @@ static void session_signal(struct wl_listener *listener, void *data) {
struct wlr_drm_plane *plane = conn->crtc->cursor; struct wlr_drm_plane *plane = conn->crtc->cursor;
drm->iface->crtc_set_cursor(drm, conn->crtc, drm->iface->crtc_set_cursor(drm, conn->crtc,
(plane && plane->cursor_enabled) ? plane->cursor_bo : NULL); (plane && plane->cursor_enabled) ? plane->surf.back : NULL);
drm->iface->crtc_move_cursor(drm, conn->crtc, conn->cursor_x, drm->iface->crtc_move_cursor(drm, conn->crtc, conn->cursor_x,
conn->cursor_y); conn->cursor_y);

View File

@ -226,12 +226,6 @@ void finish_drm_resources(struct wlr_drm_backend *drm) {
} }
free(crtc->gamma_table); free(crtc->gamma_table);
} }
for (size_t i = 0; i < drm->num_planes; ++i) {
struct wlr_drm_plane *plane = &drm->planes[i];
if (plane->cursor_bo) {
gbm_bo_destroy(plane->cursor_bo);
}
}
free(drm->crtcs); free(drm->crtcs);
free(drm->planes); free(drm->planes);
@ -642,17 +636,10 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
drm->parent ? &drm->parent->renderer : &drm->renderer; drm->parent ? &drm->parent->renderer : &drm->renderer;
if (!init_drm_surface(&plane->surf, renderer, w, h, if (!init_drm_surface(&plane->surf, renderer, w, h,
renderer->gbm_format, 0)) { renderer->gbm_format, GBM_BO_USE_LINEAR | GBM_BO_USE_SCANOUT)) {
wlr_log(WLR_ERROR, "Cannot allocate cursor resources"); wlr_log(WLR_ERROR, "Cannot allocate cursor resources");
return false; return false;
} }
plane->cursor_bo = gbm_bo_create(drm->renderer.gbm, w, h,
renderer->gbm_format, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE);
if (!plane->cursor_bo) {
wlr_log_errno(WLR_ERROR, "Failed to create cursor bo");
return false;
}
} }
wlr_matrix_projection(plane->matrix, plane->surf.width, wlr_matrix_projection(plane->matrix, plane->surf.width,
@ -697,17 +684,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
return false; return false;
} }
uint32_t bo_width = gbm_bo_get_width(plane->cursor_bo);
uint32_t bo_height = gbm_bo_get_height(plane->cursor_bo);
uint32_t bo_stride;
void *bo_data;
if (!gbm_bo_map(plane->cursor_bo, 0, 0, bo_width, bo_height,
GBM_BO_TRANSFER_WRITE, &bo_stride, &bo_data)) {
wlr_log_errno(WLR_ERROR, "Unable to map buffer");
return false;
}
make_drm_surface_current(&plane->surf, NULL); make_drm_surface_current(&plane->surf, NULL);
struct wlr_renderer *rend = plane->surf.renderer->wlr_rend; struct wlr_renderer *rend = plane->surf.renderer->wlr_rend;
@ -722,13 +698,8 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
wlr_render_texture_with_matrix(rend, texture, matrix, 1.0); wlr_render_texture_with_matrix(rend, texture, matrix, 1.0);
wlr_renderer_end(rend); wlr_renderer_end(rend);
wlr_renderer_read_pixels(rend, WL_SHM_FORMAT_ARGB8888, NULL, bo_stride,
plane->surf.width, plane->surf.height, 0, 0, 0, 0, bo_data);
swap_drm_surface_buffers(&plane->surf, NULL); swap_drm_surface_buffers(&plane->surf, NULL);
gbm_bo_unmap(plane->cursor_bo, bo_data);
plane->cursor_enabled = true; plane->cursor_enabled = true;
} }
@ -736,7 +707,7 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
return true; // will be committed when session is resumed return true; // will be committed when session is resumed
} }
struct gbm_bo *bo = plane->cursor_enabled ? plane->cursor_bo : NULL; struct gbm_bo *bo = plane->cursor_enabled ? plane->surf.back : NULL;
bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo); bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo);
if (ok) { if (ok) {
wlr_output_update_needs_swap(output); wlr_output_update_needs_swap(output);

View File

@ -30,7 +30,6 @@ struct wlr_drm_plane {
// Only used by cursor // Only used by cursor
float matrix[9]; float matrix[9];
struct gbm_bo *cursor_bo;
bool cursor_enabled; bool cursor_enabled;
int32_t cursor_hotspot_x, cursor_hotspot_y; int32_t cursor_hotspot_x, cursor_hotspot_y;