+#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
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)
%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
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
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}
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
%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
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+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}
#define inline __inline__
#include <wayland-drm.h>
-#include <wayland-egl-priv.h>
+#include "wayland-egl/wayland-egl-priv.h"
#include <wayland-client.h>
#include <wayland-drm-client-protocol.h>
--- /dev/null
+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)
--- /dev/null
+#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 <wayland-client.h>
+
+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
--- /dev/null
+#include <stdlib.h>
+
+#include <wayland-client.h>
+#include "wayland-egl.h"
+#include "wayland-egl-priv.h"
+
+#define WL_EGL_DEBUG 1
+#if WL_EGL_DEBUG
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <sys/types.h>
+#include <signal.h>
+
+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);
+}