ecore_drm2: Try to mmap gbm buffers
We're currently doing screenshots in E under wayland by copying data out of the framebuffer, mmaping gbm buffers makes screenshots work again when rendering with GL.
This commit is contained in:
parent
f48f565306
commit
f8e07c4d7c
|
@ -108,7 +108,9 @@ err:
|
||||||
EAPI Ecore_Drm2_Fb *
|
EAPI Ecore_Drm2_Fb *
|
||||||
ecore_drm2_fb_gbm_create(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int handle, unsigned int stride)
|
ecore_drm2_fb_gbm_create(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int handle, unsigned int stride)
|
||||||
{
|
{
|
||||||
|
struct drm_mode_map_dumb marg;
|
||||||
Ecore_Drm2_Fb *fb;
|
Ecore_Drm2_Fb *fb;
|
||||||
|
int ret;
|
||||||
|
|
||||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((fd < 0), NULL);
|
EINA_SAFETY_ON_TRUE_RETURN_VAL((fd < 0), NULL);
|
||||||
|
|
||||||
|
@ -141,6 +143,15 @@ ecore_drm2_fb_gbm_create(int fd, int width, int height, int depth, int bpp, unsi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* mmap it if we can so screenshots are easy */
|
||||||
|
memset(&marg, 0, sizeof(struct drm_mode_map_dumb));
|
||||||
|
marg.handle = fb->hdl;
|
||||||
|
ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &marg);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
fb->mmap = mmap(NULL, fb->size, PROT_WRITE, MAP_SHARED, fd, marg.offset);
|
||||||
|
if (fb->mmap == MAP_FAILED) fb->mmap = NULL;
|
||||||
|
}
|
||||||
return fb;
|
return fb;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
@ -153,14 +164,14 @@ ecore_drm2_fb_destroy(Ecore_Drm2_Fb *fb)
|
||||||
{
|
{
|
||||||
EINA_SAFETY_ON_NULL_RETURN(fb);
|
EINA_SAFETY_ON_NULL_RETURN(fb);
|
||||||
|
|
||||||
|
if (fb->mmap) munmap(fb->mmap, fb->size);
|
||||||
|
|
||||||
if (fb->id) drmModeRmFB(fb->fd, fb->id);
|
if (fb->id) drmModeRmFB(fb->fd, fb->id);
|
||||||
|
|
||||||
if (!fb->gbm)
|
if (!fb->gbm)
|
||||||
{
|
{
|
||||||
struct drm_mode_destroy_dumb darg;
|
struct drm_mode_destroy_dumb darg;
|
||||||
|
|
||||||
if (fb->mmap) munmap(fb->mmap, fb->size);
|
|
||||||
|
|
||||||
memset(&darg, 0, sizeof(struct drm_mode_destroy_dumb));
|
memset(&darg, 0, sizeof(struct drm_mode_destroy_dumb));
|
||||||
darg.handle = fb->hdl;
|
darg.handle = fb->hdl;
|
||||||
drmIoctl(fb->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &darg);
|
drmIoctl(fb->fd, DRM_IOCTL_MODE_DESTROY_DUMB, &darg);
|
||||||
|
|
Loading…
Reference in New Issue