[waffle] [PATCH 5/7] surfaceless_egl: Implement new platform

Chad Versace chadversary at chromium.org
Tue Oct 18 17:33:03 UTC 2016


Now waffle_init() supports WAFFLE_PLATFORM_SURFACELESS_EGL.

Cc: Gurchetan Singh <gurchetansingh at chromium.org>
Cc: Haixia Shi <hshi at chromium.org>
---
 include/waffle/waffle.h                  |   1 +
 man/waffle_init.3.xml                    |   9 ++
 src/waffle/CMakeLists.txt                |   9 ++
 src/waffle/api/waffle_init.c             |  12 +++
 src/waffle/egl/wegl_platform.c           |   6 ++
 src/waffle/surfaceless_egl/sl_display.c  |  70 +++++++++++++++
 src/waffle/surfaceless_egl/sl_display.h  |  45 ++++++++++
 src/waffle/surfaceless_egl/sl_platform.c | 144 +++++++++++++++++++++++++++++++
 src/waffle/surfaceless_egl/sl_platform.h |  49 +++++++++++
 src/waffle/surfaceless_egl/sl_window.c   |  92 ++++++++++++++++++++
 src/waffle/surfaceless_egl/sl_window.h   |  53 ++++++++++++
 11 files changed, 490 insertions(+)
 create mode 100644 src/waffle/surfaceless_egl/sl_display.c
 create mode 100644 src/waffle/surfaceless_egl/sl_display.h
 create mode 100644 src/waffle/surfaceless_egl/sl_platform.c
 create mode 100644 src/waffle/surfaceless_egl/sl_platform.h
 create mode 100644 src/waffle/surfaceless_egl/sl_window.c
 create mode 100644 src/waffle/surfaceless_egl/sl_window.h

diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
index db94a5e..82795d8 100644
--- a/include/waffle/waffle.h
+++ b/include/waffle/waffle.h
@@ -119,6 +119,7 @@ enum waffle_enum {
         WAFFLE_PLATFORM_GBM                                     = 0x0016,
         WAFFLE_PLATFORM_WGL                                     = 0x0017,
         WAFFLE_PLATFORM_NACL                                    = 0x0018,
+        WAFFLE_PLATFORM_SURFACELESS_EGL                         = 0x0019,
 
     // ------------------------------------------------------------------
     // For waffle_config_choose()
diff --git a/man/waffle_init.3.xml b/man/waffle_init.3.xml
index 76a2dee..19d4b91 100644
--- a/man/waffle_init.3.xml
+++ b/man/waffle_init.3.xml
@@ -130,6 +130,15 @@
                 </listitem>
               </varlistentry>
               <varlistentry>
+                <term><constant>WAFFLE_PLATFORM_SURFACELESS_EGL</constant></term>
+                <listitem>
+                  <para>
+                    [Linux] Use EGL's "surfaceless" platform,
+                    <ulink url="https://www.khronos.org/registry/egl/extensions/MESA/EGL_MESA_platform_surfaceless.txt">EGL_MESA_platform_surfaceless</ulink>.
+                  </para>
+                </listitem>
+              </varlistentry>
+              <varlistentry>
                 <term><constant>WAFFLE_PLATFORM_WAYLAND</constant></term>
                 <listitem>
                   <para>
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index 9150f7d..fa00bd8 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -16,6 +16,7 @@ include_directories(
     glx
     linux
     nacl
+    surfaceless_egl
     wayland
     wgl
     x11
@@ -127,6 +128,14 @@ if(waffle_on_linux)
         )
 endif()
 
+if(waffle_has_surfaceless_egl)
+    list(APPEND waffle_sources
+        surfaceless_egl/sl_display.c
+        surfaceless_egl/sl_platform.c
+        surfaceless_egl/sl_window.c
+    )
+endif()
+
 if(waffle_has_wayland)
     list(APPEND waffle_sources
         wayland/wayland_display.c
diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c
index d769270..c9a16cf 100644
--- a/src/waffle/api/waffle_init.c
+++ b/src/waffle/api/waffle_init.c
@@ -36,6 +36,7 @@ struct wcore_platform* xegl_platform_create(void);
 struct wcore_platform* wgbm_platform_create(void);
 struct wcore_platform* wgl_platform_create(void);
 struct wcore_platform* nacl_platform_create(void);
+struct wcore_platform* sl_platform_create(void);
 
 static bool
 waffle_init_parse_attrib_list(
@@ -111,6 +112,12 @@ waffle_init_parse_attrib_list(
                     CASE_UNDEFINED_PLATFORM(NACL)
 #endif
 
+#ifdef WAFFLE_HAS_SURFACELESS_EGL
+                    CASE_DEFINED_PLATFORM(SURFACELESS_EGL)
+#else
+                    CASE_UNDEFINED_PLATFORM(SURFACELESS_EGL)
+#endif
+
                     default:
                         wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
                                      "WAFFLE_PLATFORM has bad value 0x%x",
@@ -185,6 +192,11 @@ waffle_init_create_platform(int32_t waffle_platform)
             wc_platform = nacl_platform_create();
             break;
 #endif
+#ifdef WAFFLE_HAS_SURFACELESS_EGL
+        case WAFFLE_PLATFORM_SURFACELESS_EGL:
+            wc_platform = sl_platform_create();
+            break;
+#endif
         default:
             assert(false);
             return NULL;
diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 331cc89..2be250f 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -53,6 +53,9 @@ setup_env(const struct wegl_platform *self)
         case EGL_PLATFORM_X11_KHR:
             setenv("EGL_PLATFORM", "x11", true);
             break;
+        case EGL_PLATFORM_SURFACELESS_MESA:
+            setenv("EGL_PLATFORM", "surfaceless", true);
+            break;
         default:
             assert(!"bad egl_platform enum");
             break;
@@ -181,6 +184,9 @@ wegl_platform_can_use_eglGetPlatformDisplay(const struct wegl_platform *plat)
         case EGL_PLATFORM_X11_KHR:
             ext = "EGL_KHR_platform_x11";
             break;
+        case EGL_PLATFORM_SURFACELESS_MESA:
+            ext = "EGL_MESA_platform_surfaceless";
+            break;
         default:
             assert(!"bad egl_platform enum");
             return false;
diff --git a/src/waffle/surfaceless_egl/sl_display.c b/src/waffle/surfaceless_egl/sl_display.c
new file mode 100644
index 0000000..404378a
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_display.c
@@ -0,0 +1,70 @@
+// Copyright 2016 Google
+//
+// 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.
+
+#include "wcore_error.h"
+
+#include "sl_display.h"
+#include "sl_platform.h"
+
+bool
+sl_display_destroy(struct wcore_display *wc_self)
+{
+    struct sl_display *self = sl_display(wegl_display(wc_self));
+    bool ok = true;
+
+    if (!self)
+        return ok;
+
+    ok &= wegl_display_teardown(&self->wegl);
+    free(self);
+    return ok;
+}
+
+struct wcore_display*
+sl_display_connect(struct wcore_platform *wc_plat, const char *name)
+{
+    struct sl_display *self;
+    bool ok = true;
+
+    self = wcore_calloc(sizeof(*self));
+    if (self == NULL)
+        return NULL;
+
+    if (name != NULL) {
+        wcore_errorf(WAFFLE_ERROR_BAD_PARAMETER,
+                     "parameter 'name' is not NULL");
+        goto fail;
+    }
+
+    ok = wegl_display_init(&self->wegl, wc_plat, NULL);
+    if (!ok)
+        goto fail;
+
+    return &self->wegl.wcore;
+
+fail:
+    sl_display_destroy(&self->wegl.wcore);
+    return NULL;
+}
diff --git a/src/waffle/surfaceless_egl/sl_display.h b/src/waffle/surfaceless_egl/sl_display.h
new file mode 100644
index 0000000..22f694c
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_display.h
@@ -0,0 +1,45 @@
+// Copyright 2016 Google
+//
+// 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 "wegl_display.h"
+
+struct sl_display {
+    struct wegl_display wegl;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(sl_display,
+                           struct sl_display,
+                           struct wegl_display,
+                           wegl)
+
+struct wcore_display*
+sl_display_connect(struct wcore_platform *wc_plat, const char *name);
+
+bool
+sl_display_destroy(struct wcore_display *wc_self);
diff --git a/src/waffle/surfaceless_egl/sl_platform.c b/src/waffle/surfaceless_egl/sl_platform.c
new file mode 100644
index 0000000..fa69f79
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_platform.c
@@ -0,0 +1,144 @@
+// 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.
+
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include "wcore_error.h"
+
+#include "linux_platform.h"
+
+#include "wegl_config.h"
+#include "wegl_context.h"
+#include "wegl_platform.h"
+#include "wegl_util.h"
+
+#include "sl_display.h"
+#include "sl_platform.h"
+#include "sl_window.h"
+
+static const struct wcore_platform_vtbl sl_platform_vtbl;
+
+static bool
+sl_platform_destroy(struct wcore_platform *wc_self)
+{
+    struct sl_platform *self = sl_platform(wegl_platform(wc_self));
+    bool ok = true;
+
+    if (!self)
+        return true;
+
+    if (self->linux)
+        ok &= linux_platform_destroy(self->linux);
+
+    ok &= wegl_platform_teardown(&self->wegl);
+    free(self);
+    return ok;
+}
+
+struct wcore_platform*
+sl_platform_create(void)
+{
+    bool ok = true;
+
+    struct sl_platform *self = wcore_calloc(sizeof(*self));
+    if (self == NULL)
+        return NULL;
+
+    ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_SURFACELESS_MESA);
+    if (!ok)
+        goto fail;
+
+    self->wegl.egl_surface_type_mask = EGL_PBUFFER_BIT;
+
+    self->linux = linux_platform_create();
+    if (!self->linux)
+        goto fail;
+
+    self->wegl.wcore.vtbl = &sl_platform_vtbl;
+    return &self->wegl.wcore;
+
+fail:
+    sl_platform_destroy(&self->wegl.wcore);
+    return NULL;
+}
+
+static bool
+sl_dl_can_open(struct wcore_platform *wc_self, int32_t waffle_dl)
+{
+    struct sl_platform *self = sl_platform(wegl_platform(wc_self));
+    return linux_platform_dl_can_open(self->linux, waffle_dl);
+}
+
+static void*
+sl_dl_sym(struct wcore_platform *wc_self,
+          int32_t waffle_dl, const char *name)
+{
+    struct sl_platform *self = sl_platform(wegl_platform(wc_self));
+    return linux_platform_dl_sym(self->linux, waffle_dl, name);
+}
+
+// [chadv] I regret the design of the get_native interface, and wish to
+// deprecate and replace it with the interface that Ian Romanick orignally
+// recommended: waffle_display_get_egl_display(),
+// waffle_display_get_gbm_device(), waffle_display_get_xlib_display(), etc.  As
+// a first step towards that goal, I choose to not support the interface on new
+// platforms.
+static const struct wcore_platform_vtbl sl_platform_vtbl = {
+    .destroy = sl_platform_destroy,
+
+    .make_current = wegl_make_current,
+    .get_proc_address = wegl_get_proc_address,
+
+    .dl_can_open = sl_dl_can_open,
+    .dl_sym = sl_dl_sym,
+
+    .display = {
+        .connect = sl_display_connect,
+        .destroy = sl_display_destroy,
+        .supports_context_api = wegl_display_supports_context_api,
+        .get_native = NULL, // unsupported by platform
+    },
+
+    .config = {
+        .choose = wegl_config_choose,
+        .destroy = wegl_config_destroy,
+        .get_native = NULL, // unsupported by platform
+    },
+
+    .context = {
+        .create = wegl_context_create,
+        .destroy = wegl_context_destroy,
+        .get_native = NULL, // unsupported by platform
+    },
+
+    .window = {
+        .create = sl_window_create,
+        .destroy = sl_window_destroy,
+        .show = sl_window_show,
+        .swap_buffers = wegl_surface_swap_buffers,
+        .get_native = NULL, // unsupported by platform
+    },
+};
diff --git a/src/waffle/surfaceless_egl/sl_platform.h b/src/waffle/surfaceless_egl/sl_platform.h
new file mode 100644
index 0000000..5bccd1d
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_platform.h
@@ -0,0 +1,49 @@
+// Copyright 2016 Google
+//
+// 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>
+#include <gbm.h>
+
+#undef linux
+
+#include "wegl_platform.h"
+#include "wcore_util.h"
+
+struct linux_platform;
+
+struct sl_platform {
+    struct wegl_platform wegl;
+    struct linux_platform *linux;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(sl_platform,
+                           struct sl_platform,
+                           struct wegl_platform,
+                           wegl)
+
+struct wcore_platform *sl_platform_create(void);
diff --git a/src/waffle/surfaceless_egl/sl_window.c b/src/waffle/surfaceless_egl/sl_window.c
new file mode 100644
index 0000000..ffba0f4
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_window.c
@@ -0,0 +1,92 @@
+// Copyright 2016 Google
+//
+// 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.
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "wcore_attrib_list.h"
+#include "wcore_error.h"
+
+#include "wegl_config.h"
+
+#include "sl_display.h"
+#include "sl_platform.h"
+#include "sl_window.h"
+
+bool
+sl_window_destroy(struct wcore_window *wc_self)
+{
+    struct sl_window *self = sl_window(wegl_surface(wc_self));
+    bool ok = true;
+
+    if (!self)
+        return true;
+
+    ok &= wegl_surface_teardown(&self->wegl);
+    free(self);
+    return ok;
+}
+
+struct wcore_window*
+sl_window_create(struct wcore_platform *wc_plat,
+                   struct wcore_config *wc_config,
+                   int32_t width,
+                   int32_t height,
+                   const intptr_t attrib_list[])
+{
+    struct sl_window *self;
+    bool ok = true;
+
+    if (width == -1 && height == -1) {
+        wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+                     "fullscreen window not supported");
+        return NULL;
+    }
+
+    if (wcore_attrib_list_length(attrib_list) > 0) {
+        wcore_error_bad_attribute(attrib_list[0]);
+        return NULL;
+    }
+
+    self = wcore_calloc(sizeof(*self));
+    if (self == NULL)
+        return NULL;
+
+    ok = wegl_pbuffer_init(&self->wegl, wc_config, width, height);
+    if (!ok)
+        goto error;
+
+    return &self->wegl.wcore;
+
+error:
+    sl_window_destroy(&self->wegl.wcore);
+    return NULL;
+}
+
+bool
+sl_window_show(struct wcore_window *wc_self)
+{
+    return true;
+}
diff --git a/src/waffle/surfaceless_egl/sl_window.h b/src/waffle/surfaceless_egl/sl_window.h
new file mode 100644
index 0000000..516e302
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_window.h
@@ -0,0 +1,53 @@
+// Copyright 2016 Google
+//
+// 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 "wegl_surface.h"
+
+struct wcore_platform;
+
+struct sl_window {
+    struct wegl_surface wegl;
+};
+
+DEFINE_CONTAINER_CAST_FUNC(sl_window,
+                           struct sl_window,
+                           struct wegl_surface,
+                           wegl)
+
+struct wcore_window*
+sl_window_create(struct wcore_platform *wc_plat,
+                   struct wcore_config *wc_config,
+                   int32_t width,
+                   int32_t height,
+                   const intptr_t attrib_list[]);
+bool
+sl_window_destroy(struct wcore_window *wc_self);
+
+bool
+sl_window_show(struct wcore_window *wc_self);
-- 
2.10.0



More information about the waffle mailing list