[mutter] render-device: Add API to allocate dumb buffers



commit 8662f33b9ed95f727e62ae845f2a4b45144eb657
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed May 5 15:40:23 2021 +0200

    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>

 src/backends/native/meta-render-device.c | 29 +++++++++++++++++++++++++++++
 src/backends/native/meta-render-device.h |  6 ++++++
 2 files changed, 35 insertions(+)
---
diff --git a/src/backends/native/meta-render-device.c b/src/backends/native/meta-render-device.c
index 389724dd0b..982f308149 100644
--- a/src/backends/native/meta-render-device.c
+++ b/src/backends/native/meta-render-device.c
@@ -25,6 +25,7 @@
 #include "backends/meta-backend-private.h"
 #include "backends/meta-egl.h"
 #include "backends/native/meta-backend-native-types.h"
+#include "backends/native/meta-drm-buffer-dumb.h"
 
 enum
 {
@@ -381,3 +382,31 @@ meta_render_device_import_dma_buf (MetaRenderDevice  *render_device,
 
   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);
+}
diff --git a/src/backends/native/meta-render-device.h b/src/backends/native/meta-render-device.h
index 9428283b9e..4666813534 100644
--- a/src/backends/native/meta-render-device.h
+++ b/src/backends/native/meta-render-device.h
@@ -52,4 +52,10 @@ MetaDrmBuffer * meta_render_device_import_dma_buf (MetaRenderDevice  *render_dev
                                                    MetaDrmBuffer     *buffer,
                                                    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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]