[waffle] [PATCH 4/7] gbm: drop explicit linking against libgbm.so

Emil Velikov emil.l.velikov at gmail.com
Mon Nov 10 07:56:36 PST 2014


Use the function pointers stored in wgbm_platform, to communicate
with the library.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 .../Modules/WafflePrintConfigurationSummary.cmake  |  1 -
 src/waffle/CMakeLists.txt                          |  1 -
 src/waffle/gbm/wgbm_display.c                      | 12 ++++++-----
 src/waffle/gbm/wgbm_window.c                       | 24 ++++++++++++++--------
 src/waffle/gbm/wgbm_window.h                       |  1 +
 5 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/cmake/Modules/WafflePrintConfigurationSummary.cmake b/cmake/Modules/WafflePrintConfigurationSummary.cmake
index 79f7b38..81e738d 100644
--- a/cmake/Modules/WafflePrintConfigurationSummary.cmake
+++ b/cmake/Modules/WafflePrintConfigurationSummary.cmake
@@ -65,7 +65,6 @@ if(waffle_has_x11)
 endif()
 if(waffle_has_gbm)
     message("    gbm_INCLUDE_DIRS: ${gbm_INCLUDE_DIRS}")
-    message("    gbm_LDFLAGS:      ${gbm_LDFLAGS}")
 endif()
 message("")
 message("Build type:")
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index bf096b0..5d703f4 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -55,7 +55,6 @@ if(waffle_on_linux)
     endif()
     if(waffle_has_gbm)
         list(APPEND waffle_libdeps
-            ${gbm_LDFLAGS}
             ${libudev_LDFLAGS}
             )
     endif()
diff --git a/src/waffle/gbm/wgbm_display.c b/src/waffle/gbm/wgbm_display.c
index be5e83f..2f5df00 100644
--- a/src/waffle/gbm/wgbm_display.c
+++ b/src/waffle/gbm/wgbm_display.c
@@ -23,13 +23,11 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#define __GBM__ 1
 #define _GNU_SOURCE
 
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <gbm.h>
 #include <libudev.h>
 #include <fcntl.h>
 #include <sys/types.h>
@@ -44,6 +42,8 @@
 bool
 wgbm_display_destroy(struct wcore_display *wc_self)
 {
+    struct wegl_platform *wegl_plat = wegl_platform(wc_self->platform);
+    struct wgbm_platform *plat = wgbm_platform(wegl_plat);
     struct wgbm_display *self = wgbm_display(wc_self);
     bool ok = true;
     int fd;
@@ -55,8 +55,8 @@ wgbm_display_destroy(struct wcore_display *wc_self)
     ok &= wegl_display_teardown(&self->wegl);
 
     if (self->gbm_device) {
-        fd = gbm_device_get_fd(self->gbm_device);
-        gbm_device_destroy(self->gbm_device);
+        fd = plat->gbm_device_get_fd(self->gbm_device);
+        plat->gbm_device_destroy(self->gbm_device);
         close(fd);
     }
 
@@ -118,6 +118,8 @@ struct wcore_display*
 wgbm_display_connect(struct wcore_platform *wc_plat,
                      const char *name)
 {
+    struct wegl_platform *wegl_plat = wegl_platform(wc_plat);
+    struct wgbm_platform *plat = wgbm_platform(wegl_plat);
     struct wgbm_display *self;
     bool ok = true;
     int fd;
@@ -137,7 +139,7 @@ wgbm_display_connect(struct wcore_platform *wc_plat,
         goto error;
     }
 
-    self->gbm_device = gbm_create_device(fd);
+    self->gbm_device = plat->gbm_create_device(fd);
     if (!self->gbm_device) {
         wcore_errorf(WAFFLE_ERROR_UNKNOWN, "gbm_create_device failed");
         goto error;
diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
index bce32a4..75ac681 100644
--- a/src/waffle/gbm/wgbm_window.c
+++ b/src/waffle/gbm/wgbm_window.c
@@ -23,8 +23,6 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#define __GBM__ 1
-
 #include <stdlib.h>
 #include <string.h>
 
@@ -38,11 +36,14 @@
 
 #include "wgbm_config.h"
 #include "wgbm_display.h"
+#include "wgbm_platform.h"
 #include "wgbm_window.h"
 
 bool
 wgbm_window_destroy(struct wcore_window *wc_self)
 {
+    struct wegl_platform *wegl_plat = wegl_platform(wc_self->display->platform);
+    struct wgbm_platform *plat = wgbm_platform(wegl_plat);
     struct wgbm_window *self = wgbm_window(wc_self);
     bool ok = true;
 
@@ -50,7 +51,7 @@ wgbm_window_destroy(struct wcore_window *wc_self)
         return ok;
 
     ok &= wegl_window_teardown(&self->wegl);
-    gbm_surface_destroy(self->gbm_surface);
+    plat->gbm_surface_destroy(self->gbm_surface);
     free(self);
     return ok;
 }
@@ -61,8 +62,10 @@ wgbm_window_create(struct wcore_platform *wc_plat,
                    int width,
                    int height)
 {
-    struct wgbm_window *self;
     struct wgbm_display *dpy = wgbm_display(wc_config->display);
+    struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
+
+    struct wgbm_window *self;
     uint32_t gbm_format;
     bool ok = true;
 
@@ -72,9 +75,9 @@ wgbm_window_create(struct wcore_platform *wc_plat,
 
     gbm_format = wgbm_config_get_gbm_format(&wc_config->attrs);
     assert(gbm_format != 0);
-    self->gbm_surface = gbm_surface_create(dpy->gbm_device, width, height,
-                                           gbm_format,
-                                           GBM_BO_USE_RENDERING);
+    self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device,
+                                                 width, height, gbm_format,
+                                                 GBM_BO_USE_RENDERING);
     if (!self->gbm_surface) {
         wcore_errorf(WAFFLE_ERROR_UNKNOWN,
                      "gbm_surface_create failed");
@@ -104,15 +107,18 @@ wgbm_window_show(struct wcore_window *wc_self)
 bool
 wgbm_window_swap_buffers(struct wcore_window *wc_self)
 {
+    struct wegl_platform *wegl_plat = wegl_platform(wc_self->display->platform);
+    struct wgbm_platform *plat = wgbm_platform(wegl_plat);
+
     if (!wegl_window_swap_buffers(wc_self))
         return false;
 
     struct wgbm_window *self = wgbm_window(wc_self);
-    struct gbm_bo *bo = gbm_surface_lock_front_buffer(self->gbm_surface);
+    struct gbm_bo *bo = plat->gbm_surface_lock_front_buffer(self->gbm_surface);
     if (!bo)
         return false;
 
-    gbm_surface_release_buffer(self->gbm_surface, bo);
+    plat->gbm_surface_release_buffer(self->gbm_surface, bo);
     return true;
 }
 
diff --git a/src/waffle/gbm/wgbm_window.h b/src/waffle/gbm/wgbm_window.h
index 0a895db..729612b 100644
--- a/src/waffle/gbm/wgbm_window.h
+++ b/src/waffle/gbm/wgbm_window.h
@@ -30,6 +30,7 @@
 #include "wegl_window.h"
 
 struct wcore_platform;
+struct gbm_surface;
 
 struct wgbm_window {
     struct gbm_surface *gbm_surface;
-- 
2.1.3



More information about the waffle mailing list