drm-buffer: Keep track of handle as well

This handle is used by the legacy KMS API; lets avoid having to have GBM
specific code where this is done by letting the MetaDrmBuffer API, that
already has this information, expose it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2275>
This commit is contained in:
Jonas Ådahl 2022-02-08 15:58:33 +01:00 committed by Marge Bot
parent d19700604b
commit 22d11eb9cb
6 changed files with 17 additions and 0 deletions

View File

@ -248,6 +248,7 @@ init_dumb_buffer (MetaDrmBufferDumb *buffer_dumb,
.width = width,
.height = height,
.format = format,
.handle = create_arg.handle,
.handles = { create_arg.handle },
.strides = { create_arg.pitch },
};

View File

@ -164,6 +164,7 @@ meta_drm_buffer_gbm_ensure_fb_id (MetaDrmBuffer *buffer,
fb_args.width = gbm_bo_get_width (bo);
fb_args.height = gbm_bo_get_height (bo);
fb_args.format = gbm_bo_get_format (bo);
fb_args.handle = gbm_bo_get_handle (bo).u32;
if (!meta_drm_buffer_do_ensure_fb_id (META_DRM_BUFFER (buffer_gbm),
&fb_args, error))

View File

@ -162,6 +162,7 @@ import_gbm_buffer (MetaDrmBufferImport *buffer_import,
fb_args.width = gbm_bo_get_width (primary_bo);
fb_args.height = gbm_bo_get_height (primary_bo);
fb_args.format = gbm_bo_get_format (primary_bo);
fb_args.handle = gbm_bo_get_handle (primary_bo).u32;
imported_bo = dmabuf_to_gbm_bo (importer,
dmabuf_fd,

View File

@ -33,6 +33,7 @@ typedef struct _MetaDrmFbArgs
uint32_t offsets[4];
uint32_t strides[4];
uint64_t modifiers[4];
uint32_t handle;
} MetaDrmFbArgs;
struct _MetaDrmBufferClass

View File

@ -53,6 +53,7 @@ typedef struct _MetaDrmBufferPrivate
MetaDrmBufferFlags flags;
uint32_t fb_id;
uint32_t handle;
} MetaDrmBufferPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaDrmBuffer, meta_drm_buffer,
@ -152,6 +153,8 @@ meta_drm_buffer_do_ensure_fb_id (MetaDrmBuffer *buffer,
}
priv->fb_id = fb_id;
priv->handle = fb_args->handle;
return TRUE;
}
@ -185,6 +188,14 @@ meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer)
return priv->fb_id;
}
uint32_t
meta_drm_buffer_get_handle (MetaDrmBuffer *buffer)
{
MetaDrmBufferPrivate *priv = meta_drm_buffer_get_instance_private (buffer);
return priv->handle;
}
int
meta_drm_buffer_get_width (MetaDrmBuffer *buffer)
{

View File

@ -50,6 +50,8 @@ gboolean meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer,
uint32_t meta_drm_buffer_get_fb_id (MetaDrmBuffer *buffer);
uint32_t meta_drm_buffer_get_handle (MetaDrmBuffer *buffer);
int meta_drm_buffer_get_width (MetaDrmBuffer *buffer);
int meta_drm_buffer_get_height (MetaDrmBuffer *buffer);