render-device: Add API to allocate dumb buffers
All render devices that have a device file backing them might be able to allocate dumb buffers, so add a helper for doing that. Will indirectly result in an error up front on a surfaceless render device due to lack of a device file. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
This commit is contained in:
parent
986588ade2
commit
8662f33b9e
@ -25,6 +25,7 @@
|
|||||||
#include "backends/meta-backend-private.h"
|
#include "backends/meta-backend-private.h"
|
||||||
#include "backends/meta-egl.h"
|
#include "backends/meta-egl.h"
|
||||||
#include "backends/native/meta-backend-native-types.h"
|
#include "backends/native/meta-backend-native-types.h"
|
||||||
|
#include "backends/native/meta-drm-buffer-dumb.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -381,3 +382,31 @@ meta_render_device_import_dma_buf (MetaRenderDevice *render_device,
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaDrmBuffer *
|
||||||
|
meta_render_device_allocate_dumb_buf (MetaRenderDevice *render_device,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
uint32_t format,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
MetaRenderDevicePrivate *priv =
|
||||||
|
meta_render_device_get_instance_private (render_device);
|
||||||
|
MetaDrmBufferDumb *buffer_dumb;
|
||||||
|
|
||||||
|
if (!priv->device_file)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||||
|
"No device file to allocate from");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer_dumb = meta_drm_buffer_dumb_new (priv->device_file,
|
||||||
|
width, height,
|
||||||
|
format,
|
||||||
|
error);
|
||||||
|
if (!buffer_dumb)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return META_DRM_BUFFER (buffer_dumb);
|
||||||
|
}
|
||||||
|
@ -52,4 +52,10 @@ MetaDrmBuffer * meta_render_device_import_dma_buf (MetaRenderDevice *render_dev
|
|||||||
MetaDrmBuffer *buffer,
|
MetaDrmBuffer *buffer,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
MetaDrmBuffer * meta_render_device_allocate_dumb_buf (MetaRenderDevice *render_device,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
uint32_t format,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
#endif /* META_RENDER_DEVICE_H */
|
#endif /* META_RENDER_DEVICE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user