[Cogl] [PATCH] kms: Update to latest gbm api

Robert Bragg robert at sixbynine.org
Tue Aug 28 06:24:22 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

gbm_bo_get_pitch was renamed to gbm_bo_get_stride to be consistent with
how the terms pitch and stride are used throughout mesa. This updates
the Cogl backend to use the new gbm_bo_get_stride name.

For compatibility with previous version of libgbm we now explicitly
check the version of libgbm in configure.ac and expose
COGL_GBM_{MAJOR,MINOR,MICRO} defines to the code so we can conditionally
use the older gbm_bo_get_pitch() name with older versions.
---
 cogl/winsys/cogl-winsys-egl-kms.c |   10 +++++++---
 configure.ac                      |    9 +++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c
index a4928e8..4a9f51a 100644
--- a/cogl/winsys/cogl-winsys-egl-kms.c
+++ b/cogl/winsys/cogl-winsys-egl-kms.c
@@ -662,7 +662,7 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
   CoglRendererKMS *kms_renderer = egl_renderer->platform;
   CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
   CoglOnscreenKMS *kms_onscreen = egl_onscreen->platform;
-  uint32_t handle, pitch;
+  uint32_t handle, stride;
   CoglFlipKMS *flip;
   GList *l;
 
@@ -676,7 +676,11 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
   /* Now we need to set the CRTC to whatever is the front buffer */
   kms_onscreen->next_bo = gbm_surface_lock_front_buffer (kms_onscreen->surface);
 
-  pitch = gbm_bo_get_pitch (kms_onscreen->next_bo);
+#if COGL_GBM_MAJOR >= 8 && COGL_GBM_MINOR >= 1
+  stride = gbm_bo_get_stride (kms_onscreen->next_bo);
+#else
+  stride = gbm_bo_get_pitch (kms_onscreen->next_bo);
+#endif
   handle = gbm_bo_get_handle (kms_onscreen->next_bo).u32;
 
   if (drmModeAddFB (kms_renderer->fd,
@@ -684,7 +688,7 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
                     kms_display->height,
                     24, /* depth */
                     32, /* bpp */
-                    pitch,
+                    stride,
                     handle,
                     &kms_onscreen->next_fb_id))
     {
diff --git a/configure.ac b/configure.ac
index 1121bab..064289a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -850,6 +850,15 @@ AS_IF([test "x$enable_kms_egl_platform" == "xyes"],
                          ],
                          [AC_MSG_ERROR([Unable to locate required kms libraries])])
 
+        GBM_VERSION=`$PKG_CONFIG --modversion gbm`
+        GBM_MAJOR=`echo $GBM_VERSION | cut -d'.' -f1`
+        GBM_MINOR=`echo $GBM_VERSION | cut -d'.' -f2`
+        GBM_MICRO=`echo $GBM_VERSION | cut -d'.' -f3`
+
+        AC_DEFINE_UNQUOTED([COGL_GBM_MAJOR], [$GBM_MAJOR], [The major version for libgbm])
+        AC_DEFINE_UNQUOTED([COGL_GBM_MINOR], [$GBM_MINOR], [The minor version for libgbm])
+        AC_DEFINE_UNQUOTED([COGL_GBM_MICRO], [$GBM_MICRO], [The micro version for libgbm])
+
         COGL_DEFINES_SYMBOLS="$COGL_DEFINES_SYMBOLS COGL_HAS_EGL_PLATFORM_KMS_SUPPORT"
       ])
 AM_CONDITIONAL(SUPPORT_EGL_PLATFORM_KMS,
-- 
1.7.7.6



More information about the Cogl mailing list