diff options
author | Xiaowei Guan <xiaowei.guan@samsung.com> | 2019-04-18 16:43:01 +0800 |
---|---|---|
committer | Xuelian Bai <xuelian.bai@samsung.com> | 2019-04-19 02:57:21 +0800 |
commit | 6e7ce80fc524b78980d702549cf5bbc3a641e6ae (patch) | |
tree | 03e3aa32f2cd48fed7f46ec63de1c13e8925955d | |
parent | 7c8922c1ead5875fda90106793c2fcfab2feb9f3 (diff) | |
download | mesa-6e7ce80fc524b78980d702549cf5bbc3a641e6ae.tar.gz mesa-6e7ce80fc524b78980d702549cf5bbc3a641e6ae.tar.bz2 mesa-6e7ce80fc524b78980d702549cf5bbc3a641e6ae.zip |
add wayland-egl code for platform_waylandsubmit/tizen/20190424.023121
Change-Id: Ic7b4623c24f95187bb4effa3e88f6ee691b4b0b3
-rw-r--r-- | src/egl/Makefile.am | 1 | ||||
-rw-r--r-- | src/egl/drivers/dri2/platform_wayland.c | 7 | ||||
-rw-r--r-- | src/egl/wayland/wayland-egl/Makefile.am | 20 | ||||
-rw-r--r-- | src/egl/wayland/wayland-egl/wayland-egl-priv.h | 41 | ||||
-rwxr-xr-x | src/egl/wayland/wayland-egl/wayland-egl-symbols-check | 16 | ||||
-rw-r--r-- | src/egl/wayland/wayland-egl/wayland-egl.c | 102 | ||||
-rw-r--r-- | src/egl/wayland/wayland-egl/wayland-egl.pc.in | 11 |
7 files changed, 194 insertions, 4 deletions
diff --git a/src/egl/Makefile.am b/src/egl/Makefile.am index 2383022962b..ba8d6c599d4 100644 --- a/src/egl/Makefile.am +++ b/src/egl/Makefile.am @@ -125,6 +125,7 @@ AM_CFLAGS += \ -I$(top_builddir)/src/egl/drivers/dri2 \ -I$(top_srcdir)/src/egl/drivers/dri2 \ -I$(top_srcdir)/src/gbm/backends/dri \ + -I$(top_srcdir)/src/egl/wayland/wayland-egl \ -I$(top_builddir)/src/egl/wayland/wayland-drm \ -I$(top_srcdir)/src/egl/wayland/wayland-drm diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 0064f827ef8..c4a58a28d15 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -45,8 +45,7 @@ #include "util/u_vector.h" #include "eglglobals.h" -//include <wayland-egl-backend.h> -#include <wayland-egl-priv.h> +#include "wayland-egl-priv.h" #include <wayland-client.h> #include "wayland-drm-client-protocol.h" #include "linux-dmabuf-unstable-v1-client-protocol.h" @@ -345,7 +344,7 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp, dri2_surf->wl_queue); dri2_surf->wl_win = window; - dri2_surf->wl_win->private = dri2_surf; + dri2_surf->wl_win->driver_private = dri2_surf; dri2_surf->wl_win->destroy_window_callback = destroy_window_callback; if (dri2_dpy->flush) dri2_surf->wl_win->resize_callback = resize_callback; @@ -431,7 +430,7 @@ dri2_wl_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) wl_callback_destroy(dri2_surf->throttle_callback); if (dri2_surf->wl_win) { - dri2_surf->wl_win->private = NULL; + dri2_surf->wl_win->driver_private = NULL; dri2_surf->wl_win->resize_callback = NULL; dri2_surf->wl_win->destroy_window_callback = NULL; } diff --git a/src/egl/wayland/wayland-egl/Makefile.am b/src/egl/wayland/wayland-egl/Makefile.am new file mode 100644 index 00000000000..8c45e8e26d7 --- /dev/null +++ b/src/egl/wayland/wayland-egl/Makefile.am @@ -0,0 +1,20 @@ +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = wayland-egl.pc + +AM_CFLAGS = $(DEFINES) \ + $(VISIBILITY_CFLAGS) \ + $(WAYLAND_CFLAGS) + +lib_LTLIBRARIES = libwayland-egl.la +noinst_HEADERS = wayland-egl-priv.h +libwayland_egl_la_SOURCES = wayland-egl.c +libwayland_egl_la_LDFLAGS = \ + -no-undefined \ + -version-info 1 \ + $(GC_SECTIONS) \ + $(LD_NO_UNDEFINED) + +TESTS = wayland-egl-symbols-check +EXTRA_DIST = wayland-egl-symbols-check + +include $(top_srcdir)/install-lib-links.mk diff --git a/src/egl/wayland/wayland-egl/wayland-egl-priv.h b/src/egl/wayland/wayland-egl/wayland-egl-priv.h new file mode 100644 index 00000000000..63545fee221 --- /dev/null +++ b/src/egl/wayland/wayland-egl/wayland-egl-priv.h @@ -0,0 +1,41 @@ +#ifndef _WAYLAND_EGL_PRIV_H +#define _WAYLAND_EGL_PRIV_H + + +#include <wayland-client.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * NOTE: This version must be kept in sync with the Version field in the + * wayland-egl-backend.pc.in file. + */ +#define WL_EGL_WINDOW_VERSION 3 + +struct wl_surface; + +struct wl_egl_window { + const intptr_t version; + + int width; + int height; + int dx; + int dy; + + int attached_width; + int attached_height; + + void *driver_private; + void (*resize_callback)(struct wl_egl_window *, void *); + void (*destroy_window_callback)(void *); + + struct wl_surface *surface; +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/egl/wayland/wayland-egl/wayland-egl-symbols-check b/src/egl/wayland/wayland-egl/wayland-egl-symbols-check new file mode 100755 index 00000000000..0c5fd09a012 --- /dev/null +++ b/src/egl/wayland/wayland-egl/wayland-egl-symbols-check @@ -0,0 +1,16 @@ +#!/bin/bash + +FUNCS=$(nm -D --defined-only ${1-.libs/libwayland-egl.so} | grep -o "T .*" | cut -c 3- | while read func; do +( grep -q "^$func$" || echo $func ) <<EOF +wl_egl_window_resize +wl_egl_window_create +wl_egl_window_destroy +wl_egl_window_get_attached_size +_fini +_init +EOF +done) + +test ! -n "$FUNCS" || echo $FUNCS +test ! -n "$FUNCS" + diff --git a/src/egl/wayland/wayland-egl/wayland-egl.c b/src/egl/wayland/wayland-egl/wayland-egl.c new file mode 100644 index 00000000000..0ef5fa70291 --- /dev/null +++ b/src/egl/wayland/wayland-egl/wayland-egl.c @@ -0,0 +1,102 @@ +/* + * Copyright © 2011 Kristian Høgsberg + * Copyright © 2011 Benjamin Franzke + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Kristian Høgsberg <krh@bitplanet.net> + * Benjamin Franzke <benjaminfranzke@googlemail.com> + */ + +#include <stdlib.h> + +#include <wayland-client.h> +#include "wayland-egl.h" +#include "wayland-egl-priv.h" + +WL_EGL_EXPORT void +wl_egl_window_resize(struct wl_egl_window *egl_window, + int width, int height, + int dx, int dy) +{ + if (width <= 0 || height <= 0) + return; + + egl_window->width = width; + egl_window->height = height; + egl_window->dx = dx; + egl_window->dy = dy; + + if (egl_window->resize_callback) + egl_window->resize_callback(egl_window, egl_window->driver_private); +} + +WL_EGL_EXPORT struct wl_egl_window * +wl_egl_window_create(struct wl_surface *surface, + int width, int height) +{ + struct wl_egl_window *egl_window; + + if (width <= 0 || height <= 0) + return NULL; + + egl_window = calloc(1, sizeof *egl_window); + if (!egl_window) + return NULL; + + /* Cast away the constness to set the version number. + * + * We want the const notation since it gives an explicit + * feedback to the backend implementation, should it try to + * change it. + * + * The latter in itself is not too surprising as these days APIs + * tend to provide bidirectional version field. + */ + intptr_t *version = (intptr_t *)&egl_window->version; + *version = WL_EGL_WINDOW_VERSION; + + egl_window->surface = surface; + + egl_window->width = width; + egl_window->height = height; + + return egl_window; +} + +WL_EGL_EXPORT void +wl_egl_window_destroy(struct wl_egl_window *egl_window) +{ + if (egl_window->destroy_window_callback) + egl_window->destroy_window_callback(egl_window->driver_private); + free(egl_window); +} + +WL_EGL_EXPORT void +wl_egl_window_get_attached_size(struct wl_egl_window *egl_window, + int *width, int *height) +{ + if (width) + *width = egl_window->attached_width; + if (height) + *height = egl_window->attached_height; +} diff --git a/src/egl/wayland/wayland-egl/wayland-egl.pc.in b/src/egl/wayland/wayland-egl/wayland-egl.pc.in new file mode 100644 index 00000000000..8a40cfac5aa --- /dev/null +++ b/src/egl/wayland/wayland-egl/wayland-egl.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: wayland-egl +Description: Mesa wayland-egl library +Version: @VERSION@ +Requires: wayland-client +Libs: -L${libdir} -lwayland-egl +Cflags: -I${includedir} |