wayland/eglstream: Don't build skeleton when disabled

Instead of calling no-op functions when EGLStream support isn't enabled,
make it clear at the call site that EGLStream support is optional.
This commit is contained in:
Jonas Ådahl 2018-11-06 17:09:03 +01:00
parent 6192e944b8
commit 417c00b8fa
5 changed files with 31 additions and 10 deletions

View File

@ -408,8 +408,6 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
wayland/meta-wayland-data-device.c \ wayland/meta-wayland-data-device.c \
wayland/meta-wayland-data-device.h \ wayland/meta-wayland-data-device.h \
wayland/meta-wayland-data-device-private.h \ wayland/meta-wayland-data-device-private.h \
wayland/meta-wayland-egl-stream.c \
wayland/meta-wayland-egl-stream.h \
wayland/meta-wayland-input-device.c \ wayland/meta-wayland-input-device.c \
wayland/meta-wayland-input-device.h \ wayland/meta-wayland-input-device.h \
wayland/meta-wayland-pointer-gestures.c \ wayland/meta-wayland-pointer-gestures.c \
@ -491,6 +489,13 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
wayland/meta-xwayland-grab-keyboard.c \ wayland/meta-xwayland-grab-keyboard.c \
wayland/meta-xwayland-grab-keyboard.h \ wayland/meta-xwayland-grab-keyboard.h \
$(NULL) $(NULL)
if HAVE_WAYLAND_EGLSTREAM
libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
wayland/meta-wayland-egl-stream.c \
wayland/meta-wayland-egl-stream.h \
$(NULL)
endif
endif endif
if HAVE_NATIVE_BACKEND if HAVE_NATIVE_BACKEND

View File

