From b89af8efa3931bb0cb5a7c5c6a01823ab5d6be78 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 10 Jan 2012 22:39:53 +0000 Subject: [PATCH] wayland-surface: Add cogl-texture property This adds a "cogl-texture" gobject property so that a compositor may listen for notifications of changes to the texture used to paint. Reviewed-by: Neil Roberts Reviewed-by: Emmanuele Bassi --- clutter/wayland/clutter-wayland-surface.c | 36 +++++++++++++++++++++++++------ clutter/wayland/clutter-wayland-surface.h | 1 + 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/clutter/wayland/clutter-wayland-surface.c b/clutter/wayland/clutter-wayland-surface.c index 3f1c28e..7ba809d 100644 --- a/clutter/wayland/clutter-wayland-surface.c +++ b/clutter/wayland/clutter-wayland-surface.c @@ -55,9 +55,13 @@ enum { PROP_SURFACE = 1, PROP_SURFACE_WIDTH, - PROP_SURFACE_HEIGHT + PROP_SURFACE_HEIGHT, + PROP_COGL_TEXTURE, + PROP_LAST }; +static GParamSpec *obj_props[PROP_LAST]; + #if 0 enum { @@ -204,12 +208,12 @@ set_size (ClutterWaylandSurface *self, if (priv->width != width) { priv->width = width; - g_object_notify (G_OBJECT (self), "surface-width"); + g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SURFACE_WIDTH]); } if (priv->height != height) { priv->height = height; - g_object_notify (G_OBJECT (self), "surface-height"); + g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SURFACE_HEIGHT]); } clutter_actor_set_size (CLUTTER_ACTOR (self), priv->width, priv->height); @@ -249,7 +253,7 @@ clutter_wayland_surface_set_surface (ClutterWaylandSurface *self, /* XXX: should we freeze/thaw notifications? */ - g_object_notify (G_OBJECT (self), "surface"); + g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_SURFACE]); /* We have to wait until the next attach event to find out the surface * geometry... */ @@ -417,7 +421,7 @@ clutter_wayland_surface_class_init (ClutterWaylandSurfaceClass *klass) P_("The underlying wayland surface"), CLUTTER_PARAM_READWRITE| G_PARAM_CONSTRUCT_ONLY); - + obj_props[PROP_SURFACE] = pspec; g_object_class_install_property (object_class, PROP_SURFACE, pspec); pspec = g_param_spec_uint ("surface-width", @@ -426,7 +430,7 @@ clutter_wayland_surface_class_init (ClutterWaylandSurfaceClass *klass) 0, G_MAXUINT, 0, G_PARAM_READABLE); - + obj_props[PROP_SURFACE_WIDTH] = pspec; g_object_class_install_property (object_class, PROP_SURFACE_WIDTH, pspec); pspec = g_param_spec_uint ("surface-height", @@ -435,8 +439,16 @@ clutter_wayland_surface_class_init (ClutterWaylandSurfaceClass *klass) 0, G_MAXUINT, 0, G_PARAM_READABLE); - + obj_props[PROP_SURFACE_HEIGHT] = pspec; g_object_class_install_property (object_class, PROP_SURFACE_HEIGHT, pspec); + + pspec = g_param_spec_boxed ("cogl-texture", + P_("Cogl Texture"), + P_("The underlying Cogl texture handle used to draw this actor"), + COGL_TYPE_HANDLE, + CLUTTER_PARAM_READWRITE); + obj_props[PROP_COGL_TEXTURE] = pspec; + g_object_class_install_property (object_class, PROP_COGL_TEXTURE, pspec); } /** @@ -497,6 +509,8 @@ clutter_wayland_surface_attach_buffer (ClutterWaylandSurface *self, clutter_actor_queue_redraw (CLUTTER_ACTOR (self)); + g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_COGL_TEXTURE]); + if (!priv->buffer) return FALSE; @@ -576,3 +590,11 @@ clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self, clutter_wayland_surface_queue_damage_redraw (self, x, y, width, height); } + +CoglTexture * +clutter_wayland_surface_get_cogl_texture (ClutterWaylandSurface *self) +{ + g_return_val_if_fail (CLUTTER_WAYLAND_IS_SURFACE (self), NULL); + + return COGL_TEXTURE (self->priv->buffer); +} diff --git a/clutter/wayland/clutter-wayland-surface.h b/clutter/wayland/clutter-wayland-surface.h index 3786b54..54e4572 100644 --- a/clutter/wayland/clutter-wayland-surface.h +++ b/clutter/wayland/clutter-wayland-surface.h @@ -91,6 +91,7 @@ void clutter_wayland_surface_damage_buffer (ClutterWaylandSurface * gint32 y, gint32 width, gint32 height); +CoglTexture *clutter_wayland_surface_get_cogl_texture (ClutterWaylandSurface *self); G_END_DECLS -- 2.7.4