Commit 549a5ea7 authored by Emil Velikov's avatar Emil Velikov Committed by Daniel Stone

wayland-egl: import libwayland-egl.so frontend library from Mesa

Currently the client-facing libwayland-egl API is defined by a header
file shipped by Wayland, but the implementation is left to each vendor.

This can cause collisions when multiple implementations are installed on
the same system. Importing the implementation into Wayland with a stable
and versioned driver-facing ABI allows multiple drivers to coexist on
the same system.

Pull the sample implementation from Mesa commit 677edff5cfd
("wayland-egl: rework and simplify wl_egl_window initialization")
It has been used by the Mesa open source drivers, NVIDIA and others[1].

v2: Reword commit message, rebase on top of newer Mesa.

[1] https://github.com/thayama/wayland-egl

Cc: Miguel A. Vico <mvicomoya@nvidia.com>
Cc: James Jones <jajones@nvidia.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: duncan-roe <duncan_roe@optusnet.com.au>
Cc: Takanari Hayama <taki@igel.co.jp>
Suggested-by: Daniel Stone's avatarDaniel Stone <daniels@collabora.com>
Signed-off-by: default avatarEmil Velikov <emil.velikov@collabora.com>
Reviewed-by: Miguel A Vico Moya's avatarMiguel A Vico Moya <mvicomoya@nvidia.com>
Reviewed-by: default avatarArnaud Vrac <avrac@freebox.fr>
parent 0fa3474b
This diff is collapsed.
/*
* 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:
* Benjamin Franzke <benjaminfranzke@googlemail.com>
*/
#ifndef _WAYLAND_EGL_PRIV_H
#define _WAYLAND_EGL_PRIV_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#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 *private;
void (*resize_callback)(struct wl_egl_window *, void *);
void (*destroy_window_callback)(void *);
struct wl_surface *surface;
};
#ifdef __cplusplus
}
#endif
#endif
#!/bin/sh
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"
/*
* 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 <string.h>
#include "wayland-egl.h"
#include "wayland-egl-backend.h"
/* GCC visibility */
#if defined(__GNUC__)
#define WL_EGL_EXPORT __attribute__ ((visibility("default")))
#else
#define WL_EGL_EXPORT
#endif
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->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->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;
}
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}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment