From 890a75ab06d05522f68779419e4e982d6565b0d0 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 20 Mar 2012 13:21:18 +0000 Subject: [PATCH] Create standalone public wayland client/server headers Because the wayland-client-protocol.h header defines symbols that collide with the wayland-server-protocol.h header we allow applications to explicitly ensure that they are only including one at a time by exposing corresponding and headers. This also adds a missing guard to cogl-texture-2d.h that it isn't included directly. Reviewed-by: Neil Roberts --- cogl/Makefile.am | 7 +++- cogl/cogl-framebuffer.h | 4 --- cogl/cogl-texture-2d.c | 2 +- cogl/cogl-texture-2d.h | 39 +++------------------ cogl/cogl-wayland-client.h | 32 +++++++++++++++++ cogl/cogl-wayland-server.h | 70 ++++++++++++++++++++++++++++++++++++++ cogl/cogl.h | 3 -- examples/cogland.c | 1 + 8 files changed, 114 insertions(+), 44 deletions(-) create mode 100644 cogl/cogl-wayland-client.h create mode 100644 cogl/cogl-wayland-server.h diff --git a/cogl/Makefile.am b/cogl/Makefile.am index 853e561e8..538fbf397 100644 --- a/cogl/Makefile.am +++ b/cogl/Makefile.am @@ -395,9 +395,14 @@ cogl_sources_c += \ $(srcdir)/winsys/cogl-winsys-wgl.c \ $(srcdir)/winsys/cogl-winsys-wgl-feature-functions.h endif +if SUPPORT_WAYLAND_EGL_SERVER +cogl_experimental_h += \ + $(srcdir)/cogl-wayland-server.h +endif if SUPPORT_EGL_PLATFORM_WAYLAND cogl_experimental_h += \ - $(srcdir)/cogl-wayland-renderer.h + $(srcdir)/cogl-wayland-renderer.h \ + $(srcdir)/cogl-wayland-client.h cogl_sources_c += \ $(srcdir)/winsys/cogl-winsys-egl-wayland.c \ $(srcdir)/winsys/cogl-winsys-egl-wayland-private.h diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h index 0e688fa23..07886db56 100644 --- a/cogl/cogl-framebuffer.h +++ b/cogl/cogl-framebuffer.h @@ -34,10 +34,6 @@ #include #endif /* COGL_HAS_WIN32_SUPPORT */ -#if defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT) -#include -#endif /* COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT */ - #ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API #include #else diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c index 93bb07ce8..dad1eaca7 100644 --- a/cogl/cogl-texture-2d.c +++ b/cogl/cogl-texture-2d.c @@ -46,7 +46,7 @@ #include #ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT -#include +#include "cogl-wayland-server.h" #endif static void _cogl_texture_2d_free (CoglTexture2D *tex_2d); diff --git a/cogl/cogl-texture-2d.h b/cogl/cogl-texture-2d.h index 8e2e7109f..f191924e8 100644 --- a/cogl/cogl-texture-2d.h +++ b/cogl/cogl-texture-2d.h @@ -24,15 +24,15 @@ * Robert Bragg */ +#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION) +#error "Only can be included directly." +#endif + #ifndef __COGL_TEXURE_2D_H #define __COGL_TEXURE_2D_H #include "cogl-context.h" -#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT -#include -#endif - #include G_BEGIN_DECLS @@ -185,37 +185,6 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx, CoglPixelFormat format, GError **error); -#ifdef COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT -#define cogl_wayland_texture_2d_new_from_buffer \ - cogl_wayland_texture_2d_new_from_buffer_EXP -/** - * cogl_wayland_texture_2d_new_from_buffer: - * @ctx: A #CoglContext - * @buffer: A Wayland buffer - * @error: A #GError for exceptions - * - * Uploads the given Wayland @buffer to a #CoglTexture2D. - * - * The results are undefined for passing an invalid @buffer - * pointer - * It is undefined if future updates to @buffer outside the - * control of Cogl will affect the allocated #CoglTexture2D. In some - * cases the contents of the buffer are copied (such as shm buffers), - * and in other cases the underlying storage is re-used directly (such - * as drm buffers) - * - * Returns: A newly allocated #CoglTexture2D, or if Cogl could not - * validate the @buffer in some way (perhaps because of - * an unsupported format) it will return %NULL and set - * @error. - * Since: 2.0 - */ -CoglTexture2D * -cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx, - struct wl_buffer *buffer, - GError **error); -#endif /* COGL_HAS_WAYLAND_EGL_SERVER_SUPPORT */ - G_END_DECLS #endif /* __COGL_TEXURE_2D_H */ diff --git a/cogl/cogl-wayland-client.h b/cogl/cogl-wayland-client.h new file mode 100644 index 000000000..3f290dc7d --- /dev/null +++ b/cogl/cogl-wayland-client.h @@ -0,0 +1,32 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2012 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#ifndef __COGL_WAYLAND_CLIENT_H +#define __COGL_WAYLAND_CLIENT_H + +#include + +#define __COGL_H_INSIDE__ +#include + +#endif /* __COGL_WAYLAND_CLIENT_H */ diff --git a/cogl/cogl-wayland-server.h b/cogl/cogl-wayland-server.h new file mode 100644 index 000000000..9c2cb46cc --- /dev/null +++ b/cogl/cogl-wayland-server.h @@ -0,0 +1,70 @@ +/* + * Cogl + * + * An object oriented GL/GLES Abstraction/Utility Layer + * + * Copyright (C) 2012 Intel Corporation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#ifndef __COGL_WAYLAND_SERVER_H +#define __COGL_WAYLAND_SERVER_H + +#include + +#include + +#define __COGL_H_INSIDE__ +#include +#include + +G_BEGIN_DECLS + +#define cogl_wayland_texture_2d_new_from_buffer \ + cogl_wayland_texture_2d_new_from_buffer_EXP +/** + * cogl_wayland_texture_2d_new_from_buffer: + * @ctx: A #CoglContext + * @buffer: A Wayland buffer + * @error: A #GError for exceptions + * + * Uploads the given Wayland @buffer to a #CoglTexture2D. + * + * The results are undefined for passing an invalid @buffer + * pointer + * It is undefined if future updates to @buffer outside the + * control of Cogl will affect the allocated #CoglTexture2D. In some + * cases the contents of the buffer are copied (such as shm buffers), + * and in other cases the underlying storage is re-used directly (such + * as drm buffers) + * + * Returns: A newly allocated #CoglTexture2D, or if Cogl could not + * validate the @buffer in some way (perhaps because of + * an unsupported format) it will return %NULL and set + * @error. + * + * Since: 1.10 + * Stability: unstable + */ +CoglTexture2D * +cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx, + struct wl_buffer *buffer, + GError **error); + +G_END_DECLS + +#endif /* __COGL_WAYLAND_SERVER_H */ diff --git a/cogl/cogl.h b/cogl/cogl.h index d2e0bc060..b27b75989 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -105,9 +105,6 @@ #if defined (COGL_HAS_EGL_PLATFORM_KMS_SUPPORT) #include #endif -#if defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT) -#include -#endif #if COGL_HAS_WIN32_SUPPORT #include #endif diff --git a/examples/cogland.c b/examples/cogland.c index 766657ebd..6b791600c 100644 --- a/examples/cogland.c +++ b/examples/cogland.c @@ -1,4 +1,5 @@ #include +#include #include #include #include