[waffle] [PATCH v4 3/4] gbm: initial skeleton for gbm support

Jordan Justen jordan.l.justen at intel.com
Mon Oct 1 10:14:33 PDT 2012


All routines in this skeleton will fail.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 CMakeLists.txt                   |   26 +++++++++--
 include/CMakeLists.txt           |    1 +
 include/waffle/waffle_config.h   |    2 +
 include/waffle/waffle_context.h  |    2 +
 include/waffle/waffle_display.h  |    2 +
 include/waffle/waffle_gbm.h      |   65 ++++++++++++++++++++++++++
 include/waffle/waffle_window.h   |    2 +
 src/waffle/CMakeLists.txt        |   15 ++++++
 src/waffle/api/waffle_init.c     |    8 ++++
 src/waffle/gbm/gbm_config.c      |   68 +++++++++++++++++++++++++++
 src/waffle/gbm/gbm_config.h      |   60 ++++++++++++++++++++++++
 src/waffle/gbm/gbm_context.c     |   63 +++++++++++++++++++++++++
 src/waffle/gbm/gbm_context.h     |   51 ++++++++++++++++++++
 src/waffle/gbm/gbm_display.c     |   78 +++++++++++++++++++++++++++++++
 src/waffle/gbm/gbm_display.h     |   59 +++++++++++++++++++++++
 src/waffle/gbm/gbm_platform.c    |   96 ++++++++++++++++++++++++++++++++++++++
 src/waffle/gbm/gbm_platform.h    |   49 +++++++++++++++++++
 src/waffle/gbm/gbm_priv_egl.c    |   29 ++++++++++++
 src/waffle/gbm/gbm_priv_egl.h    |   30 ++++++++++++
 src/waffle/gbm/gbm_window.c      |   82 ++++++++++++++++++++++++++++++++
 src/waffle/gbm/gbm_window.h      |   53 +++++++++++++++++++++
 tests/functional/gl_basic_test.c |   52 +++++++++++++++++++++
 22 files changed, 890 insertions(+), 3 deletions(-)
 create mode 100644 include/waffle/waffle_gbm.h
 create mode 100644 src/waffle/gbm/gbm_config.c
 create mode 100644 src/waffle/gbm/gbm_config.h
 create mode 100644 src/waffle/gbm/gbm_context.c
 create mode 100644 src/waffle/gbm/gbm_context.h
 create mode 100644 src/waffle/gbm/gbm_display.c
 create mode 100644 src/waffle/gbm/gbm_display.h
 create mode 100644 src/waffle/gbm/gbm_platform.c
 create mode 100644 src/waffle/gbm/gbm_platform.h
 create mode 100644 src/waffle/gbm/gbm_priv_egl.c
 create mode 100644 src/waffle/gbm/gbm_priv_egl.h
 create mode 100644 src/waffle/gbm/gbm_window.c
 create mode 100644 src/waffle/gbm/gbm_window.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bba1796..240072e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,6 +76,7 @@ set(waffle_build_examples "Build examples" ON)
 option(waffle_has_glx "Build support for GLX" OFF)
 option(waffle_has_wayland "Build support for Wayland" OFF)
 option(waffle_has_x11_egl "Build support for X11/EGL" OFF)
+option(waffle_has_gbm "Build support for GBM" OFF)
 
 set(waffle_install_includedir "${CMAKE_INSTALL_PREFIX}/include"
     CACHE PATH "Directory where header files will be installed")
@@ -95,7 +96,7 @@ set(waffle_install_docdir "${CMAKE_INSTALL_PREFIX}/share/doc/waffle-${waffle_maj
 #     waffle_tls_model_initial_exec
 check_thread_local_storage()
 
-if(waffle_has_wayland OR waffle_has_x11_egl)
+if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm)
     set(waffle_has_egl TRUE)
 else(waffle_has_wayland OR waffle_has_x11_egl)
     set(waffle_has_egl FALSE)
@@ -112,8 +113,12 @@ endif()
 # ----------------------------------------------
 
 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
