summaryrefslogtreecommitdiff
path: root/src/backends/native/meta-drm-buffer.c
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2021-05-05 10:15:18 +0200
committerJonas Ådahl <jadahl@gmail.com>2021-10-18 17:33:33 +0200
commit6ba86366b3b6d4e97cce872dc569c7d96b5d083a (patch)
tree005e71d0c106e8fc9a415a130d264fa207863dee /src/backends/native/meta-drm-buffer.c
parent99f51d28665a1b39a1a1431e2bfc0d0f823ac0ec (diff)
downloadmutter-6ba86366b3b6d4e97cce872dc569c7d96b5d083a.tar.gz
drm-buffer: Replace 'use-modifier' boolean with flags
This lets us add more customization to the buffer instance without adding more boolean arguments. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
Diffstat (limited to 'src/backends/native/meta-drm-buffer.c')
-rw-r--r--src/backends/native/meta-drm-buffer.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/backends/native/meta-drm-buffer.c b/src/backends/native/meta-drm-buffer.c
index 5e60f9a5e..4ec9d820c 100644
--- a/src/backends/native/meta-drm-buffer.c
+++ b/src/backends/native/meta-drm-buffer.c
@@ -31,6 +31,8 @@
#include "backends/native/meta-device-pool.h"
#include "backends/native/meta-kms-utils.h"
+#include "meta-private-enum-types.h"
+
#define INVALID_FB_ID 0U
enum
@@ -38,6 +40,7 @@ enum
PROP_0,
PROP_DEVICE_FILE,
+ PROP_FLAGS,
N_PROPS
};
@@ -47,6 +50,8 @@ static GParamSpec *obj_props[N_PROPS];
typedef struct _MetaDrmBufferPrivate
{
MetaDeviceFile *device_file;
+ MetaDrmBufferFlags flags;
+
uint32_t fb_id;
} MetaDrmBufferPrivate;
@@ -63,7 +68,6 @@ meta_drm_buffer_get_device_file (MetaDrmBuffer *buffer)
gboolean
meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer,
- gboolean use_modifiers,
const MetaDrmFbArgs *fb_args,
GError **error)
{
@@ -74,7 +78,8 @@ meta_drm_buffer_ensure_fb_id (MetaDrmBuffer *buffer,
fd = meta_device_file_get_fd (priv->device_file);
- if (use_modifiers && fb_args->modifiers[0] != DRM_FORMAT_MOD_INVALID)
+ if (!(priv->flags & META_DRM_BUFFER_FLAG_DISABLE_MODIFIERS) &&
+ fb_args->modifiers[0] != DRM_FORMAT_MOD_INVALID)
{
if (drmModeAddFB2WithModifiers (fd,
fb_args->width,
@@ -239,6 +244,9 @@ meta_drm_buffer_get_property (GObject *object,
case PROP_DEVICE_FILE:
g_value_set_pointer (value, priv->device_file);
break;
+ case PROP_FLAGS:
+ g_value_set_flags (value, priv->flags);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -259,6 +267,9 @@ meta_drm_buffer_set_property (GObject *object,
case PROP_DEVICE_FILE:
priv->device_file = g_value_get_pointer (value);
break;
+ case PROP_FLAGS:
+ priv->flags = g_value_get_flags (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -311,5 +322,14 @@ meta_drm_buffer_class_init (MetaDrmBufferClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
+ obj_props[PROP_FLAGS] =
+ g_param_spec_flags ("flags",
+ "flags",
+ "MetaDrmBufferFlags",
+ META_TYPE_DRM_BUFFER_FLAGS,
+ META_DRM_BUFFER_FLAG_NONE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, obj_props);
}