From 5964ccb3856853dbf7b06b8e4a755c4546980295 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Wed, 3 Jan 2024 10:52:08 +0100 Subject: [PATCH] wayland: Fix building without native backend Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1026 Part-of: --- src/core/meta-context-main.c | 4 +-- src/wayland/meta-wayland-dma-buf.c | 43 ++++++++++++++++++------------ src/wayland/meta-wayland.c | 2 ++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/core/meta-context-main.c b/src/core/meta-context-main.c index 9592bb005..890c29497 100644 --- a/src/core/meta-context-main.c +++ b/src/core/meta-context-main.c @@ -25,9 +25,9 @@ #include #include -#if defined(HAVE_NATIVE_BACKEND) && defined(HAVE_WAYLAND) +#ifdef HAVE_WAYLAND #include -#endif /* HAVE_WAYLAND && HAVE_NATIVE_BACKEND */ +#endif #include "backends/meta-monitor-manager-private.h" #include "backends/meta-virtual-monitor.h" diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c index 233bae61e..333a12f66 100644 --- a/src/wayland/meta-wayland-dma-buf.c +++ b/src/wayland/meta-wayland-dma-buf.c @@ -148,28 +148,13 @@ G_DEFINE_TYPE (MetaWaylandDmaBufManager, meta_wayland_dma_buf_manager, static GQuark quark_dma_buf_surface_feedback; +#ifdef HAVE_NATIVE_BACKEND static gboolean -should_send_modifiers (MetaBackend *backend) +should_send_modifiers_native (MetaBackend *backend) { MetaRendererNative *renderer_native; MetaGpuKms *gpu_kms; - if (!META_IS_BACKEND_NATIVE (backend)) - { - MetaEgl *egl = meta_backend_get_egl (backend); - ClutterBackend *clutter_backend = - meta_backend_get_clutter_backend (backend); - CoglContext *cogl_context = - clutter_backend_get_cogl_context (clutter_backend); - EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); - - return meta_egl_has_extensions (egl, - egl_display, - NULL, - "EGL_EXT_image_dma_buf_import_modifiers", - NULL); - } - renderer_native = META_RENDERER_NATIVE (meta_backend_get_renderer (backend)); gpu_kms = meta_renderer_native_get_primary_gpu (renderer_native); if (!gpu_kms) @@ -177,7 +162,30 @@ should_send_modifiers (MetaBackend *backend) return meta_renderer_native_send_modifiers (renderer_native); } +#endif +static gboolean +should_send_modifiers (MetaBackend *backend) +{ + MetaEgl *egl = meta_backend_get_egl (backend); + ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); + CoglContext *cogl_context = + clutter_backend_get_cogl_context (clutter_backend); + EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); + +#ifdef HAVE_NATIVE_BACKEND + if (META_IS_BACKEND_NATIVE (backend)) + return should_send_modifiers_native (backend); +#endif + + return meta_egl_has_extensions (egl, + egl_display, + NULL, + "EGL_EXT_image_dma_buf_import_modifiers", + NULL); +} + +#ifdef HAVE_NATIVE_BACKEND static gboolean should_send_modifiers_scanout_tranches (MetaBackend *backend) { @@ -189,6 +197,7 @@ should_send_modifiers_scanout_tranches (MetaBackend *backend) renderer_native = META_RENDERER_NATIVE (meta_backend_get_renderer (backend)); return meta_renderer_native_has_addfb2 (renderer_native); } +#endif static gint compare_tranches (gconstpointer a, diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c index a2bd7d2ab..60c442d21 100644 --- a/src/wayland/meta-wayland.c +++ b/src/wayland/meta-wayland.c @@ -189,6 +189,7 @@ emit_frame_callbacks_for_stage_view (MetaWaylandCompositor *compositor, } } +#ifdef HAVE_NATIVE_BACKEND static gboolean frame_callback_source_dispatch (GSource *source, GSourceFunc callback, @@ -279,6 +280,7 @@ ensure_source_for_stage_view (MetaWaylandCompositor *compositor, return source; } +#endif /* HAVE_NATIVE_BACKEND */ static void on_after_update (ClutterStage *stage,