-    if(NOT waffle_has_glx AND NOT waffle_has_wayland AND NOT waffle_has_x11_egl)
-        message(FATAL_ERROR "Must enable at least one of: waffle_has_glx, waffle_has_wayland, waffle_has_x11_egl.")
+    if(NOT waffle_has_glx AND NOT waffle_has_wayland AND
+       NOT waffle_has_x11_egl AND NOT waffle_has_gbm)
+        message(FATAL_ERROR
+                "Must enable at least one of: "
+                "waffle_has_glx, waffle_has_wayland, "
+                "waffle_has_x11_egl, waffle_has_gbm.")
     endif()
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
     if(waffle_has_glx)
@@ -167,6 +172,11 @@ if(waffle_has_x11)
     waffle_find_library(waffle_X11-xcb_library X11-xcb)
 endif()
 
+if(waffle_has_gbm)
+    waffle_find_library(waffle_gbm_library gbm)
+    waffle_find_library(waffle_udev_library udev)
+endif()
+
 
 # ------------------------------------------------------------------------------
 # Compiler Flags
@@ -211,6 +221,10 @@ if(waffle_has_x11_egl)
     add_definitions(-DWAFFLE_HAS_X11_EGL)
 endif()
 
+if(waffle_has_gbm)
+    add_definitions(-DWAFFLE_HAS_GBM)
+endif()
+
 # ------------------------------------------------------------------------------
 # Add subdirectories
 # ------------------------------------------------------------------------------
@@ -288,6 +302,9 @@ endif()
 if(waffle_has_x11_egl)
     message("    x11_egl")
 endif()
+if(waffle_has_gbm)
+    message("    gbm")
+endif()
 message("")
 message("Libraries:")
 if(DEFINED waffle_EGL_library)
@@ -305,6 +322,9 @@ if(DEFINED waffle_X11-xcb_library)
     message("    X11: ${waffle_X11_library}")
     message("    X11-xcb: ${waffle_X11-xcb_library}")
 endif()
