drm-buffer-gbm: Cache EGLImages created during screen-casting
This consolidates duplicate code in meta_drm_buffer_gbm_blit_to_framebuffer to use the newly added meta_drm_buffer_gbm_create_native_blit_image, which also has the side-effect of caching creation of the EGLImage per GBM BO. (cherry picked from commit c866ca2206ab279f639fa452f43812abd9be243a) Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4027> Signed-off-by: Mingi Sung <sungmg@saltyming.net>
This commit is contained in:
parent
09c8a4c8a3
commit
61fd95e495
1 changed files with 10 additions and 50 deletions
|
@ -384,67 +384,28 @@ meta_drm_buffer_gbm_blit_to_framebuffer (CoglScanout *scanout,
|
||||||
CoglEglImageFlags flags;
|
CoglEglImageFlags flags;
|
||||||
CoglOffscreen *cogl_fbo = NULL;
|
CoglOffscreen *cogl_fbo = NULL;
|
||||||
CoglTexture *cogl_tex;
|
CoglTexture *cogl_tex;
|
||||||
uint32_t n_planes;
|
|
||||||
uint64_t *modifiers;
|
|
||||||
uint32_t *strides;
|
|
||||||
uint32_t *offsets;
|
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
uint32_t drm_format;
|
uint32_t format;
|
||||||
int *fds;
|
|
||||||
gboolean result;
|
gboolean result;
|
||||||
int dmabuf_fd = -1;
|
|
||||||
uint32_t i;
|
|
||||||
const MetaFormatInfo *format_info;
|
const MetaFormatInfo *format_info;
|
||||||
|
|
||||||
dmabuf_fd = gbm_bo_get_fd (buffer_gbm->bo);
|
egl_image = meta_drm_buffer_gbm_create_native_blit_image (egl, egl_display, buffer_gbm->bo, error);
|
||||||
if (dmabuf_fd == -1)
|
|
||||||
{
|
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
|
|
||||||
"Failed to export buffer's DMA fd: %s",
|
|
||||||
g_strerror (errno));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
drm_format = gbm_bo_get_format (buffer_gbm->bo);
|
|
||||||
|
|
||||||
format_info = meta_format_info_from_drm_format (drm_format);
|
|
||||||
g_assert (format_info);
|
|
||||||
cogl_format = format_info->cogl_format;
|
|
||||||
|
|
||||||
width = gbm_bo_get_width (buffer_gbm->bo);
|
|
||||||
height = gbm_bo_get_height (buffer_gbm->bo);
|
|
||||||
n_planes = gbm_bo_get_plane_count (buffer_gbm->bo);
|
|
||||||
fds = g_alloca (sizeof (int) * n_planes);
|
|
||||||
strides = g_alloca (sizeof (uint32_t) * n_planes);
|
|
||||||
offsets = g_alloca (sizeof (uint32_t) * n_planes);
|
|
||||||
modifiers = g_alloca (sizeof (uint64_t) * n_planes);
|
|
||||||
|
|
||||||
for (i = 0; i < n_planes; i++)
|
|
||||||
{
|
|
||||||
fds[i] = dmabuf_fd;
|
|
||||||
strides[i] = gbm_bo_get_stride_for_plane (buffer_gbm->bo, i);
|
|
||||||
offsets[i] = gbm_bo_get_offset (buffer_gbm->bo, i);
|
|
||||||
modifiers[i] = gbm_bo_get_modifier (buffer_gbm->bo);
|
|
||||||
}
|
|
||||||
|
|
||||||
egl_image = meta_egl_create_dmabuf_image (egl,
|
|
||||||
egl_display,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
drm_format,
|
|
||||||
n_planes,
|
|
||||||
fds,
|
|
||||||
strides,
|
|
||||||
offsets,
|
|
||||||
modifiers,
|
|
||||||
error);
|
|
||||||
if (egl_image == EGL_NO_IMAGE_KHR)
|
if (egl_image == EGL_NO_IMAGE_KHR)
|
||||||
{
|
{
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
width = gbm_bo_get_width (buffer_gbm->bo);
|
||||||
|
height = gbm_bo_get_height (buffer_gbm->bo);
|
||||||
|
format = gbm_bo_get_format (buffer_gbm->bo);
|
||||||
|
|
||||||
|
format_info = meta_format_info_from_drm_format (format);
|
||||||
|
g_assert (format_info);
|
||||||
|
cogl_format = format_info->cogl_format;
|
||||||
|
|
||||||
flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA;
|
flags = COGL_EGL_IMAGE_FLAG_NO_GET_DATA;
|
||||||
cogl_tex = cogl_texture_2d_new_from_egl_image (cogl_context,
|
cogl_tex = cogl_texture_2d_new_from_egl_image (cogl_context,
|
||||||
width,
|
width,
|
||||||
|
@ -480,7 +441,6 @@ meta_drm_buffer_gbm_blit_to_framebuffer (CoglScanout *scanout,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_clear_object (&cogl_fbo);
|
g_clear_object (&cogl_fbo);
|
||||||
close (dmabuf_fd);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue