From: Mun, Gwan-gyeong Date: Tue, 24 Nov 2015 08:55:26 +0000 (+0900) Subject: Add libwayland-egl package X-Git-Tag: submit/tizen_mobile/20151202.065613~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dade9ad69a250e3689b5e0ba1f420ddebd9c2eb2;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git Add libwayland-egl package Change-Id: Icac4d36d3eab4186ea38a3984db10cab2e9ea628 --- diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 7e6dc58..256c127 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -1,27 +1,23 @@ +#TPL VERSION MACROS %define TPL_VER_MAJOR 0 %define TPL_VER_MINOR 8 -%define TPL_RELEASE 9 -%define TPL_VERSION %{TPL_VER_MAJOR}.%{TPL_VER_MINOR} +%define TPL_RELEASE 9 +%define TPL_VERSION %{TPL_VER_MAJOR}.%{TPL_VER_MINOR} %define TPL_VER_FULL %{TPL_VERSION}.%{TPL_RELEASE} +#TPL WINDOW SYSTEM DEFINITION +%define TPL_WINSYS WL + +#TPL FEATURE OPTION %define ENABLE_TTRACE 0 -%define ENABLE_DLOG 0 +%define ENABLE_DLOG 0 %define ENABLE_PNG_DUMP 0 %define ENABLE_WL_TBM 0 -################################################################################ - -%define TPL_WINSYS WL -%if "%{?tizen_version}" == "2.4" -%define TPL_WINSYS DRI3 -%if "%{?tizen_target_name}" == "Z130H" -%define TPL_WINSYS DRI2 -%endif -%if "%{?tizen_target_name}" == "Z300H" -%define TPL_WINSYS DRI2 -%endif -%endif +#WAYLAND-EGL VERSION MACROS +%define WL_EGL_VERSION 1.0.0 +#TPL WINDOW SYSTEM CHECK %if "%{TPL_WINSYS}" != "DRI2" && "%{TPL_WINSYS}" != "DRI3" && "%{TPL_WINSYS}" != "WL" BuildRequires: ERROR(No_window_system_designated) %endif @@ -46,9 +42,6 @@ BuildRequires: pkg-config BuildRequires: pkgconfig(libdrm) BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(dlog) -%if "%{ENABLE_PNG_DUMP}" == "1" -BuildRequires: pkgconfig(libpng) -%endif %if "%{TPL_WINSYS}" == "DRI2" || "%{TPL_WINSYS}" == "DRI3" BuildRequires: pkgconfig(libdri2) @@ -64,15 +57,19 @@ BuildRequires: pkgconfig(xshmfence) %endif %if "%{TPL_WINSYS}" == "WL" +BuildRequires: libtool +BuildRequires: wayland-devel BuildRequires: pkgconfig(gbm) -BuildRequires: wayland-devel %if "%{ENABLE_WL_TBM}" == "1" BuildRequires: pkgconfig(wayland-tbm-client) BuildRequires: pkgconfig(wayland-tbm-server) %else BuildRequires: pkgconfig(wayland-drm) %endif -BuildRequires: libwayland-egl-devel +%endif + +%if "%{ENABLE_PNG_DUMP}" == "1" +BuildRequires: pkgconfig(libpng) %endif %description @@ -87,17 +84,33 @@ The following window systems are supported: Summary: Development files for TPL Group: System/Libraries Requires: %{name} = %{version}-%{release} +%if "%{TPL_WINSYS}" == "WL" +Requires: libwayland-egl-devel +%endif %description devel This package contains the development libraries and header files needed by the DDK for ARM Mali EGL. -################################################################################ +%if "%{TPL_WINSYS}" == "WL" +%package -n libwayland-egl +Summary: Wayland EGL backend + +%description -n libwayland-egl +Wayland EGL backend + +%package -n libwayland-egl-devel +Summary: Development header files for use with Wayland protocol + +%description -n libwayland-egl-devel +Development header files for use with Wayland protocol +%endif %prep %setup -q %build +#libtpl-egl build %if "%{TPL_WINSYS}" == "DRI2" TPL_OPTIONS=${TPL_OPTIONS}-winsys_dri2 %endif @@ -134,6 +147,13 @@ export TPL_RELEASE=%{TPL_RELEASE} make all +#libwayland-egl build +%if "%{TPL_WINSYS}" == "WL" +cd src/wayland-egl +export WLD_EGL_SO_VER=%{WL_EGL_VERSION} +make +%endif + %install rm -fr %{buildroot} mkdir -p %{buildroot} @@ -153,11 +173,22 @@ ln -sf libtpl-egl.so.%{TPL_VER_MAJOR} %{buildroot}%{_libdir}/libtpl-egl.so cp -a src/tpl.h %{buildroot}%{_includedir}/ cp -a pkgconfig/tpl-egl.pc %{buildroot}%{_libdir}/pkgconfig/ -%post -p /sbin/ldconfig +%if "%{TPL_WINSYS}" == "WL" +cd src/wayland-egl +cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so +cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so.1 +cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so.1.0 +export WLD_EGL_SO_VER=%{WL_EGL_VERSION} +%makeinstall +%endif +%post -p /sbin/ldconfig %postun -p /sbin/ldconfig -################################################################################ +%if "%{TPL_WINSYS}" == "WL" +%post -n libwayland-egl -p /sbin/ldconfig +%postun -n libwayland-egl -p /sbin/ldconfig +%endif %files %manifest packaging/libtpl-egl.manifest @@ -172,3 +203,18 @@ cp -a pkgconfig/tpl-egl.pc %{buildroot}%{_libdir}/pkgconfig/ %defattr(-,root,root,-) %{_includedir}/tpl.h %{_libdir}/pkgconfig/tpl-egl.pc + +%if "%{TPL_WINSYS}" == "WL" +%files -n libwayland-egl +%manifest packaging/libwayland-egl.manifest +%license COPYING +%defattr(-,root,root,-) +%{_libdir}/libwayland-egl.so +%{_libdir}/libwayland-egl.so.1 +%{_libdir}/libwayland-egl.so.1.0 +%{_libdir}/libwayland-egl.so.%{WL_EGL_VERSION} + +%files -n libwayland-egl-devel +%defattr(-,root,root,-) +%{_libdir}/pkgconfig/wayland-egl.pc +%endif diff --git a/packaging/libwayland-egl.manifest b/packaging/libwayland-egl.manifest new file mode 100644 index 0000000..97e8c31 --- /dev/null +++ b/packaging/libwayland-egl.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/pkgconfig/wayland-egl.pc b/pkgconfig/wayland-egl.pc new file mode 100644 index 0000000..8d32b34 --- /dev/null +++ b/pkgconfig/wayland-egl.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: wayland-egl +Description: Wayland EGL Protocol for TIZEN (from Mesa) +Version: 10.2.0 +Requires: wayland-client +Libs: -L${libdir} -lwayland-egl +Cflags: -I${includedir} diff --git a/src/tpl_wayland.c b/src/tpl_wayland.c index ca2b8db..a3a880e 100644 --- a/src/tpl_wayland.c +++ b/src/tpl_wayland.c @@ -1,7 +1,7 @@ #define inline __inline__ #include -#include +#include "wayland-egl/wayland-egl-priv.h" #include #include diff --git a/src/wayland-egl/Makefile b/src/wayland-egl/Makefile new file mode 100644 index 0000000..6dda73e --- /dev/null +++ b/src/wayland-egl/Makefile @@ -0,0 +1,33 @@ +WLD_EGL_SO_VER ?= no_ver +SRC_DIR = ./ + +#CROSS_COMPILE ?= arm-none-linux-gnueabi- +TARGET_CC ?= $(CROSS_COMPILE)gcc +TARGET_AR ?= $(CROSS_COMPILE)ar +CFLAGS += -Wall -fno-strict-aliasing -Wno-strict-aliasing -Wno-long-long -O3 -fPIC + +#wayland-egl sources +WAYLAND_EGL_SRCS += \ + $(SRC_DIR)/wayland-egl.c + +%.o: %.c + $(TARGET_CC) -c -o $@ $< $(CFLAGS) + +WAYLAND_EGL_OBJS := $(WAYLAND_EGL_SRCS:.c=.o) + +libwayland-egl.so.$(WLD_EGL_SO_VER): $(WAYLAND_EGL_OBJS) + $(TARGET_CC) -shared -o $@ $(WAYLAND_EGL_OBJS) $(CFLAGS) + +.DEFAULT_GOAL = all +all: libwayland-egl.so.$(WLD_EGL_SO_VER) + +clean: + -rm -f $(WAYLAND_EGL_OBJS) libwayland-egl.so.$(WLD_EGL_SO_VER) + +install: all + cp ../../pkgconfig/wayland-egl.pc $(libdir)/pkgconfig/ + cp libwayland-egl.so.$(WLD_EGL_SO_VER) $(libdir)/ + +uninstall: + -rm -f $(libdir)/pkgconfig/wayland-egl.pc + -rm -f $(libdir)/libwayland-egl.so.$(WLD_EGL_SO_VER) diff --git a/src/wayland-egl/wayland-egl-priv.h b/src/wayland-egl/wayland-egl-priv.h new file mode 100644 index 0000000..da25be9 --- /dev/null +++ b/src/wayland-egl/wayland-egl-priv.h @@ -0,0 +1,36 @@ +#ifndef _WAYLAND_EGL_PRIV_H +#define _WAYLAND_EGL_PRIV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* GCC visibility */ +#if defined(__GNUC__) && __GNUC__ >= 4 +#define WL_EGL_EXPORT __attribute__ ((visibility("default"))) +#else +#define WL_EGL_EXPORT +#endif + +#include + +struct wl_egl_window { + struct wl_surface *surface; + + int width; + int height; + int dx; + int dy; + + int attached_width; + int attached_height; + + void *private; + void (*resize_callback)(struct wl_egl_window *, void *); +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c new file mode 100644 index 0000000..acb35f7 --- /dev/null +++ b/src/wayland-egl/wayland-egl.c @@ -0,0 +1,133 @@ +#include + +#include +#include "wayland-egl.h" +#include "wayland-egl-priv.h" + +#define WL_EGL_DEBUG 1 +#if WL_EGL_DEBUG + +#include +#include +#include +#include +#include + +unsigned int wl_egl_log_level; + +/* WL-EGL Log Level - 0:unintialized, 1:initialized(no logging), 2:min log, 3:more log */ +#define WL_EGL_LOG(lvl, f, x...) \ + { \ + if(wl_egl_log_level == 1) \ + {} \ + else if(wl_egl_log_level > 1) \ + { \ + if(wl_egl_log_level <= lvl) \ + WL_EGL_LOG_PRINT(f, ##x) \ + } \ + else \ + { \ + char *env = getenv("WL_EGL_LOG_LEVEL"); \ + if(env == NULL) \ + wl_egl_log_level = 1; \ + else \ + wl_egl_log_level = atoi(env); \ + \ + if(wl_egl_log_level > 1 && wl_egl_log_level <= lvl) \ + WL_EGL_LOG_PRINT(f, ##x) \ + } \ + } + +#define WL_EGL_LOG_PRINT(fmt, args...) \ + { \ + printf("[\x1b[32mWL-EGL\x1b[0m %d:%d|\x1b[32m%s\x1b[0m|%d] " fmt "\n", \ + getpid(), (int)syscall(SYS_gettid), __func__,__LINE__, ##args); \ + } + +#define WL_EGL_ERR(f, x...) \ + { \ + printf("[\x1b[31mWL-EGL_ERR\x1b[0m %d:%d|\x1b[31m%s\x1b[0m|%d] " f "\n",\ + getpid(), (int)syscall(SYS_gettid), __func__, __LINE__, ##x); \ + } + +#else +#define WL_EGL_LOG(lvl, f, x...) +#endif + +WL_EGL_EXPORT void +wl_egl_window_resize(struct wl_egl_window *egl_window, + int width, int height, + int dx, int dy) +{ + if (egl_window == NULL) + { + WL_EGL_ERR("egl_window is NULL"); + 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->private); + + WL_EGL_LOG(2, "egl_win:%10p WxH:%dx%d dx:%d dy:%d rsz_cb:%10p", + egl_window, egl_window->width, egl_window->height, + egl_window->dx, egl_window->dy, egl_window->resize_callback); +} + +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; + + egl_window = malloc(sizeof *egl_window); + if (!egl_window) + { + WL_EGL_ERR("failed to allocate memory for egl_window"); + return NULL; + } + + egl_window->surface = surface; + egl_window->private = NULL; + egl_window->resize_callback = NULL; + wl_egl_window_resize(egl_window, width, height, 0, 0); + egl_window->attached_width = 0; + egl_window->attached_height = 0; + + WL_EGL_LOG(2, "surf:%10p WxH:%dx%d egl_win:%10p priv:%10p", + surface, width, height, egl_window, egl_window->private); + + return egl_window; +} + +WL_EGL_EXPORT void +wl_egl_window_destroy(struct wl_egl_window *egl_window) +{ + if(egl_window == NULL) + { + WL_EGL_ERR("egl_window is NULL"); + return; + } + + free(egl_window); + + WL_EGL_LOG(2, "egl_win:%10p", 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; + + WL_EGL_LOG(2, "egl_win:%10p w:%10p h:%10p att_w:%d att_h:%d", + egl_window, width, height, egl_window->attached_width, + egl_window->attached_height); +}