Commit c0d6c008 authored by Matt Turner's avatar Matt Turner
Browse files

surfaceless_egl: Implement get_native functions

parent 2698f6f9
Pipeline #575348 passed with stages
in 51 seconds
......@@ -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
......
......@@ -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
......
......@@ -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,
......
......@@ -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;
};
// ---------------------------------------------------------------------------
......
// 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
......@@ -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
......
......@@ -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',
......
// 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;
}
// 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);
......@@ -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;
}
......@@ -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);
......@@ -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,
},
};
......@@ -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;
}
......@@ -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);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment