Will be used to store all the egl function pointers, in order to avoid linking against libEGL.so.
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com> --- src/waffle/CMakeLists.txt | 1 + src/waffle/egl/wegl_platform.c | 44 +++++++++++++++++++++++++++++++++ src/waffle/egl/wegl_platform.h | 46 +++++++++++++++++++++++++++++++++++ src/waffle/gbm/wgbm_platform.c | 22 ++++++++--------- src/waffle/gbm/wgbm_platform.h | 8 +++--- src/waffle/wayland/wayland_platform.c | 22 ++++++++--------- src/waffle/wayland/wayland_platform.h | 8 +++--- src/waffle/xegl/xegl_platform.c | 22 ++++++++--------- src/waffle/xegl/xegl_platform.h | 8 +++--- 9 files changed, 136 insertions(+), 45 deletions(-) create mode 100644 src/waffle/egl/wegl_platform.c create mode 100644 src/waffle/egl/wegl_platform.h diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt index 3fca87f..b7612e5 100644 --- a/src/waffle/CMakeLists.txt +++ b/src/waffle/CMakeLists.txt @@ -85,6 +85,7 @@ if(waffle_has_egl) egl/wegl_config.c egl/wegl_context.c egl/wegl_display.c + egl/wegl_platform.c egl/wegl_util.c egl/wegl_window.c ) diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c new file mode 100644 index 0000000..b67e8d2 --- /dev/null +++ b/src/waffle/egl/wegl_platform.c @@ -0,0 +1,44 @@ +// Copyright 2014 Emil Velikov +// +// 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 "wegl_platform.h" + +bool +wegl_platform_teardown(struct wegl_platform *self) +{ + bool ok; + + ok = wcore_platform_teardown(&self->wcore); + return ok; +} +bool +wegl_platform_init(struct wegl_platform *self) +{ + bool ok; + + ok = wcore_platform_init(&self->wcore); + + return ok; +} diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h new file mode 100644 index 0000000..43108dc --- /dev/null +++ b/src/waffle/egl/wegl_platform.h @@ -0,0 +1,46 @@ +// Copyright 2014 Emil Velikov +// +// 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 "wcore_platform.h" +#include "wcore_util.h" + +struct wegl_platform { + struct wcore_platform wcore; + + // EGL function pointers +}; + +DEFINE_CONTAINER_CAST_FUNC(wegl_platform, + struct wegl_platform, + struct wcore_platform, + wcore) + +bool +wegl_platform_teardown(struct wegl_platform *self); + +bool +wegl_platform_init(struct wegl_platform *self); diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c index 5624660..906b9a3 100644 --- a/src/waffle/gbm/wgbm_platform.c +++ b/src/waffle/gbm/wgbm_platform.c @@ -34,6 +34,7 @@ #include "wegl_config.h" #include "wegl_context.h" +#include "wegl_platform.h" #include "wegl_util.h" #include "wgbm_config.h" @@ -46,7 +47,7 @@ static const struct wcore_platform_vtbl wgbm_platform_vtbl; static bool wgbm_platform_destroy(struct wcore_platform *wc_self) { - struct wgbm_platform *self = wgbm_platform(wc_self); + struct wgbm_platform *self = wgbm_platform(wegl_platform(wc_self)); bool ok = true; if (!self) @@ -57,7 +58,7 @@ wgbm_platform_destroy(struct wcore_platform *wc_self) if (self->linux) ok &= linux_platform_destroy(self->linux); - ok &= wcore_platform_teardown(wc_self); + ok &= wegl_platform_teardown(&self->wegl); free(self); return ok; } @@ -72,7 +73,7 @@ wgbm_platform_create(void) if (self == NULL) return NULL; - ok = wcore_platform_init(&self->wcore); + ok = wegl_platform_init(&self->wegl); if (!ok) goto error; @@ -82,11 +83,11 @@ wgbm_platform_create(void) setenv("EGL_PLATFORM", "drm", true); - self->wcore.vtbl = &wgbm_platform_vtbl; - return &self->wcore; + self->wegl.wcore.vtbl = &wgbm_platform_vtbl; + return &self->wegl.wcore; error: - wgbm_platform_destroy(&self->wcore); + wgbm_platform_destroy(&self->wegl.wcore); return NULL; } @@ -94,8 +95,8 @@ static bool wgbm_dl_can_open(struct wcore_platform *wc_self, int32_t waffle_dl) { - return linux_platform_dl_can_open(wgbm_platform(wc_self)->linux, - waffle_dl); + struct wgbm_platform *self = wgbm_platform(wegl_platform(wc_self)); + return linux_platform_dl_can_open(self->linux, waffle_dl); } static void* @@ -103,9 +104,8 @@ wgbm_dl_sym(struct wcore_platform *wc_self, int32_t waffle_dl, const char *name) { - return linux_platform_dl_sym(wgbm_platform(wc_self)->linux, - waffle_dl, - name); + struct wgbm_platform *self = wgbm_platform(wegl_platform(wc_self)); + return linux_platform_dl_sym(self->linux, waffle_dl, name); } static union waffle_native_context* diff --git a/src/waffle/gbm/wgbm_platform.h b/src/waffle/gbm/wgbm_platform.h index c833780..11a5867 100644 --- a/src/waffle/gbm/wgbm_platform.h +++ b/src/waffle/gbm/wgbm_platform.h @@ -30,20 +30,20 @@ #undef linux -#include "wcore_platform.h" +#include "wegl_platform.h" #include "wcore_util.h" struct linux_platform; struct wgbm_platform { - struct wcore_platform wcore; + struct wegl_platform wegl; struct linux_platform *linux; }; DEFINE_CONTAINER_CAST_FUNC(wgbm_platform, struct wgbm_platform, - struct wcore_platform, - wcore) + struct wegl_platform, + wegl) struct wcore_platform* wgbm_platform_create(void); diff --git a/src/waffle/wayland/wayland_platform.c b/src/waffle/wayland/wayland_platform.c index 8ca30d4..63cfdc2 100644 --- a/src/waffle/wayland/wayland_platform.c +++ b/src/waffle/wayland/wayland_platform.c @@ -36,6 +36,7 @@ #include "wegl_config.h" #include "wegl_context.h" +#include "wegl_platform.h" #include "wegl_util.h" #include "wayland_display.h" @@ -47,7 +48,7 @@ static const struct wcore_platform_vtbl wayland_platform_vtbl; static bool wayland_platform_destroy(struct wcore_platform *wc_self) { - struct wayland_platform *self = wayland_platform(wc_self); + struct wayland_platform *self = wayland_platform(wegl_platform(wc_self)); bool ok = true; if (!self) @@ -58,7 +59,7 @@ wayland_platform_destroy(struct wcore_platform *wc_self) if (self->linux) ok &= linux_platform_destroy(self->linux); - ok &= wcore_platform_teardown(wc_self); + ok &= wegl_platform_teardown(&self->wegl); free(self); return ok; } @@ -73,7 +74,7 @@ wayland_platform_create(void) if (self == NULL) return NULL; - ok = wcore_platform_init(&self->wcore); + ok = wegl_platform_init(&self->wegl); if (!ok) goto error; @@ -83,11 +84,11 @@ wayland_platform_create(void) setenv("EGL_PLATFORM", "wayland", true); - self->wcore.vtbl = &wayland_platform_vtbl; - return &self->wcore; + self->wegl.wcore.vtbl = &wayland_platform_vtbl; + return &self->wegl.wcore; error: - wayland_platform_destroy(&self->wcore); + wayland_platform_destroy(&self->wegl.wcore); return NULL; } @@ -95,8 +96,8 @@ static bool wayland_dl_can_open(struct wcore_platform *wc_self, int32_t waffle_dl) { - return linux_platform_dl_can_open(wayland_platform(wc_self)->linux, - waffle_dl); + struct wayland_platform *self = wayland_platform(wegl_platform(wc_self)); + return linux_platform_dl_can_open(self->linux, waffle_dl); } static void* @@ -104,9 +105,8 @@ wayland_dl_sym(struct wcore_platform *wc_self, int32_t waffle_dl, const char *name) { - return linux_platform_dl_sym(wayland_platform(wc_self)->linux, - waffle_dl, - name); + struct wayland_platform *self = wayland_platform(wegl_platform(wc_self)); + return linux_platform_dl_sym(self->linux, waffle_dl, name); } static union waffle_native_config* diff --git a/src/waffle/wayland/wayland_platform.h b/src/waffle/wayland/wayland_platform.h index 41ca8f5..c4e870f 100644 --- a/src/waffle/wayland/wayland_platform.h +++ b/src/waffle/wayland/wayland_platform.h @@ -32,20 +32,20 @@ #include "waffle_wayland.h" -#include "wcore_platform.h" +#include "wegl_platform.h" #include "wcore_util.h" struct linux_platform; struct wayland_platform { - struct wcore_platform wcore; + struct wegl_platform wegl; struct linux_platform *linux; }; DEFINE_CONTAINER_CAST_FUNC(wayland_platform, struct wayland_platform, - struct wcore_platform, - wcore) + struct wegl_platform, + wegl) struct wcore_platform* wayland_platform_create(void); diff --git a/src/waffle/xegl/xegl_platform.c b/src/waffle/xegl/xegl_platform.c index 71bf23c..e36a41b 100644 --- a/src/waffle/xegl/xegl_platform.c +++ b/src/waffle/xegl/xegl_platform.c @@ -31,6 +31,7 @@ #include "wegl_config.h" #include "wegl_context.h" +#include "wegl_platform.h" #include "wegl_util.h" #include "linux_platform.h" @@ -44,7 +45,7 @@ static const struct wcore_platform_vtbl xegl_platform_vtbl; static bool xegl_platform_destroy(struct wcore_platform *wc_self) { - struct xegl_platform *self = xegl_platform(wc_self); + struct xegl_platform *self = xegl_platform(wegl_platform(wc_self)); bool ok = true; if (!self) @@ -55,7 +56,7 @@ xegl_platform_destroy(struct wcore_platform *wc_self) if (self->linux) ok &= linux_platform_destroy(self->linux); - ok &= wcore_platform_teardown(wc_self); + ok &= wegl_platform_teardown(&self->wegl); free(self); return ok; } @@ -70,7 +71,7 @@ xegl_platform_create(void) if (self == NULL) return NULL; - ok = wcore_platform_init(&self->wcore); + ok = wegl_platform_init(&self->wegl); if (!ok) goto error; @@ -80,11 +81,11 @@ xegl_platform_create(void) setenv("EGL_PLATFORM", "x11", true); - self->wcore.vtbl = &xegl_platform_vtbl; - return &self->wcore; + self->wegl.wcore.vtbl = &xegl_platform_vtbl; + return &self->wegl.wcore; error: - xegl_platform_destroy(&self->wcore); + xegl_platform_destroy(&self->wegl.wcore); return NULL; } @@ -92,8 +93,8 @@ static bool xegl_dl_can_open(struct wcore_platform *wc_self, int32_t waffle_dl) { - return linux_platform_dl_can_open(xegl_platform(wc_self)->linux, - waffle_dl); + struct xegl_platform *self = xegl_platform(wegl_platform(wc_self)); + return linux_platform_dl_can_open(self->linux, waffle_dl); } static void* @@ -101,9 +102,8 @@ xegl_dl_sym(struct wcore_platform *wc_self, int32_t waffle_dl, const char *name) { - return linux_platform_dl_sym(xegl_platform(wc_self)->linux, - waffle_dl, - name); + struct xegl_platform *self = xegl_platform(wegl_platform(wc_self)); + return linux_platform_dl_sym(self->linux, waffle_dl, name); } static union waffle_native_config* diff --git a/src/waffle/xegl/xegl_platform.h b/src/waffle/xegl/xegl_platform.h index 835f360..003343f 100644 --- a/src/waffle/xegl/xegl_platform.h +++ b/src/waffle/xegl/xegl_platform.h @@ -31,20 +31,20 @@ #include "waffle_x11_egl.h" -#include "wcore_platform.h" +#include "wegl_platform.h" #include "wcore_util.h" struct linux_platform; struct xegl_platform { - struct wcore_platform wcore; + struct wegl_platform wegl; struct linux_platform *linux; }; DEFINE_CONTAINER_CAST_FUNC(xegl_platform, struct xegl_platform, - struct wcore_platform, - wcore) + struct wegl_platform, + wegl) struct wcore_platform* xegl_platform_create(void); -- 2.0.2 _______________________________________________ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle