|
|
@ -160,17 +160,33 @@ void post_drm_surface(struct wlr_drm_surface *surf) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void export_drm_bo(struct gbm_bo *bo,
|
|
|
|
bool export_drm_bo(struct gbm_bo *bo,
|
|
|
|
struct wlr_dmabuf_buffer_attribs *attribs) {
|
|
|
|
struct wlr_dmabuf_buffer_attribs *attribs) {
|
|
|
|
memset(attribs, 0, sizeof(struct wlr_dmabuf_buffer_attribs));
|
|
|
|
memset(attribs, 0, sizeof(struct wlr_dmabuf_buffer_attribs));
|
|
|
|
attribs->n_planes = 1;
|
|
|
|
|
|
|
|
|
|
|
|
attribs->n_planes = gbm_bo_get_plane_count(bo);
|
|
|
|
|
|
|
|
if (attribs->n_planes > WLR_LINUX_DMABUF_MAX_PLANES) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
attribs->width = gbm_bo_get_width(bo);
|
|
|
|
attribs->width = gbm_bo_get_width(bo);
|
|
|
|
attribs->height = gbm_bo_get_height(bo);
|
|
|
|
attribs->height = gbm_bo_get_height(bo);
|
|
|
|
attribs->format = gbm_bo_get_format(bo);
|
|
|
|
attribs->format = gbm_bo_get_format(bo);
|
|
|
|
attribs->offset[0] = 0;
|
|
|
|
|
|
|
|
attribs->stride[0] = gbm_bo_get_stride_for_plane(bo, 0);
|
|
|
|
for (int i = 0; i < attribs->n_planes; ++i) {
|
|
|
|
attribs->modifier[0] = DRM_FORMAT_MOD_LINEAR;
|
|
|
|
attribs->offset[i] = gbm_bo_get_offset(bo, i);
|
|
|
|
attribs->fd[0] = gbm_bo_get_fd(bo);
|
|
|
|
attribs->stride[i] = gbm_bo_get_stride_for_plane(bo, i);
|
|
|
|
|
|
|
|
attribs->modifier[i] = gbm_bo_get_modifier(bo);
|
|
|
|
|
|
|
|
attribs->fd[i] = gbm_bo_get_fd(bo);
|
|
|
|
|
|
|
|
if (attribs->fd[i] < 0) {
|
|
|
|
|
|
|
|
for (int j = 0; j < i; ++j) {
|
|
|
|
|
|
|
|
close(attribs->fd[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct tex {
|
|
|
|
struct tex {
|
|
|
@ -200,7 +216,10 @@ static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_dmabuf_buffer_attribs attribs;
|
|
|
|
struct wlr_dmabuf_buffer_attribs attribs;
|
|
|
|
export_drm_bo(bo, &attribs);
|
|
|
|
if (!export_drm_bo(bo, &attribs)) {
|
|
|
|
|
|
|
|
free(tex);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tex->tex = wlr_texture_from_dmabuf(renderer->wlr_rend, &attribs);
|
|
|
|
tex->tex = wlr_texture_from_dmabuf(renderer->wlr_rend, &attribs);
|
|
|
|
if (tex->tex == NULL) {
|
|
|
|
if (tex->tex == NULL) {
|
|
|
|