+if(DEFINED waffle_gbm_library)
+    message("    gbm: ${waffle_gbm_library}")
+endif()
 message("")
 message("Build type:")
 message("    ${CMAKE_BUILD_TYPE}")
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 4a402e6..33bc91a 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -14,6 +14,7 @@ install(FILES waffle/waffle.h
               waffle/waffle_enum.h
               waffle/waffle_error.h
               waffle/waffle_gl_misc.h
+              waffle/waffle_gbm.h
               waffle/waffle_glx.h
               waffle/waffle_init.h
               waffle/waffle_portability.h
diff --git a/include/waffle/waffle_config.h b/include/waffle/waffle_config.h
index c3b7b5e..58414c0 100644
--- a/include/waffle/waffle_config.h
+++ b/include/waffle/waffle_config.h
@@ -43,11 +43,13 @@ extern "C" {
 struct waffle_config;
 struct waffle_display;
 
+struct waffle_gbm_config;
 struct waffle_glx_config;
 struct waffle_x11_egl_config;
 struct waffle_wayland_config;
 
 union waffle_native_config {
+    struct waffle_gbm_config *gbm;
     struct waffle_glx_config *glx;
     struct waffle_x11_egl_config *x11_egl;
     struct waffle_wayland_config *wayland;
diff --git a/include/waffle/waffle_context.h b/include/waffle/waffle_context.h
index d0264b1..a360560 100644
--- a/include/waffle/waffle_context.h
+++ b/include/waffle/waffle_context.h
@@ -42,11 +42,13 @@ extern "C" {
 struct waffle_config;
 struct waffle_context;
 
+struct waffle_gbm_context;
 struct waffle_glx_context;
 struct waffle_x11_egl_context;
 struct waffle_wayland_context;
 
 union waffle_native_context {
+    struct waffle_gbm_context *gbm;
     struct waffle_glx_context *glx;
     struct waffle_x11_egl_context *x11_egl;
     struct waffle_wayland_context *wayland;
diff --git a/include/waffle/waffle_display.h b/include/waffle/waffle_display.h
index 6146de2..d65d269 100644
--- a/include/waffle/waffle_display.h
+++ b/include/waffle/waffle_display.h
@@ -42,11 +42,13 @@ extern "C" {
 
 struct waffle_display;
 
+struct waffle_gbm_display;
 struct waffle_glx_display;
 struct waffle_x11_egl_display;
 struct waffle_wayland_display;
 
 union waffle_native_display {
+    struct waffle_gbm_display *gbm;
     struct waffle_glx_display *glx;
     struct waffle_x11_egl_display *x11_egl;
     struct waffle_wayland_display *wayland;
diff --git a/include/waffle/waffle_gbm.h b/include/waffle/waffle_gbm.h
new file mode 100644
index 0000000..fe45343
--- /dev/null
+++ b/include/waffle/waffle_gbm.h
@@ -0,0 +1,65 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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.
+
+#pragma once
+
+#define __GBM__ 1
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <EGL/egl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gbm_device;
+struct gbm_surface;
+
+struct waffle_gbm_display {
+    struct gbm_device *gbm_device;
+    EGLDisplay egl_display;
+};
+
+struct waffle_gbm_config {
+    struct waffle_gbm_display display;
+    EGLConfig egl_config;
+};
+
+struct waffle_gbm_context {
+    struct waffle_gbm_display display;
+    EGLContext egl_context;
+};
+
+struct waffle_gbm_window {
+    struct waffle_gbm_display display;
+    struct gbm_surface *gbm_surface;
+    EGLSurface egl_surface;
+};
+
+#ifdef __cplusplus
+} // end extern "C"
+#endif
diff --git a/include/waffle/waffle_window.h b/include/waffle/waffle_window.h
index ac82304..02da0f4 100644
--- a/include/waffle/waffle_window.h
+++ b/include/waffle/waffle_window.h
@@ -41,11 +41,13 @@ extern "C" {
 struct waffle_config;
 struct waffle_window;
 
+struct waffle_gbm_window;
 struct waffle_glx_window;
 struct waffle_x11_egl_window;
 struct waffle_wayland_window;
 
 union waffle_native_window {
+    struct waffle_gbm_window *gbm;
     struct waffle_glx_window *glx;
     struct waffle_x11_egl_window *x11_egl;
     struct waffle_wayland_window *wayland;
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index dd7e2b5..07a34fa 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -111,6 +111,21 @@ if(waffle_has_x11_egl)
     )
 endif()
 
+if(waffle_has_gbm)
+    list(APPEND waffle_sources
+        gbm/gbm_config.c
+        gbm/gbm_context.c
+        gbm/gbm_display.c
+        gbm/gbm_platform.c
+        gbm/gbm_priv_egl.c
+        gbm/gbm_window.c
+    )
+    list(APPEND waffle_libdeps
+        ${waffle_gbm_library}
+        ${waffle_udev_library}
+        )
+endif()
+
 # CMake will pass to the C compiler only C sources. CMake does not recognize the
 # .m extension and ignores any such files in the source lists. To coerce CMake
 # to pass .m files to the compiler, we must lie and claim that they are
diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c
index c6e46bc..925c586 100644
--- a/src/waffle/api/waffle_init.c
+++ b/src/waffle/api/waffle_init.c
@@ -41,6 +41,7 @@ struct wcore_platform* droid_platform_create(void);
 struct wcore_platform* glx_platform_create(void);
 struct wcore_platform* wayland_platform_create(void);
 struct wcore_platform* xegl_platform_create(void);
+struct wcore_platform* gbm_platform_create(void);
 
 static bool
 waffle_init_parse_attrib_list(
@@ -72,6 +73,9 @@ waffle_init_parse_attrib_list(
 #ifdef WAFFLE_HAS_X11_EGL
                     case WAFFLE_PLATFORM_X11_EGL:
 #endif
+#ifdef WAFFLE_HAS_GBM
+                    case WAFFLE_PLATFORM_GBM:
+#endif
                         found_platform = true;
                         *platform = value;
                         break;
@@ -124,6 +128,10 @@ waffle_init_create_platform(int32_t waffle_platform)
         case WAFFLE_PLATFORM_X11_EGL:
             return xegl_platform_create();
 #endif
+#ifdef WAFFLE_HAS_GBM
+        case WAFFLE_PLATFORM_GBM:
+            return gbm_platform_create();
+#endif
         default:
             assert(false);
             return NULL;
diff --git a/src/waffle/gbm/gbm_config.c b/src/waffle/gbm/gbm_config.c
new file mode 100644
index 0000000..4270b8a
--- /dev/null
+++ b/src/waffle/gbm/gbm_config.c
@@ -0,0 +1,68 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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>
+
+#include <gbm.h>
+
+#include <waffle/core/wcore_config_attrs.h>
+#include <waffle/core/wcore_error.h>
+
+#include "waffle.h"
+
+#include "gbm_config.h"
+#include "gbm_display.h"
+#include "gbm_platform.h"
+#include "gbm_priv_egl.h"
+
+static const struct wcore_config_vtbl gbm_config_wcore_vtbl;
+
+static bool
+gbm_config_destroy(struct wcore_config *wc_self)
+{
+    return false;
+}
+
+struct wcore_config*
+gbm_config_choose(struct wcore_platform *wc_plat,
+                  struct wcore_display *wc_dpy,
+                  const struct wcore_config_attrs *attrs)
+{
+    return NULL;
+}
+
+static union waffle_native_config*
+gbm_config_get_native(struct wcore_config *wc_self)
+{
+    return NULL;
+}
+
+static const struct wcore_config_vtbl gbm_config_wcore_vtbl = {
+    .destroy = gbm_config_destroy,
+    .get_native = gbm_config_get_native,
+};
diff --git a/src/waffle/gbm/gbm_config.h b/src/waffle/gbm/gbm_config.h
new file mode 100644
index 0000000..a0a4e2c
--- /dev/null
+++ b/src/waffle/gbm/gbm_config.h
@@ -0,0 +1,60 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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.
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <EGL/egl.h>
+
+#include <waffle/core/wcore_config.h>
+#include <waffle/core/wcore_util.h>
+
+struct wcore_config_attrs;
+struct wcore_platform;
+
+struct gbm_config {
+    struct wcore_config wcore;
+
+    EGLConfig egl;
+    int32_t waffle_context_api;
+
+    /// The value of @c EGL_RENDER_BUFFER that will be set in the attrib_list
+    /// of eglCreateWindowSurface().
+    EGLint egl_render_buffer;
+
+    uint32_t gbm_format;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(gbm_config,
+                           struct gbm_config,
+                           struct wcore_config,
+                           wcore)
+
+struct wcore_config*
+gbm_config_choose(struct wcore_platform *wc_plat,
+                  struct wcore_display *wc_dpy,
+                  const struct wcore_config_attrs *attrs);
diff --git a/src/waffle/gbm/gbm_context.c b/src/waffle/gbm/gbm_context.c
new file mode 100644
index 0000000..f723a4f
--- /dev/null
+++ b/src/waffle/gbm/gbm_context.c
@@ -0,0 +1,63 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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 <waffle/core/wcore_config.h>
+#include <waffle/core/wcore_error.h>
+
+#include "gbm_config.h"
+#include "gbm_context.h"
+#include "gbm_display.h"
+#include "gbm_priv_egl.h"
+
+static const struct wcore_context_vtbl gbm_context_wcore_vtbl;
+
+static bool
+gbm_context_destroy(struct wcore_context *wc_self)
+{
+    return false;
+}
+
+struct wcore_context*
+gbm_context_create(struct wcore_platform *wc_plat,
+                   struct wcore_config *wc_config,
+                   struct wcore_context *wc_share_ctx)
+{
+    return NULL;
+}
+
+static union waffle_native_context*
+gbm_context_get_native(struct wcore_context *wc_self)
+{
+    return NULL;
+}
+
+static const struct wcore_context_vtbl gbm_context_wcore_vtbl = {
+    .destroy = gbm_context_destroy,
+    .get_native = gbm_context_get_native,
+};
diff --git a/src/waffle/gbm/gbm_context.h b/src/waffle/gbm/gbm_context.h
new file mode 100644
index 0000000..0509299
--- /dev/null
+++ b/src/waffle/gbm/gbm_context.h
@@ -0,0 +1,51 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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.
+
+#pragma once
+
+#include <stdbool.h>
+
+#include <EGL/egl.h>
+
+#include <waffle/core/wcore_context.h>
+#include <waffle/core/wcore_util.h>
+
+struct wcore_config;
+struct wcore_platform;
+
+struct gbm_context {
+    struct wcore_context wcore;
+    EGLContext egl;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(gbm_context,
+                           struct gbm_context,
+                           struct wcore_context,
+                           wcore)
+
+struct wcore_context*
+gbm_context_create(struct wcore_platform *wc_plat,
+                   struct wcore_config *wc_config,
+                   struct wcore_context *wc_share_ctx);
diff --git a/src/waffle/gbm/gbm_display.c b/src/waffle/gbm/gbm_display.c
new file mode 100644
index 0000000..a38f8a4
--- /dev/null
+++ b/src/waffle/gbm/gbm_display.c
@@ -0,0 +1,78 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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 <gbm.h>
+#include <libudev.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <linux/input.h>
+
+#include <waffle/core/wcore_error.h>
+#include <waffle/core/wcore_display.h>
+
+#include "gbm_display.h"
+#include "gbm_platform.h"
+#include "gbm_priv_egl.h"
+
+static const struct wcore_display_vtbl gbm_display_wcore_vtbl;
+
+static bool
+gbm_display_destroy(struct wcore_display *wc_self)
+{
+    return false;
+}
+
+struct wcore_display*
+gbm_display_connect(struct wcore_platform *wc_plat,
+                    const char *name)
+{
+    return NULL;
+}
+
+
+static bool
+gbm_display_supports_context_api(struct wcore_display *wc_self,
+                                 int32_t waffle_context_api)
+{
+    return false;
+}
+
+static union waffle_native_display*
+gbm_display_get_native(struct wcore_display *wc_self)
+{
+    return NULL;
+}
+
+static const struct wcore_display_vtbl gbm_display_wcore_vtbl = {
+    .destroy = gbm_display_destroy,
+    .get_native = gbm_display_get_native,
+    .supports_context_api = gbm_display_supports_context_api,
+};
diff --git a/src/waffle/gbm/gbm_display.h b/src/waffle/gbm/gbm_display.h
new file mode 100644
index 0000000..05f3a0c
--- /dev/null
+++ b/src/waffle/gbm/gbm_display.h
@@ -0,0 +1,59 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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.
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <EGL/egl.h>
+
+#include <waffle/core/wcore_display.h>
+#include <waffle/core/wcore_util.h>
+#include <waffle_gbm.h>
+
+struct wcore_platform;
+struct gbm_device;
+
+struct gbm_display {
+    struct wcore_display wcore;
+
+    struct gbm_device *gbm_device;
+
+    EGLDisplay egl;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(gbm_display,
+                           struct gbm_display,
+                           struct wcore_display,
+                           wcore)
+
+struct wcore_display*
+gbm_display_connect(struct wcore_platform *wc_plat,
+                    const char *name);
+
+void
+gbm_display_fill_native(struct gbm_display *self,
+                        struct waffle_gbm_display *n_dpy);
diff --git a/src/waffle/gbm/gbm_platform.c b/src/waffle/gbm/gbm_platform.c
new file mode 100644
index 0000000..fca6ab5
--- /dev/null
+++ b/src/waffle/gbm/gbm_platform.c
@@ -0,0 +1,96 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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 _POSIX_C_SOURCE 200112 // glib feature macro for unsetenv()
+
+#include <stdlib.h>
+
+#include <waffle/core/wcore_error.h>
+#include <waffle/linux/linux_platform.h>
+
+#include "gbm_config.h"
+#include "gbm_context.h"
+#include "gbm_display.h"
+#include "gbm_platform.h"
+#include "gbm_priv_egl.h"
+#include "gbm_window.h"
+
+static const struct wcore_platform_vtbl gbm_platform_wcore_vtbl;
+
+static bool
+gbm_platform_destroy(struct wcore_platform *wc_self)
+{
+    return false;
+}
+
+struct wcore_platform*
+gbm_platform_create(void)
+{
+    return NULL;
+}
+
+static bool
+gbm_platform_make_current(struct wcore_platform *wc_self,
+                          struct wcore_display *wc_dpy,
+                          struct wcore_window *wc_window,
+                          struct wcore_context *wc_ctx)
+{
+    return false;
+}
+
+static void*
+gbm_platform_get_proc_address(struct wcore_platform *wc_self,
+                              const char *name)
+{
+    return NULL;
+}
+
+static bool
+gbm_platform_dl_can_open(struct wcore_platform *wc_self,
+                         int32_t waffle_dl)
+{
+    return false;
+}
+
+static void*
+gbm_platform_dl_sym(struct wcore_platform *wc_self,
+                    int32_t waffle_dl,
+                    const char *name)
+{
+    return NULL;
+}
+
+static const struct wcore_platform_vtbl gbm_platform_wcore_vtbl = {
+    .destroy = gbm_platform_destroy,
+    .connect_to_display = gbm_display_connect,
+    .choose_config = gbm_config_choose,
+    .create_context = gbm_context_create,
+    .create_window = gbm_window_create,
+    .make_current = gbm_platform_make_current,
+    .get_proc_address = gbm_platform_get_proc_address,
+    .dl_can_open = gbm_platform_dl_can_open,
+    .dl_sym = gbm_platform_dl_sym,
+};
diff --git a/src/waffle/gbm/gbm_platform.h b/src/waffle/gbm/gbm_platform.h
new file mode 100644
index 0000000..fe4a257
--- /dev/null
+++ b/src/waffle/gbm/gbm_platform.h
@@ -0,0 +1,49 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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.
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdlib.h>
+
+#undef linux
+
+#include <waffle/core/wcore_platform.h>
+#include <waffle/core/wcore_util.h>
+
+struct linux_platform;
+
+struct gbm_platform {
+    struct wcore_platform wcore;
+    struct linux_platform *linux;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(gbm_platform,
+                           struct gbm_platform,
+                           struct wcore_platform,
+                           wcore)
+
+struct wcore_platform*
+gbm_platform_create(void);
diff --git a/src/waffle/gbm/gbm_priv_egl.c b/src/waffle/gbm/gbm_priv_egl.c
new file mode 100644
index 0000000..536f00d
--- /dev/null
+++ b/src/waffle/gbm/gbm_priv_egl.c
@@ -0,0 +1,29 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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 "gbm_priv_egl.h"
+#include <waffle/egl/egl_native_template.c>
diff --git a/src/waffle/gbm/gbm_priv_egl.h b/src/waffle/gbm/gbm_priv_egl.h
new file mode 100644
index 0000000..f129d6c
--- /dev/null
+++ b/src/waffle/gbm/gbm_priv_egl.h
@@ -0,0 +1,30 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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.
+
+#pragma once
+
+#define NATIVE_EGL(basename) gbm_egl_##basename
+
+#include <waffle/egl/egl.h>
diff --git a/src/waffle/gbm/gbm_window.c b/src/waffle/gbm/gbm_window.c
new file mode 100644
index 0000000..588588b
--- /dev/null
+++ b/src/waffle/gbm/gbm_window.c
@@ -0,0 +1,82 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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>
+
+#include <gbm.h>
+
+#include <waffle/core/wcore_error.h>
+#include <waffle_gbm.h>
+
+#include "gbm_config.h"
+#include "gbm_display.h"
+#include "gbm_priv_egl.h"
+#include "gbm_window.h"
+
+static const struct wcore_window_vtbl gbm_window_wcore_vtbl;
+
+static bool
+gbm_window_destroy(struct wcore_window *wc_self)
+{
+    return false;
+}
+
+struct wcore_window*
+gbm_window_create(struct wcore_platform *wc_plat,
+                  struct wcore_config *wc_config,
+                  int width,
+                  int height)
+{
+    return NULL;
+}
+
+
+static bool
+gbm_window_show(struct wcore_window *wc_self)
+{
+    return false;
+}
+
+static bool
+gbm_window_swap_buffers(struct wcore_window *wc_self)
+{
+    return false;
+}
+
+static union waffle_native_window*
+gbm_window_get_native(struct wcore_window *wc_self)
+{
+    return NULL;
+}
+
+static const struct wcore_window_vtbl gbm_window_wcore_vtbl = {
+    .destroy = gbm_window_destroy,
+    .get_native = gbm_window_get_native,
+    .show = gbm_window_show,
+    .swap_buffers = gbm_window_swap_buffers,
+};
diff --git a/src/waffle/gbm/gbm_window.h b/src/waffle/gbm/gbm_window.h
new file mode 100644
index 0000000..5512bcc
--- /dev/null
+++ b/src/waffle/gbm/gbm_window.h
@@ -0,0 +1,53 @@
+// Copyright 2012 Intel Corporation
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// - Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+//
+// - Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// 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.
+
+#pragma once
+
+#include <stdbool.h>
+
+#include <EGL/egl.h>
+
+#include <waffle/core/wcore_window.h>
+#include <waffle/core/wcore_util.h>
+
+struct wcore_platform;
+
+struct gbm_window {
+    struct wcore_window wcore;
+
+    struct gbm_surface *gbm_surface;
+
+    EGLSurface egl;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(gbm_window,
+                           struct gbm_window,
+                           struct wcore_window,
+                           wcore)
+struct wcore_window*
+gbm_window_create(struct wcore_platform *wc_plat,
+                  struct wcore_config *wc_config,
+                  int width,
+                  int height);
diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 92b449b..e1eb2ef 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -425,6 +425,55 @@ testsuite_x11_egl(void)
 }
 #endif // WAFFLE_HAS_X11_EGL
 
+#ifdef WAFFLE_HAS_GBM
+TEST(gl_basic, gbm_init)
+{
+    gl_basic_init(WAFFLE_PLATFORM_GBM);
+}
+
+TEST(gl_basic, gbm_gl_rgb)
+{
+    gl_basic_draw(WAFFLE_CONTEXT_OPENGL, 0);
+}
+
+TEST(gl_basic, gbm_gles1_rgb)
+{
+    gl_basic_draw(WAFFLE_CONTEXT_OPENGL_ES1, 0);
+}
+
+TEST(gl_basic, gbm_gles2_rgb)
+{
+    gl_basic_draw(WAFFLE_CONTEXT_OPENGL_ES2, 0);
+}
+
+TEST(gl_basic, gbm_gl_rgba)
+{
+    gl_basic_draw(WAFFLE_CONTEXT_OPENGL, 1);
+}
+
+TEST(gl_basic, gbm_gles1_rgba)
+{
+    gl_basic_draw(WAFFLE_CONTEXT_OPENGL_ES1, 1);
+}
+
+TEST(gl_basic, gbm_gles2_rgba)
+{
+    gl_basic_draw(WAFFLE_CONTEXT_OPENGL_ES2, 1);
+}
+
+static void
+testsuite_gbm(void)
+{
+    TEST_RUN(gl_basic, gbm_init);
+    TEST_RUN(gl_basic, gbm_gl_rgb);
+    TEST_RUN(gl_basic, gbm_gles1_rgb);
+    TEST_RUN(gl_basic, gbm_gles2_rgb);
+    TEST_RUN(gl_basic, gbm_gl_rgba);
+    TEST_RUN(gl_basic, gbm_gles1_rgba);
+    TEST_RUN(gl_basic, gbm_gles2_rgba);
+}
+#endif // WAFFLE_HAS_GBM
+
 
 static void
 usage_error(void)
@@ -497,6 +546,9 @@ main(int argc, char *argv[])
 #ifdef WAFFLE_HAS_X11_EGL
     run_testsuite(testsuite_x11_egl);
 #endif
+#ifdef WAFFLE_HAS_GBM
+    run_testsuite(testsuite_gbm);
+#endif
 
    return 0;
 }
-- 
1.7.9.5



More information about the waffle mailing list