wayland-drm: static inline wayland_drm_buffer_get
authorEmil Velikov <emil.velikov@collabora.com>
Tue, 24 Oct 2017 16:14:20 +0000 (17:14 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 8 Nov 2017 14:40:12 +0000 (14:40 +0000)
The function is effectively a direct function call into
libwayland-server.so.

Thus GBM no longer depends on the wayland-drm static library, making the
build more straight forward. And the resulting binary is a bit smaller.

Note: we need to move struct wayland_drm_callbacks further up,
otherwise we'll get an error since the type is incomplete.

v2: Rebase, beef-up commit message, update meson, move struct
wayland_drm_callbacks.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com> (v1)
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> # meson bit only
Acked-by: Eric Engestrom <eric.engestrom@imgtec.com> # for the rest
Reviewed-by: Dylan Baker <dylan@pnwbakers.com> # meson
src/Makefile.am
src/egl/wayland/wayland-drm/wayland-drm.c
src/egl/wayland/wayland-drm/wayland-drm.h
src/gbm/Makefile.am
src/gbm/meson.build

index 22973b14bc792e000c276bcf9f0775ad87cc6010..ea530eca7d6d834679069eb19b39b6d4d73c0dd6 100644 (file)
@@ -57,7 +57,7 @@ endif
 # include only conditionally ?
 SUBDIRS += compiler
 
-## Optionally required by GBM, EGL
+## Optionally required by EGL
 if HAVE_PLATFORM_WAYLAND
 SUBDIRS += egl/wayland/wayland-drm
 endif
index 73dfba9600e7b96341601dfa2addf24f6c766106..81f6f52852760bc053b0b9131a33345cdeb9bb36 100644 (file)
 
 #define MIN(x,y) (((x)<(y))?(x):(y))
 
-struct wl_drm {
-       struct wl_display *display;
-       struct wl_global *wl_drm_global;
-
-       void *user_data;
-       char *device_name;
-        uint32_t flags;
-
-       struct wayland_drm_callbacks callbacks;
-
-        struct wl_buffer_interface buffer_interface;
-};
-
 static void
 destroy_buffer(struct wl_resource *resource)
 {
@@ -244,19 +231,6 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
            wl_resource_post_event(resource, WL_DRM_CAPABILITIES, capabilities);
 }
 
-struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
-{
-       if (resource == NULL)
-               return NULL;
-
-        if (wl_resource_instance_of(resource, &wl_buffer_interface,
-                                    &drm->buffer_interface))
-               return wl_resource_get_user_data(resource);
-        else
-               return NULL;
-}
-
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
                  const struct wayland_drm_callbacks *callbacks, void *user_data,
index 111383ff1d687419e47fd660590873cb0b42ac29..36e5bf042a7a9178f8146ef4ade9cf976610a16c 100644 (file)
@@ -4,8 +4,31 @@
 #include <wayland-server.h>
 
 struct wl_display;
-struct wl_drm;
 struct wl_resource;
+struct wl_drm_buffer;
+
+struct wayland_drm_callbacks {
+       int (*authenticate)(void *user_data, uint32_t id);
+
+       void (*reference_buffer)(void *user_data, uint32_t name, int fd,
+                                 struct wl_drm_buffer *buffer);
+
+       void (*release_buffer)(void *user_data, struct wl_drm_buffer *buffer);
+};
+
+
+struct wl_drm {
+       struct wl_display *display;
+       struct wl_global *wl_drm_global;
+
+       void *user_data;
+       char *device_name;
+       uint32_t flags;
+
+       struct wayland_drm_callbacks callbacks;
+
+       struct wl_buffer_interface buffer_interface;
+};
 
 struct wl_drm_buffer {
        struct wl_resource *resource;
@@ -18,19 +41,20 @@ struct wl_drm_buffer {
        void *driver_buffer;
 };
 
-struct wayland_drm_callbacks {
-       int (*authenticate)(void *user_data, uint32_t id);
-
-        void (*reference_buffer)(void *user_data, uint32_t name, int fd,
-                                 struct wl_drm_buffer *buffer);
-
-       void (*release_buffer)(void *user_data, struct wl_drm_buffer *buffer);
-};
-
 enum { WAYLAND_DRM_PRIME = 0x01 };
 
-struct wl_drm_buffer *
-wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
+static inline struct wl_drm_buffer *
+wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
+{
+       if (resource == NULL)
+               return NULL;
+
+       if (wl_resource_instance_of(resource, &wl_buffer_interface,
+                                   &drm->buffer_interface))
+               return wl_resource_get_user_data(resource);
+       else
+               return NULL;
+}
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
index 05d861ff999db7c8f47ba7df7de4c0c34b55c8c8..682c4281f4c1e7cd706761f0afacdedd78565f1d 100644 (file)
@@ -34,7 +34,7 @@ if HAVE_PLATFORM_WAYLAND
 AM_CFLAGS += \
        $(WAYLAND_SERVER_CFLAGS) \
        -I$(top_srcdir)/src/egl/wayland/wayland-drm/
-libgbm_la_LIBADD += $(top_builddir)/src/egl/wayland/wayland-drm/libwayland-drm.la $(WAYLAND_SERVER_LIBS)
+libgbm_la_LIBADD += $(WAYLAND_SERVER_LIBS)
 endif
 
 if HAVE_DRI2
index f25f3172027794f1cc4f157092f32ba9d3f8d463..4b550e06f2790ae9a13d39bf820bfde3a48f58a2 100644 (file)
@@ -29,7 +29,6 @@ files_gbm = files(
 )
 deps_gbm = []
 args_gbm = []
-links_gbm = []
 deps_gbm = []
 incs_gbm = [
   include_directories('main'), inc_include, inc_src, inc_loader,
@@ -43,7 +42,6 @@ if with_dri2
 endif
 if with_platform_wayland
   deps_gbm += dep_wayland_server
-  links_gbm += libwayland_drm
   incs_gbm += inc_wayland_drm
 endif
 
@@ -55,7 +53,7 @@ libgbm = shared_library(
   include_directories : incs_gbm,
   c_args : [c_vis_args, args_gbm],
   link_args : [ld_args_gc_sections],
-  link_with : [links_gbm, libloader, libmesa_util, libxmlconfig],
+  link_with : [libloader, libmesa_util, libxmlconfig],
   dependencies : [deps_gbm, dep_dl],
   version : '1.0.0',
   install : true,