@ -108,7 +108,9 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer)
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend); CoglContext *cogl_context = clutter_backend_get_cogl_context (clutter_backend);
EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context); EGLDisplay egl_display = cogl_egl_context_get_egl_display (cogl_context);
#ifdef HAVE_WAYLAND_EGLSTREAM
MetaWaylandEglStream *stream; MetaWaylandEglStream *stream;
#endif
MetaWaylandDmaBufBuffer *dma_buf; MetaWaylandDmaBufBuffer *dma_buf;
if (wl_shm_buffer_get (buffer->resource) != NULL) if (wl_shm_buffer_get (buffer->resource) != NULL)
@ -125,6 +127,7 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer)
return TRUE; return TRUE;
} }
#ifdef HAVE_WAYLAND_EGLSTREAM
stream = meta_wayland_egl_stream_new (buffer, NULL); stream = meta_wayland_egl_stream_new (buffer, NULL);
if (stream) if (stream)
{ {
@ -141,6 +144,7 @@ meta_wayland_buffer_realize (MetaWaylandBuffer *buffer)
return TRUE; return TRUE;
} }
#endif /* HAVE_WAYLAND_EGLSTREAM */
dma_buf = meta_wayland_dma_buf_from_buffer (buffer); dma_buf = meta_wayland_dma_buf_from_buffer (buffer);
if (dma_buf) if (dma_buf)
@ -320,6 +324,7 @@ egl_image_buffer_attach (MetaWaylandBuffer *buffer,
return TRUE; return TRUE;
} }
#ifdef HAVE_WAYLAND_EGLSTREAM
static gboolean static gboolean
egl_stream_buffer_attach (MetaWaylandBuffer *buffer, egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
GError **error) GError **error)
@ -333,6 +338,7 @@ egl_stream_buffer_attach (MetaWaylandBuffer *buffer,
return TRUE; return TRUE;
} }
#endif /* HAVE_WAYLAND_EGLSTREAM */
gboolean gboolean
meta_wayland_buffer_attach (MetaWaylandBuffer *buffer, meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
@ -355,8 +361,10 @@ meta_wayland_buffer_attach (MetaWaylandBuffer *buffer,
return shm_buffer_attach (buffer, error); return shm_buffer_attach (buffer, error);
case META_WAYLAND_BUFFER_TYPE_EGL_IMAGE: case META_WAYLAND_BUFFER_TYPE_EGL_IMAGE:
return egl_image_buffer_attach (buffer, error); return egl_image_buffer_attach (buffer, error);
#ifdef HAVE_WAYLAND_EGLSTREAM
case META_WAYLAND_BUFFER_TYPE_EGL_STREAM: case META_WAYLAND_BUFFER_TYPE_EGL_STREAM:
return egl_stream_buffer_attach (buffer, error); return egl_stream_buffer_attach (buffer, error);
#endif
case META_WAYLAND_BUFFER_TYPE_DMA_BUF: case META_WAYLAND_BUFFER_TYPE_DMA_BUF:
return meta_wayland_dma_buf_buffer_attach (buffer, error); return meta_wayland_dma_buf_buffer_attach (buffer, error);
case META_WAYLAND_BUFFER_TYPE_UNKNOWN: case META_WAYLAND_BUFFER_TYPE_UNKNOWN:
@ -376,10 +384,14 @@ meta_wayland_buffer_get_texture (MetaWaylandBuffer *buffer)
CoglSnippet * CoglSnippet *
meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer) meta_wayland_buffer_create_snippet (MetaWaylandBuffer *buffer)
{ {
#ifdef HAVE_WAYLAND_EGLSTREAM
if (!buffer->egl_stream.stream) if (!buffer->egl_stream.stream)
return NULL; return NULL;
return meta_wayland_egl_stream_create_snippet (); return meta_wayland_egl_stream_create_snippet ();
#else
return NULL;
#endif /* HAVE_WAYLAND_EGLSTREAM */
} }
gboolean gboolean
@ -448,7 +460,9 @@ meta_wayland_buffer_process_damage (MetaWaylandBuffer *buffer,
res = process_shm_buffer_damage (buffer, region, &error); res = process_shm_buffer_damage (buffer, region, &error);
break; break;
case META_WAYLAND_BUFFER_TYPE_EGL_IMAGE: case META_WAYLAND_BUFFER_TYPE_EGL_IMAGE:
#ifdef HAVE_WAYLAND_EGLSTREAM
case META_WAYLAND_BUFFER_TYPE_EGL_STREAM: case META_WAYLAND_BUFFER_TYPE_EGL_STREAM:
#endif
case META_WAYLAND_BUFFER_TYPE_DMA_BUF: case META_WAYLAND_BUFFER_TYPE_DMA_BUF:
res = TRUE; res = TRUE;
break; break;
@ -473,7 +487,9 @@ meta_wayland_buffer_finalize (GObject *object)
MetaWaylandBuffer *buffer = META_WAYLAND_BUFFER (object); MetaWaylandBuffer *buffer = META_WAYLAND_BUFFER (object);
g_clear_pointer (&buffer->texture, cogl_object_unref); g_clear_pointer (&buffer->texture, cogl_object_unref);
#ifdef HAVE_WAYLAND_EGLSTREAM
g_clear_object (&buffer->egl_stream.stream); g_clear_object (&buffer->egl_stream.stream);
#endif
g_clear_object (&buffer->dma_buf.dma_buf); g_clear_object (&buffer->dma_buf.dma_buf);
G_OBJECT_CLASS (meta_wayland_buffer_parent_class)->finalize (object); G_OBJECT_CLASS (meta_wayland_buffer_parent_class)->finalize (object);

View File

@ -38,7 +38,9 @@ typedef enum _MetaWaylandBufferType
META_WAYLAND_BUFFER_TYPE_UNKNOWN, META_WAYLAND_BUFFER_TYPE_UNKNOWN,
META_WAYLAND_BUFFER_TYPE_SHM, META_WAYLAND_BUFFER_TYPE_SHM,
META_WAYLAND_BUFFER_TYPE_EGL_IMAGE, META_WAYLAND_BUFFER_TYPE_EGL_IMAGE,
#ifdef HAVE_WAYLAND_EGLSTREAM
META_WAYLAND_BUFFER_TYPE_EGL_STREAM, META_WAYLAND_BUFFER_TYPE_EGL_STREAM,
#endif
META_WAYLAND_BUFFER_TYPE_DMA_BUF, META_WAYLAND_BUFFER_TYPE_DMA_BUF,
} MetaWaylandBufferType; } MetaWaylandBufferType;
@ -54,9 +56,11 @@ struct _MetaWaylandBuffer
MetaWaylandBufferType type; MetaWaylandBufferType type;
#ifdef HAVE_WAYLAND_EGLSTREAM
struct { struct {
MetaWaylandEglStream *stream; MetaWaylandEglStream *stream;
} egl_stream; } egl_stream;
#endif
struct { struct {
MetaWaylandDmaBufBuffer *dma_buf; MetaWaylandDmaBufBuffer *dma_buf;

View File

@ -26,6 +26,8 @@
#include "wayland/meta-wayland-egl-stream.h" #include "wayland/meta-wayland-egl-stream.h"
#include <dlfcn.h>
#include "backends/meta-backend-private.h" #include "backends/meta-backend-private.h"
#include "backends/meta-egl-ext.h" #include "backends/meta-egl-ext.h"
#include "backends/meta-egl.h" #include "backends/meta-egl.h"
@ -34,10 +36,6 @@
#include "wayland/meta-wayland-buffer.h" #include "wayland/meta-wayland-buffer.h"
#include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-private.h"
#ifdef HAVE_WAYLAND_EGLSTREAM
#include <dlfcn.h>
#include "wayland-eglstream-controller-server-protocol.h" #include "wayland-eglstream-controller-server-protocol.h"
static struct wl_interface *wl_eglstream_controller_interface_ptr = NULL; static struct wl_interface *wl_eglstream_controller_interface_ptr = NULL;
@ -86,12 +84,9 @@ bind_eglstream_controller (struct wl_client *client,
NULL); NULL);
} }
#endif /* HAVE_WAYLAND_EGLSTREAM */
gboolean gboolean
meta_wayland_eglstream_controller_init (MetaWaylandCompositor *compositor) meta_wayland_eglstream_controller_init (MetaWaylandCompositor *compositor)
{ {
#ifdef HAVE_WAYLAND_EGLSTREAM
/* /*
* wl_eglstream_controller_interface is provided by * wl_eglstream_controller_interface is provided by
* libnvidia-egl-wayland.so.1 * libnvidia-egl-wayland.so.1
@ -127,7 +122,6 @@ fail:
dlclose(lib); dlclose(lib);
g_debug ("WL: Unable to initialize wl_eglstream_controller."); g_debug ("WL: Unable to initialize wl_eglstream_controller.");
#endif
return FALSE; return FALSE;
} }

View File

@ -398,7 +398,9 @@ meta_wayland_init (void)
meta_xwayland_global_filter, meta_xwayland_global_filter,
compositor); compositor);
#ifdef HAVE_WAYLAND_EGLSTREAM
meta_wayland_eglstream_controller_init (compositor); meta_wayland_eglstream_controller_init (compositor);
#endif
if (meta_should_autostart_x11_display ()) if (meta_should_autostart_x11_display ())
{ {