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. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4027>
This commit is contained in:
parent
ada199621c
commit
dfa3755f55
@ -22,6 +22,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "backends/native/meta-drm-buffer-gbm.h"
|
#include "backends/native/meta-drm-buffer-gbm.h"
|
||||||
|
#include "backends/native/meta-egl-gbm.h"
|
||||||
|
|
||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -292,67 +293,31 @@ 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_egl_ensure_gbm_bo_egl_image (egl,
|
||||||
if (dmabuf_fd == -1)
|
egl_display,
|
||||||
{
|
buffer_gbm->bo,
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
|
error);
|
||||||
"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,
|
||||||
@ -388,7 +353,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…
x
Reference in New Issue
Block a user