From: Zhaowei Yuan Date: Mon, 3 Dec 2018 03:08:44 +0000 (+0800) Subject: EGL: Add support for weston X-Git-Tag: accepted/tizen/unified/20230227.042036~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9785bbb1a5ac85b3191968520351fa848a5f4b78;p=platform%2Fupstream%2Fmesa.git EGL: Add support for weston Add support for wayland & drm platforms which are used by weston. Select EGL platform for weston by setting environment variable: export EGL_PLATFORM=wayland Modifications to mesa.spec: Add platforms wayland and drm which is needed by weston Enable gbm and pack it into RPM package Modifications to egl_dri2.h Since tizen, drm and wayland are all supported now, remove the duplicate definition of "color_buffers" and "back" for tizen to avoid from building error. Merged commit: commit 7c8922c1ead5875fda90106793c2fcfab2feb9f3 Author: Xiaowei Guan - fix weston build error and app launch error commit 6e7ce80fc524b78980d702549cf5bbc3a641e6ae Author: Xiaowei Guan - add wayland-egl code for platform_wayland commit 5cd0256faa43e376dcd5b5f2c2edd2515aff9c04 Author: Zhaowei Yuan - EGL: Add support for weston Change-Id: I58272083b7d110d55800d8b9ad7e7c4f0a6f6077 Signed-off-by: Zhaowei Yuan --- diff --git a/packaging/mesa.spec b/packaging/mesa.spec index eff7a36..d5a9861 100644 --- a/packaging/mesa.spec +++ b/packaging/mesa.spec @@ -66,7 +66,7 @@ meson --prefix %{_prefix} build/ \ -Dglx=disabled \ -Ddri3=false \ -Dgbm=true \ - -Dplatforms="tizen" \ + -Dplatforms="tizen,wayland,drm" \ %ifarch %ix86 x86_64 -Dgallium-drivers="i915,swrast" \ -Ddri-drivers="" \ @@ -96,4 +96,5 @@ cp 99-GPU-Acceleration.rules %{buildroot}/etc/udev/rules.d %{_libdir}/libglapi* %{_libdir}/driver/* %{_libdir}/dri/* +%{_libdir}/libgbm* /etc/udev/rules.d/99-GPU-Acceleration.rules diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index cdbdd67..7eea735 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -371,19 +371,10 @@ struct dri2_egl_surface __DRIimage *dri_image_back; __DRIimage *dri_image_front; - /* Used to record all the tbm_surface created by tpl_surface and their ages. - * Usually Tizen uses at most triple buffers in tpl_surface (tbm_surface_queue) - * so hardcode the number of color_buffers to 3. - */ - struct { - tbm_surface_h tbm_surface; - int age; - } color_buffers[3], *back; - int buffer_count; #endif -#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM) +#if defined(HAVE_WAYLAND_PLATFORM) || defined(HAVE_DRM_PLATFORM) || defined(HAVE_TIZEN_PLATFORM) struct { #ifdef HAVE_WAYLAND_PLATFORM struct wl_buffer *wl_buffer; @@ -400,6 +391,13 @@ struct dri2_egl_surface #endif bool locked; int age; +#ifdef HAVE_TIZEN_PLATFORM + /* Used to record all the tbm_surface created by tpl_surface and their ages. + * Usually Tizen uses at most triple buffers in tpl_surface (tbm_surface_queue) + * so hardcode the number of color_buffers to 3. + */ + tbm_surface_h tbm_surface; +#endif } color_buffers[4], *back, *current; #endif diff --git a/src/egl/meson.build b/src/egl/meson.build index 5f8f008..94844ec 100644 --- a/src/egl/meson.build +++ b/src/egl/meson.build @@ -125,6 +125,7 @@ if with_dri2 wayland_drm_client_protocol_h, ] incs_for_egl += [include_directories('wayland/wayland-drm')] + incs_for_egl += [include_directories('wayland/wayland-egl')] endif if with_platform_tizen files_egl += files('drivers/dri2/platform_tizen.c') 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 0000000..63545fe --- /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 + +#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 0000000..0c5fd09 --- /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 ) < + * Benjamin Franzke + */ + +#include + +#include +#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 0000000..8a40cfa --- /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}