diff options
author | Robert Bragg <robert@linux.intel.com> | 2011-05-13 16:54:11 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2011-12-08 16:13:37 +0000 |
commit | 16ed7677e00fda9e9ef4e85ef7032a367e273e0c (patch) | |
tree | 494c2e64e6c5c5b099fb4e085dc10433a64debb0 | |
parent | 07c6f96cb43b1e0c788e50323f1184bd2906e3f7 (diff) | |
download | clutter-16ed7677e00fda9e9ef4e85ef7032a367e273e0c.tar.gz |
Adds wayland-surface actor for wayland compositors
This adds a --enable-wayland-compositor configure option which will add
support for a ClutterWaylandSurface actor which can be used to aid in
writing Wayland compositors using Clutter by providing a ClutterActor to
represent Wayland client surfaces.
Notably this configure option isn't tied into any particular backend
since conceptually the compositor support can be used in conjunction
with any clutter backend that has corresponding Cogl support.
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
-rw-r--r-- | clutter/Makefile.am | 8 | ||||
-rw-r--r-- | clutter/clutter-backend.c | 41 | ||||
-rw-r--r-- | clutter/wayland/clutter-wayland-compositor.h | 43 | ||||
-rw-r--r-- | clutter/wayland/clutter-wayland-surface.c | 565 | ||||
-rw-r--r-- | clutter/wayland/clutter-wayland-surface.h | 94 | ||||
-rw-r--r-- | configure.ac | 28 | ||||
-rw-r--r-- | doc/reference/clutter/clutter-sections.txt | 15 |
7 files changed, 792 insertions, 2 deletions
diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 2d9137cfd..115ee61cb 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -599,6 +599,14 @@ backend_source_c += \ $(srcdir)/wayland/clutter-device-manager-wayland.c endif # SUPPORT_WAYLAND +if SUPPORT_WAYLAND_COMPOSITOR +backend_source_h += \ + $(srcdir)/wayland/clutter-wayland-compositor.h \ + $(srcdir)/wayland/clutter-wayland-surface.h +backend_source_c += \ + $(srcdir)/wayland/clutter-wayland-surface.c +endif + if SUPPORT_EGL backend_source_h += $(egl_source_h) backend_source_c += $(egl_source_c) diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index 06f4125c7..115d29b20 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -78,6 +78,10 @@ #include "wayland/clutter-device-manager-wayland.h" #endif +#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR +#include <wayland-server.h> +#endif + G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT); #define DEFAULT_FONT_NAME "Sans 10" @@ -108,6 +112,13 @@ enum static guint backend_signals[LAST_SIGNAL] = { 0, }; +/* Global for being able to specify a compositor side wayland display + * pointer before clutter initialization */ +#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR +static struct wl_display *_wayland_compositor_display; +#endif + + static void clutter_backend_dispose (GObject *gobject) { @@ -299,6 +310,11 @@ clutter_backend_real_create_context (ClutterBackend *backend, if (backend->cogl_display == NULL) goto error; +#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR + cogl_wayland_display_set_compositor_display (backend->cogl_display, + _wayland_compositor_display); +#endif + CLUTTER_NOTE (BACKEND, "Setting up the display"); if (!cogl_display_setup (backend->cogl_display, &internal_error)) goto error; @@ -1307,3 +1323,28 @@ clutter_backend_get_cogl_context (ClutterBackend *backend) { return backend->cogl_context; } + +#ifdef HAVE_CLUTTER_WAYLAND_COMPOSITOR +/** + * clutter_wayland_set_compositor_display: + * @display: A compositor side struct wl_display pointer + * + * This informs Clutter of your compositor side Wayland display + * object. This must be called before calling clutter_init(). + * + * Since: 1.8 + * Stability: unstable + */ +void +clutter_wayland_set_compositor_display (struct wl_display *display) +{ + if (_clutter_context_is_initialized ()) + { + g_warning ("%s() can only be used before calling clutter_init()", + G_STRFUNC); + return; + } + + _wayland_compositor_display = display; +} +#endif diff --git a/clutter/wayland/clutter-wayland-compositor.h b/clutter/wayland/clutter-wayland-compositor.h new file mode 100644 index 000000000..f7fa96e76 --- /dev/null +++ b/clutter/wayland/clutter-wayland-compositor.h @@ -0,0 +1,43 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2011 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 <http://www.gnu.org/licenses/>. + * + * Authors: + * Robert Bragg <robert@linux.intel.com> + */ + +/** + * SECTION:clutter-wayland-compositor + * @short_description: Wayland compositor specific APIs + * + * Clutter provides some Wayland specific APIs to aid in writing + * Clutter based compositors. + * + * The Clutter Wayland compositor API is available since Clutter 1.8 + */ + +#include <wayland-server.h> +#include <clutter/wayland/clutter-wayland-surface.h> + +G_BEGIN_DECLS + +void +clutter_wayland_set_compositor_display (struct wl_display *display); + +G_END_DECLS diff --git a/clutter/wayland/clutter-wayland-surface.c b/clutter/wayland/clutter-wayland-surface.c new file mode 100644 index 000000000..84c8dc65b --- /dev/null +++ b/clutter/wayland/clutter-wayland-surface.c @@ -0,0 +1,565 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2011 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 + * <http://www.gnu.org/licenses/>. + * + * Authors: + * Robert Bragg <robert@linux.intel.com> + */ + +/** + * SECTION:clutter-wayland-surface + * @Title: ClutterWaylandSurface + * @short_description: An actor which displays the content of a client surface + * + * #ClutterWaylandSurface is an actor for displaying the contents of a client + * surface. It is intended to support developers implementing Clutter based + * wayland compositors. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#define CLUTTER_ENABLE_EXPERIMENTAL_API + +#include "clutter-wayland-surface.h" + +#include "clutter-actor-private.h" +#include "clutter-marshal.h" +#include "clutter-paint-volume-private.h" +#include "clutter-private.h" +#include "clutter-backend.h" + +#include <cogl/cogl.h> + +#include <wayland-server.h> + +enum +{ + PROP_SURFACE = 1, + PROP_WIDTH, + PROP_HEIGHT +}; + +#if 0 +enum +{ + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0, }; +#endif + +struct _ClutterWaylandSurfacePrivate +{ + struct wl_surface *surface; + CoglTexture2D *buffer; + int width, height; + CoglPipeline *pipeline; + GArray *damage; +}; + +G_DEFINE_TYPE (ClutterWaylandSurface, + clutter_wayland_surface, + CLUTTER_TYPE_ACTOR); + +static gboolean +clutter_wayland_surface_get_paint_volume (ClutterActor *self, + ClutterPaintVolume *volume) +{ + return clutter_paint_volume_set_from_allocation (volume, self); +} + +static void +clutter_wayland_surface_queue_damage_redraw (ClutterWaylandSurface *texture, + gint x, + gint y, + gint width, + gint height) +{ + ClutterWaylandSurfacePrivate *priv = texture->priv; + ClutterActor *self = CLUTTER_ACTOR (texture); + ClutterActorBox allocation; + float scale_x; + float scale_y; + ClutterVertex origin; + ClutterPaintVolume clip; + + /* NB: clutter_actor_queue_clipped_redraw expects a box in the actor's + * coordinate space so we need to convert from surface coordinates to + * actor coordinates... + */ + + /* Calling clutter_actor_get_allocation_box() is enormously expensive + * if the actor has an out-of-date allocation, since it triggers + * a full redraw. clutter_actor_queue_clipped_redraw() would redraw + * the whole stage anyways in that case, so just go ahead and do + * it here. + */ + if (!clutter_actor_has_allocation (self)) + { + clutter_actor_queue_redraw (self); + return; + } + + if (priv->width == 0 || priv->height == 0) + return; + + clutter_actor_get_allocation_box (self, &allocation); + + scale_x = (allocation.x2 - allocation.x1) / priv->width; + scale_y = (allocation.y2 - allocation.y1) / priv->height; + + _clutter_paint_volume_init_static (&clip, self); + + origin.x = x * scale_x; + origin.y = y * scale_y; + origin.z = 0; + clutter_paint_volume_set_origin (&clip, &origin); + clutter_paint_volume_set_width (&clip, width * scale_x); + clutter_paint_volume_set_height (&clip, height * scale_y); + + _clutter_actor_queue_redraw_with_clip (self, 0, &clip); + clutter_paint_volume_free (&clip); +} + +static void +free_pipeline (ClutterWaylandSurface *self) +{ + ClutterWaylandSurfacePrivate *priv = self->priv; + + if (priv->pipeline) + { + cogl_object_unref (priv->pipeline); + priv->pipeline = NULL; + } +} + +static void +opacity_change_cb (ClutterWaylandSurface *self) +{ + free_pipeline (self); +} + +static void +clutter_wayland_surface_init (ClutterWaylandSurface *self) +{ + ClutterWaylandSurfacePrivate *priv = + G_TYPE_INSTANCE_GET_PRIVATE (self, + CLUTTER_WAYLAND_TYPE_SURFACE, + ClutterWaylandSurfacePrivate); + + priv->surface = NULL; + priv->width = 0; + priv->height = 0; + priv->damage = g_array_new (FALSE, FALSE, sizeof (int)); + + self->priv = priv; + + g_signal_connect (self, "notify::opacity", G_CALLBACK (opacity_change_cb), NULL); +} + +static void +clutter_wayland_surface_dispose (GObject *object) +{ + ClutterWaylandSurface *self = CLUTTER_WAYLAND_SURFACE (object); + ClutterWaylandSurfacePrivate *priv = self->priv; + + if (priv->damage) + { + g_array_free (priv->damage, TRUE); + priv->damage = NULL; + } + + G_OBJECT_CLASS (clutter_wayland_surface_parent_class)->dispose (object); +} + +static void +set_size (ClutterWaylandSurface *self, + int width, + int height) +{ + ClutterWaylandSurfacePrivate *priv = self->priv; + + if (priv->width != width) + { + priv->width = width; + g_object_notify (G_OBJECT (self), "width"); + } + if (priv->height != height) + { + priv->height = height; + g_object_notify (G_OBJECT (self), "height"); + } +} + +static void +clutter_wayland_surface_set_surface (ClutterWaylandSurface *self, + struct wl_surface *surface) +{ + ClutterWaylandSurfacePrivate *priv; + + g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self)); + + priv = self->priv; + + g_return_if_fail (priv->surface == NULL); + priv->surface = surface; + + /* XXX: should we freeze/thaw notifications? */ + + g_object_notify (G_OBJECT (self), "surface"); + + /* We have to wait until the next attach event to find out the surface + * geometry... */ + set_size (self, 0, 0); +} + +static void +clutter_wayland_surface_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + ClutterWaylandSurface *self = CLUTTER_WAYLAND_SURFACE (object); + + switch (prop_id) + { + case PROP_SURFACE: + clutter_wayland_surface_set_surface (self, g_value_get_pointer (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +clutter_wayland_surface_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + ClutterWaylandSurface *self = CLUTTER_WAYLAND_SURFACE (object); + ClutterWaylandSurfacePrivate *priv = self->priv; + + switch (prop_id) + { + case PROP_SURFACE: + g_value_set_pointer (value, priv->surface); + break; + case PROP_WIDTH: + g_value_set_uint (value, priv->width); + break; + case PROP_HEIGHT: + g_value_set_uint (value, priv->height); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +clutter_wayland_surface_paint (ClutterActor *self) +{ + ClutterWaylandSurfacePrivate *priv; + ClutterActorBox box; + + g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self)); + + priv = CLUTTER_WAYLAND_SURFACE (self)->priv; + + if (G_UNLIKELY (priv->pipeline == NULL)) + { + guint8 paint_opacity = clutter_actor_get_paint_opacity (self); + + priv->pipeline = cogl_pipeline_new (); + cogl_pipeline_set_color4ub (priv->pipeline, + paint_opacity, + paint_opacity, + paint_opacity, + paint_opacity); + cogl_pipeline_set_layer_texture (priv->pipeline, 0, + COGL_TEXTURE (priv->buffer)); + } + + cogl_set_source (priv->pipeline); + clutter_actor_get_allocation_box (self, &box); + cogl_rectangle (0, 0, box.x2 - box.x1, box.y2 - box.y1); +} + +static void +clutter_wayland_surface_pick (ClutterActor *self, + const ClutterColor *color) +{ + ClutterActorBox box; + + cogl_set_source_color4ub (color->red, color->green, color->blue, + color->alpha); + clutter_actor_get_allocation_box (self, &box); + cogl_rectangle (0, 0, box.x2 - box.x1, box.y2 - box.y1); +} + +static void +clutter_wayland_surface_get_preferred_width (ClutterActor *self, + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) +{ + ClutterWaylandSurfacePrivate *priv; + + g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self)); + + priv = CLUTTER_WAYLAND_SURFACE (self)->priv; + + if (min_width_p) + *min_width_p = 0; + + if (natural_width_p) + *natural_width_p = priv->width; +} + +static void +clutter_wayland_surface_get_preferred_height (ClutterActor *self, + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) +{ + ClutterWaylandSurfacePrivate *priv; + + g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self)); + + priv = CLUTTER_WAYLAND_SURFACE (self)->priv; + + if (min_height_p) + *min_height_p = 0; + + if (natural_height_p) + *natural_height_p = priv->height; +} + +static gboolean +clutter_wayland_surface_has_overlaps (ClutterActor *self) +{ + /* Rectangles never need an offscreen redirect because there are + never any overlapping primitives */ + return FALSE; +} + +static void +clutter_wayland_surface_class_init (ClutterWaylandSurfaceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); + GParamSpec *pspec; + + g_type_class_add_private (klass, sizeof (ClutterWaylandSurfacePrivate)); + + actor_class->get_paint_volume = clutter_wayland_surface_get_paint_volume; + actor_class->paint = clutter_wayland_surface_paint; + actor_class->pick = clutter_wayland_surface_pick; + actor_class->get_preferred_width = + clutter_wayland_surface_get_preferred_width; + actor_class->get_preferred_height = + clutter_wayland_surface_get_preferred_height; + actor_class->has_overlaps = clutter_wayland_surface_has_overlaps; + + object_class->dispose = clutter_wayland_surface_dispose; + object_class->set_property = clutter_wayland_surface_set_property; + object_class->get_property = clutter_wayland_surface_get_property; + + pspec = g_param_spec_pointer ("surface", + P_("Surface"), + P_("The underlying wayland surface"), + CLUTTER_PARAM_READWRITE| + G_PARAM_CONSTRUCT_ONLY); + + g_object_class_install_property (object_class, PROP_SURFACE, pspec); + + pspec = g_param_spec_uint ("width", + P_("Surface width"), + P_("The width of the underlying wayland surface"), + 0, G_MAXUINT, + 0, + G_PARAM_READABLE); + + g_object_class_install_property (object_class, PROP_WIDTH, pspec); + + pspec = g_param_spec_uint ("height", + P_("Surface height"), + P_("The height of the underlying wayland surface"), + 0, G_MAXUINT, + 0, + G_PARAM_READABLE); + + g_object_class_install_property (object_class, PROP_HEIGHT, pspec); +} + +/** + * clutter_wayland_surface_new: + * @surface: the Wayland surface this actor should represent + * + * Creates a new #ClutterWaylandSurface for @surface + * + * Return value: A new #ClutterWaylandSurface representing @surface + * + * Since: 1.8 + * Stability: unstable + */ +ClutterActor * +clutter_wayland_surface_new (struct wl_surface *surface) +{ + ClutterActor *actor; + + actor = g_object_new (CLUTTER_WAYLAND_TYPE_SURFACE, + "surface", surface, + NULL); + + return actor; +} + +static void +free_surface_buffers (ClutterWaylandSurface *self) +{ + ClutterWaylandSurfacePrivate *priv = self->priv; + + if (priv->buffer) + { + cogl_object_unref (priv->buffer); + priv->buffer = NULL; + free_pipeline (self); + } +} + +/** + * clutter_wayland_surface_attach_buffer: + * @self: A #ClutterWaylandSurface actor + * @buffer: A compositor side struct wl_buffer pointer + * @error: A #GError + * + * This associates a client's buffer with the #ClutterWaylandSurface + * actor @self. This will automatically result in @self being re-drawn + * with the new buffer contents. + * + * Since: 1.8 + * Stability: unstable + */ +gboolean +clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, + struct wl_buffer *buffer, + GError **error) +{ + ClutterWaylandSurfacePrivate *priv; + ClutterBackend *backend = clutter_get_default_backend (); + CoglContext *context = clutter_backend_get_cogl_context (backend); + + g_return_val_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self), TRUE); + + priv = self->priv; + + free_surface_buffers (self); + + set_size (self, buffer->width, buffer->height); + + priv->buffer = + cogl_wayland_texture_2d_new_from_buffer (context, buffer, error); + + clutter_actor_queue_redraw (CLUTTER_ACTOR (self)); + + if (!priv->buffer) + return FALSE; + + return TRUE; +} + +/** + * clutter_wayland_surface_damage_buffer: + * @self: A #ClutterWaylandSurface actor + * @buffer: A compositor side struct wl_buffer pointer + * @x: The x coordinate of the damaged rectangle + * @y: The y coordinate of the damaged rectangle + * @width: The width of the damaged rectangle + * @height: The height of the damaged rectangle + * + * This marks a region of the given @buffer has having been changed by + * the client. This will automatically result in the corresponding damaged + * region of the actor @self being redrawn. + * + * If multiple regions are changed then this should be called multiple + * times with different damage rectangles. + * + * Since: 1.8 + * Stability: unstable + */ +void +clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self, + struct wl_buffer *buffer, + gint32 x, + gint32 y, + gint32 width, + gint32 height) +{ + ClutterWaylandSurfacePrivate *priv; + + g_return_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self)); + + priv = self->priv; + + if (priv->buffer && wl_buffer_is_shm (buffer)) + { + CoglPixelFormat format; + + switch (wl_shm_buffer_get_format (buffer)) + { +#if G_BYTE_ORDER == G_BIG_ENDIAN + case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32: + format = COGL_PIXEL_FORMAT_ARGB_8888_PRE; + break; + case WL_SHM_FORMAT_ARGB32: + case WL_SHM_FORMAT_XRGB32: + format = COGL_PIXEL_FORMAT_ARGB_8888; + break; +#elif G_BYTE_ORDER == G_LITTLE_ENDIAN + case WL_SHM_FORMAT_PREMULTIPLIED_ARGB32: + format = COGL_PIXEL_FORMAT_BGRA_8888_PRE; + break; + case WL_SHM_FORMAT_ARGB32: + case WL_SHM_FORMAT_XRGB32: + format = COGL_PIXEL_FORMAT_BGRA_8888; + break; +#endif + default: + g_warn_if_reached (); + format = COGL_PIXEL_FORMAT_ARGB_8888; + } + + cogl_texture_set_region (COGL_TEXTURE (priv->buffer), + x, y, + x, y, + width, height, + width, height, + format, + wl_shm_buffer_get_stride (buffer), + wl_shm_buffer_get_data (buffer)); + } + + clutter_wayland_surface_queue_damage_redraw (self, x, y, width, height); +} diff --git a/clutter/wayland/clutter-wayland-surface.h b/clutter/wayland/clutter-wayland-surface.h new file mode 100644 index 000000000..187ca80dd --- /dev/null +++ b/clutter/wayland/clutter-wayland-surface.h @@ -0,0 +1,94 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2011 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 + * <http://www.gnu.org/licenses/>. + * + * Authors: + * Robert Bragg <robert@linux.intel.com> + * + */ + +#ifndef __CLUTTER_WAYLAND_SURFACE_H__ +#define __CLUTTER_WAYLAND_SURFACE_H__ + +#include <glib.h> +#include <glib-object.h> +#include <clutter/clutter.h> + +#include <wayland-server.h> + +G_BEGIN_DECLS + +#define CLUTTER_WAYLAND_TYPE_SURFACE (clutter_wayland_surface_get_type ()) +#define CLUTTER_WAYLAND_SURFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_WAYLAND_TYPE_SURFACE, ClutterWaylandSurface)) +#define CLUTTER_WAYLAND_SURFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_WAYLAND_TYPE_SURFACE, ClutterWaylandSurfaceClass)) +#define CLUTTER_WAYLAND_IS_SURFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_WAYLAND_TYPE_SURFACE)) +#define CLUTTER_WAYLAND_IS_SURFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_WAYLAND_TYPE_SURFACE)) +#define CLUTTER_WAYLAND_SURFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_WAYLAND_TYPE_SURFACE, ClutterWaylandSurfaceClass)) + +typedef struct _ClutterWaylandSurface ClutterWaylandSurface; +typedef struct _ClutterWaylandSurfaceClass ClutterWaylandSurfaceClass; +typedef struct _ClutterWaylandSurfacePrivate ClutterWaylandSurfacePrivate; + +/** + * ClutterWaylandSurface: + * + * The #ClutterWaylandSurface structure contains only private data + * + * Since: 1.8 + * Stability: unstable + */ +struct _ClutterWaylandSurface +{ + /*< private >*/ + ClutterActor parent; + + ClutterWaylandSurfacePrivate *priv; +}; + +/** + * ClutterWaylandSurfaceClass: + * + * The #ClutterWaylandSurfaceClass structure contains only private data + * + * Since: 0.8 + * Stability: unstable + */ +struct _ClutterWaylandSurfaceClass +{ + /*< private >*/ + ClutterActorClass parent_class; +}; + +GType clutter_wayland_surface_get_type (void) G_GNUC_CONST; + +ClutterActor *clutter_wayland_surface_new (struct wl_surface *surface); +gboolean clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, + struct wl_buffer *buffer, + GError **error); +void clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self, + struct wl_buffer *buffer, + gint32 x, + gint32 y, + gint32 width, + gint32 height); + +G_END_DECLS + +#endif diff --git a/configure.ac b/configure.ac index 9b2cc3187..fa65baabf 100644 --- a/configure.ac +++ b/configure.ac @@ -317,12 +317,34 @@ AS_IF([test "x$enable_wayland" = "xyes"], []) AC_DEFINE([HAVE_CLUTTER_WAYLAND], [1], [Have the Wayland backend]) - ], + ]) + +dnl Note this is orthogonal to the client side support and you can +dnl use the wayland compositor features with any of the clutter +dnl backends with corresponding Cogl support. +AC_ARG_ENABLE([wayland-compositor], + [AS_HELP_STRING([--enable-wayland-compositor], [Enable Wayland compositor features])], + [], + [AS_IF([test "x$SUPPORT_EGL" = "x1"], + [enable_wayland_compositor=yes], + [enable_wayland_compositor=no]) + ]) + +AS_IF([test "x$enable_wayland_compositor" = "xyes"], + [ + PKG_CHECK_EXISTS([wayland-server], + [BACKEND_PC_FILES="$BACKEND_PC_FILES wayland-server"], []) + SUPPORT_WAYLAND_COMPOSITOR=1 + AC_DEFINE([HAVE_CLUTTER_WAYLAND_COMPOSITOR], [1], [Have wayland compositor support]) + ]) +AM_CONDITIONAL(SUPPORT_WAYLAND_COMPOSITOR, [test "x$SUPPORT_WAYLAND_COMPOSITOR" = "x1"]) + +AS_IF([test "x$enable_wayland_compositor" != "xyes" -a "x$enable_wayland" != "xyes"], [ # The wayland headers introduce so much symbol shadowing that build # logs become incomprehensible with -Wshadow so we only use it for # non-wayland builds. - MAINTAINER_COMPILER_FLAGS="-Wshadow" + MAINTAINER_COMPILER_FLAGS="-Wshadow" ]) AS_IF([test "x$enable_cex100" = "xyes"], @@ -1122,6 +1144,8 @@ echo " - CEx100 backend options:" echo " libGDL include prefix: ${CLUTTER_CEX100_LIBGDL_PREFIX}" fi +echo " Wayland compositor features: ${SUPPORT_WAYLAND_COMPOSITOR}" + echo "" # General warning about experimental features diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index b965b34ba..2cf4cbc77 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1343,6 +1343,21 @@ clutter_glx_texture_pixmap_get_type </SECTION> <SECTION> +<FILE>clutter-wayland-compositor</FILE> +<TITLE>Wayland compositor specific support</TITLE> +clutter_wayland_set_compositor_display +</SECTION> + +<SECTION> +<FILE>clutter-wayland-surface</FILE> +ClutterWaylandSurface +ClutterWaylandSurfaceClass +clutter_wayland_surface_new +clutter_wayland_surface_attach_buffer +clutter_wayland_surface_damage_buffer +</SECTION> + +<SECTION> <FILE>clutter-win32</FILE> <TITLE>Win32 Specific Support</TITLE> clutter_win32_disable_event_retrieval |