aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2022-04-12 16:04:48 -0700
committerMatt Turner <mattst88@gmail.com>2022-05-02 12:40:55 -0700
commitc0d6c008ed8d66fecfd0b3012b51035ca5da7f1a (patch)
tree8e4a79fa3eadcb4bbbaad3ea0f82fa2c4369b00b
parent2698f6f9f6aa50a7cb99cd51c0344dee9012c705 (diff)
downloadwaffle-c0d6c008ed8d66fecfd0b3012b51035ca5da7f1a.tar.gz
surfaceless_egl: Implement get_native functions
-rw-r--r--Android.mk1
-rw-r--r--include/CMakeLists.txt1
-rw-r--r--include/meson.build1
-rw-r--r--include/waffle-1/waffle.h8
-rw-r--r--include/waffle-1/waffle_surfaceless_egl.h58
-rw-r--r--src/waffle/CMakeLists.txt1
-rw-r--r--src/waffle/meson.build1
-rw-r--r--src/waffle/surfaceless_egl/sl_config.c49
-rw-r--r--src/waffle/surfaceless_egl/sl_config.h36
-rw-r--r--src/waffle/surfaceless_egl/sl_display.c22
-rw-r--r--src/waffle/surfaceless_egl/sl_display.h9
-rw-r--r--src/waffle/surfaceless_egl/sl_platform.c34
-rw-r--r--src/waffle/surfaceless_egl/sl_window.c17
-rw-r--r--src/waffle/surfaceless_egl/sl_window.h3
14 files changed, 230 insertions, 11 deletions
diff --git a/Android.mk b/Android.mk
index e79f33d..5b01337 100644
--- a/Android.mk
+++ b/Android.mk
@@ -101,6 +101,7 @@ LOCAL_COPY_HEADERS := \
include/waffle/waffle.h \
include/waffle/waffle_gbm.h \
include/waffle/waffle_glx.h \
+ include/waffle/waffle_surfaceless_egl.h \
include/waffle/waffle_version.h \
include/waffle/waffle_wayland.h \
include/waffle/waffle_x11_egl.h
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 18a5c0a..3fdab39 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -7,6 +7,7 @@ install(
waffle-1/waffle.h
waffle-1/waffle_gbm.h
waffle-1/waffle_glx.h
+ waffle-1/waffle_surfaceless_egl.h
waffle-1/waffle_version.h
waffle-1/waffle_wayland.h
waffle-1/waffle_x11_egl.h
diff --git a/include/meson.build b/include/meson.build
index b7ea0c2..ba4cd8e 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -42,6 +42,7 @@ install_headers(
'waffle-1/waffle.h',
'waffle-1/waffle_gbm.h',
'waffle-1/waffle_glx.h',
+ 'waffle-1/waffle_surfaceless_egl.h',
'waffle-1/waffle_wayland.h',
'waffle-1/waffle_x11_egl.h',
waffle_config_h,
diff --git a/include/waffle-1/waffle.h b/include/waffle-1/waffle.h
index 71b829b..1ebc364 100644
--- a/include/waffle-1/waffle.h
+++ b/include/waffle-1/waffle.h
@@ -328,12 +328,17 @@ struct waffle_x11_egl_config;
struct waffle_x11_egl_context;
struct waffle_x11_egl_display;
struct waffle_x11_egl_window;
+struct waffle_surfaceless_egl_config;
+struct waffle_surfaceless_egl_context;
+struct waffle_surfaceless_egl_display;
+struct waffle_surfaceless_egl_window;
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;
+ struct waffle_surfaceless_egl_display *surfaceless_egl;
};
union waffle_native_config {
@@ -341,6 +346,7 @@ union waffle_native_config {
struct waffle_glx_config *glx;
struct waffle_x11_egl_config *x11_egl;
struct waffle_wayland_config *wayland;
+ struct waffle_surfaceless_egl_config *surfaceless_egl;
};
union waffle_native_context {
@@ -348,6 +354,7 @@ union waffle_native_context {
struct waffle_glx_context *glx;
struct waffle_x11_egl_context *x11_egl;
struct waffle_wayland_context *wayland;
+ struct waffle_surfaceless_egl_context *surfaceless_egl;
};
union waffle_native_window {
@@ -355,6 +362,7 @@ union waffle_native_window {
struct waffle_glx_window *glx;
struct waffle_x11_egl_window *x11_egl;
struct waffle_wayland_window *wayland;
+ struct waffle_surfaceless_egl_window *surfaceless_egl;
};
// ---------------------------------------------------------------------------
diff --git a/include/waffle-1/waffle_surfaceless_egl.h b/include/waffle-1/waffle_surfaceless_egl.h
new file mode 100644
index 0000000..0eea2ec
--- /dev/null
+++ b/include/waffle-1/waffle_surfaceless_egl.h
@@ -0,0 +1,58 @@
+// Copyright 2022 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 <stdint.h>
+
+#include <EGL/egl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct waffle_surfaceless_egl_display {
+ EGLDisplay egl_display;
+};
+
+struct waffle_surfaceless_egl_config {
+ struct waffle_surfaceless_egl_display display;
+ EGLConfig egl_config;
+};
+
+struct waffle_surfaceless_egl_context {
+ struct waffle_surfaceless_egl_display display;
+ EGLContext egl_context;
+};
+
+struct waffle_surfaceless_egl_window {
+ struct waffle_surfaceless_egl_display display;
+ EGLSurface egl_surface;
+};
+
+#ifdef __cplusplus
+} // end extern "C"
+#endif
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index a3e733f..d3ab3ff 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -123,6 +123,7 @@ endif()
if(waffle_has_surfaceless_egl)
list(APPEND waffle_sources
+ surfaceless_egl/sl_config.c
surfaceless_egl/sl_display.c
surfaceless_egl/sl_platform.c
surfaceless_egl/sl_window.c
diff --git a/src/waffle/meson.build b/src/waffle/meson.build
index 20f7fb8..739b864 100644
--- a/src/waffle/meson.build
+++ b/src/waffle/meson.build
@@ -80,6 +80,7 @@ endif
if build_surfaceless
files_libwaffle += files(
+ 'surfaceless_egl/sl_config.c',
'surfaceless_egl/sl_display.c',
'surfaceless_egl/sl_platform.c',
'surfaceless_egl/sl_window.c',
diff --git a/src/waffle/surfaceless_egl/sl_config.c b/src/waffle/surfaceless_egl/sl_config.c
new file mode 100644
index 0000000..742037a
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_config.c
@@ -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.
+
+#include "sl_config.h"
+
+#include "wcore_error.h"
+
+#include "wegl_platform.h"
+
+#include "sl_display.h"
+
+union waffle_native_config *
+sl_config_get_native(struct wcore_config *wc_config)
+{
+ struct sl_display *dpy = sl_display(wegl_display(wc_config->display));
+ struct wegl_config *config = wegl_config(wc_config);
+ union waffle_native_config *n_config;
+
+ WCORE_CREATE_NATIVE_UNION(n_config, surfaceless_egl);
+ if (!n_config)
+ return NULL;
+
+ sl_display_fill_native(dpy, &n_config->surfaceless_egl->display);
+ n_config->surfaceless_egl->egl_config = config->egl;
+
+ return n_config;
+}
diff --git a/src/waffle/surfaceless_egl/sl_config.h b/src/waffle/surfaceless_egl/sl_config.h
new file mode 100644
index 0000000..658e479
--- /dev/null
+++ b/src/waffle/surfaceless_egl/sl_config.h
@@ -0,0 +1,36 @@
+// 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 "wegl_config.h"
+
+union waffle_native_config;
+
+union waffle_native_config *
+sl_config_get_native(struct wcore_config *wc_config);
diff --git a/src/waffle/surfaceless_egl/sl_display.c b/src/waffle/surfaceless_egl/sl_display.c
index 404378a..1d53fdd 100644
--- a/src/waffle/surfaceless_egl/sl_display.c
+++ b/src/waffle/surfaceless_egl/sl_display.c
@@ -68,3 +68,25 @@ fail:
sl_display_destroy(&self->wegl.wcore);
return NULL;
}
+
+void
+sl_display_fill_native(struct sl_display *self,
+ struct waffle_surfaceless_egl_display *n_dpy)
+{
+ n_dpy->egl_display = self->wegl.egl;
+}
+
+union waffle_native_display *
+sl_display_get_native(struct wcore_display *wc_self)
+{
+ struct sl_display *self = sl_display(wegl_display(wc_self));
+ union waffle_native_display *n_dpy;
+
+ WCORE_CREATE_NATIVE_UNION(n_dpy, surfaceless_egl);
+ if (n_dpy == NULL)
+ return NULL;
+
+ sl_display_fill_native(self, n_dpy->surfaceless_egl);
+
+ return n_dpy;
+}
diff --git a/src/waffle/surfaceless_egl/sl_display.h b/src/waffle/surfaceless_egl/sl_display.h
index 22f694c..0451788 100644
--- a/src/waffle/surfaceless_egl/sl_display.h
+++ b/src/waffle/surfaceless_egl/sl_display.h
@@ -27,6 +27,8 @@
#include <stdbool.h>
+#include "waffle_surfaceless_egl.h"
+
#include "wegl_display.h"
struct sl_display {
@@ -43,3 +45,10 @@ sl_display_connect(struct wcore_platform *wc_plat, const char *name);
bool
sl_display_destroy(struct wcore_display *wc_self);
+
+union waffle_native_display *
+sl_display_get_native(struct wcore_display *wc_self);
+
+void
+sl_display_fill_native(struct sl_display *self,
+ struct waffle_surfaceless_egl_display *n_dpy);
diff --git a/src/waffle/surfaceless_egl/sl_platform.c b/src/waffle/surfaceless_egl/sl_platform.c
index 5904e15..b0516dc 100644
--- a/src/waffle/surfaceless_egl/sl_platform.c
+++ b/src/waffle/surfaceless_egl/sl_platform.c
@@ -23,8 +23,8 @@
// 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 <stdlib.h>
#include "wcore_error.h"
@@ -35,6 +35,7 @@
#include "wegl_platform.h"
#include "wegl_util.h"
+#include "sl_config.h"
#include "sl_display.h"
#include "sl_platform.h"
#include "sl_window.h"
@@ -100,12 +101,23 @@ sl_dl_sym(struct wcore_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 union waffle_native_context *
+sl_context_get_native(struct wcore_context *wc_ctx)
+{
+ struct sl_display *dpy = sl_display(wegl_display(wc_ctx->display));
+ struct wegl_context *ctx = wegl_context(wc_ctx);
+ union waffle_native_context *n_ctx;
+
+ WCORE_CREATE_NATIVE_UNION(n_ctx, surfaceless_egl);
+ if (!n_ctx)
+ return NULL;
+
+ sl_display_fill_native(dpy, &n_ctx->surfaceless_egl->display);
+ n_ctx->surfaceless_egl->egl_context = ctx->egl;
+
+ return n_ctx;
+}
+
static const struct wcore_platform_vtbl sl_platform_vtbl = {
.destroy = sl_platform_destroy,
@@ -119,19 +131,19 @@ static const struct wcore_platform_vtbl sl_platform_vtbl = {
.connect = sl_display_connect,
.destroy = sl_display_destroy,
.supports_context_api = wegl_display_supports_context_api,
- .get_native = NULL, // unsupported by platform
+ .get_native = sl_display_get_native,
},
.config = {
.choose = wegl_config_choose,
.destroy = wegl_config_destroy,
- .get_native = NULL, // unsupported by platform
+ .get_native = sl_config_get_native,
},
.context = {
.create = wegl_context_create,
.destroy = wegl_context_destroy,
- .get_native = NULL, // unsupported by platform
+ .get_native = sl_context_get_native,
},
.window = {
@@ -140,6 +152,6 @@ static const struct wcore_platform_vtbl sl_platform_vtbl = {
.show = sl_window_show,
.resize = sl_window_resize,
.swap_buffers = wegl_surface_swap_buffers,
- .get_native = NULL, // unsupported by platform
+ .get_native = sl_window_get_native,
},
};
diff --git a/src/waffle/surfaceless_egl/sl_window.c b/src/waffle/surfaceless_egl/sl_window.c
index 21affd0..45f71d2 100644
--- a/src/waffle/surfaceless_egl/sl_window.c
+++ b/src/waffle/surfaceless_egl/sl_window.c
@@ -128,3 +128,20 @@ error:
wegl_surface_teardown(&new_wegl);
return false;
}
+
+union waffle_native_window *
+sl_window_get_native(struct wcore_window *wc_self)
+{
+ struct sl_window *self = sl_window(wegl_surface(wc_self));
+ struct sl_display *dpy = sl_display(wegl_display(wc_self->display));
+ union waffle_native_window *n_window;
+
+ WCORE_CREATE_NATIVE_UNION(n_window, surfaceless_egl);
+ if (n_window == NULL)
+ return NULL;
+
+ sl_display_fill_native(dpy, &n_window->surfaceless_egl->display);
+ n_window->surfaceless_egl->egl_surface = self->wegl.egl;
+
+ return n_window;
+}
diff --git a/src/waffle/surfaceless_egl/sl_window.h b/src/waffle/surfaceless_egl/sl_window.h
index 5432845..0090bab 100644
--- a/src/waffle/surfaceless_egl/sl_window.h
+++ b/src/waffle/surfaceless_egl/sl_window.h
@@ -56,3 +56,6 @@ sl_window_show(struct wcore_window *wc_self);
bool
sl_window_resize(struct wcore_window *wc_self,
int32_t width, int32_t height);
+
+union waffle_native_window *
+sl_window_get_native(struct wcore_window *wc_self);