|
|
@ -188,46 +188,29 @@ bool export_drm_bo(struct gbm_bo *bo, struct wlr_dmabuf_attributes *attribs) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct tex {
|
|
|
|
static void free_tex(struct gbm_bo *bo, void *data) {
|
|
|
|
struct wlr_egl *egl;
|
|
|
|
struct wlr_texture *tex = data;
|
|
|
|
EGLImageKHR img;
|
|
|
|
wlr_texture_destroy(tex);
|
|
|
|
struct wlr_texture *tex;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void free_eglimage(struct gbm_bo *bo, void *data) {
|
|
|
|
|
|
|
|
struct tex *tex = data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wlr_egl_destroy_image(tex->egl, tex->img);
|
|
|
|
|
|
|
|
wlr_texture_destroy(tex->tex);
|
|
|
|
|
|
|
|
free(tex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer,
|
|
|
|
static struct wlr_texture *get_tex_for_bo(struct wlr_drm_renderer *renderer,
|
|
|
|
struct gbm_bo *bo) {
|
|
|
|
struct gbm_bo *bo) {
|
|
|
|
struct tex *tex = gbm_bo_get_user_data(bo);
|
|
|
|
struct wlr_texture *tex = gbm_bo_get_user_data(bo);
|
|
|
|
if (tex != NULL) {
|
|
|
|
if (tex) {
|
|
|
|
return tex->tex;
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tex = calloc(1, sizeof(struct tex));
|
|
|
|
|
|
|
|
if (tex == NULL) {
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_dmabuf_attributes attribs;
|
|
|
|
struct wlr_dmabuf_attributes attribs;
|
|
|
|
if (!export_drm_bo(bo, &attribs)) {
|
|
|
|
if (!export_drm_bo(bo, &attribs)) {
|
|
|
|
free(tex);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tex->tex = wlr_texture_from_dmabuf(renderer->wlr_rend, &attribs);
|
|
|
|
tex = wlr_texture_from_dmabuf(renderer->wlr_rend, &attribs);
|
|
|
|
if (tex->tex == NULL) {
|
|
|
|
if (tex) {
|
|
|
|
free(tex);
|
|
|
|
gbm_bo_set_user_data(bo, tex, free_tex);
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gbm_bo_set_user_data(bo, tex, free_eglimage);
|
|
|
|
return tex;
|
|
|
|
return tex->tex;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct gbm_bo *copy_drm_surface_mgpu(struct wlr_drm_surface *dest,
|
|
|
|
struct gbm_bo *copy_drm_surface_mgpu(struct wlr_drm_surface *dest,
|
|
|
|