[maemo-commits] [maemo-commits] r17178 - in projects/haf/trunk/clutter: clutter/x11 debian
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Jan 14 21:21:40 EET 2009
- Previous message: [maemo-commits] r17177 - projects/haf/tags/gtkfilesystemmemory
- Next message: [maemo-commits] r17179 - in projects/haf/trunk/libmatchbox2: . matchbox/comp-mgr
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: gw Date: 2009-01-14 21:21:35 +0200 (Wed, 14 Jan 2009) New Revision: 17178 Modified: projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.h projects/haf/trunk/clutter/debian/changelog Log: Added clutter_x11_texture_pixmap_add_shape for XShapeGetRectangles-style transparency Modified: projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c =================================================================== --- projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c 2009-01-14 15:21:31 UTC (rev 17177) +++ projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.c 2009-01-14 19:21:35 UTC (rev 17178) @@ -44,6 +44,7 @@ #include "clutter-x11-texture-pixmap.h" #include "clutter-x11.h" #include "clutter-backend-x11.h" +#include "clutter-debug.h" #include "cogl/cogl.h" @@ -91,6 +92,8 @@ clutter_x11_texture_pixmap_set_mapped (ClutterX11TexturePixmap *texture, gboolean mapped); static void clutter_x11_texture_pixmap_destroyed (ClutterX11TexturePixmap *texture); +static void +clutter_x11_texture_pixmap_paint (ClutterActor *self); static guint signals[LAST_SIGNAL] = { 0, }; @@ -117,6 +120,8 @@ gboolean owns_pixmap; gboolean override_redirect; gint window_x, window_y; + + GList *shapes; }; static int _damage_event_base = 0; @@ -403,6 +408,7 @@ self->priv->override_redirect = FALSE; self->priv->window_x = 0; self->priv->window_y = 0; + self->priv->shapes = 0; } static void @@ -562,6 +568,9 @@ klass->update_area = clutter_x11_texture_pixmap_update_area_real; + klass->overridden_paint = actor_class->paint; + actor_class->paint = clutter_x11_texture_pixmap_paint; + pspec = g_param_spec_uint ("pixmap", "Pixmap", "The X11 Pixmap to be bound", @@ -1342,3 +1351,100 @@ priv->automatic_updates = setting; } + +static void +clutter_x11_texture_pixmap_paint (ClutterActor *self) +{ + ClutterX11TexturePixmap *texture = CLUTTER_X11_TEXTURE_PIXMAP (self); + ClutterX11TexturePixmapPrivate *priv = texture->priv; + gint x_1, y_1, x_2, y_2; + ClutterColor col = { 0xff, 0xff, 0xff, 0xff }; + ClutterFixed t_w, t_h; + GList *shape; + CoglHandle cogl_texture; + + g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture)); + + /* If we have no shapes, just call what we had before */ + if (priv->shapes==0) + { + CLUTTER_X11_TEXTURE_PIXMAP_GET_CLASS(self)->overridden_paint(self); + return; + } + + if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR(texture))) + clutter_actor_realize (CLUTTER_ACTOR(texture)); + + CLUTTER_NOTE (PAINT, + "painting X11 texture '%s'", + clutter_actor_get_name (self) ? clutter_actor_get_name (self) + : "unknown"); + col.alpha = clutter_actor_get_paint_opacity (self); + cogl_color (&col); + + clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2); + + CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i " + "opacity: %i", + x_1, y_1, x_2, y_2, + clutter_actor_get_opacity (self)); + + t_w = CFX_ONE; + t_h = CFX_ONE; + + cogl_texture = clutter_texture_get_cogl_texture(CLUTTER_TEXTURE(self)); + + /* so now we go through our shapes and render */ + for (shape = priv->shapes; shape; shape = shape->next) + { + gint w = x_2 - x_1; + gint h = y_2 - y_1; + ClutterGeometry *geo = (ClutterGeometry*)shape->data; + cogl_texture_rectangle ( + cogl_texture, + CLUTTER_INT_TO_FIXED(w * geo->x / priv->pixmap_width), + CLUTTER_INT_TO_FIXED(h * geo->y / priv->pixmap_height), + CLUTTER_INT_TO_FIXED(w * (geo->x+geo->width) / priv->pixmap_width), + CLUTTER_INT_TO_FIXED(h * (geo->y+geo->height) / priv->pixmap_height), + t_w * geo->x / priv->pixmap_width, + t_h * geo->y / priv->pixmap_height, + t_w * (geo->x+geo->width) / priv->pixmap_width, + t_h * (geo->y+geo->height) / priv->pixmap_height); + } +} + +/* Remove all shapes and instead render this texture normally. see + * clutter_x11_texture_pixmap_add_shape */ +void clutter_x11_texture_pixmap_clear_shapes(ClutterX11TexturePixmap *texture) +{ + ClutterX11TexturePixmapPrivate *priv; + GList *it; + + g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture)); + priv = texture->priv; + + it = g_list_first(priv->shapes); + while (it) + { + g_free(it->data); + it = it->next; + } + g_list_free(priv->shapes); + priv->shapes = 0; +} + +/* Add a shape (as in XShape). When shapes are added, only these bits of + * the texture will be rendered. */ +void clutter_x11_texture_pixmap_add_shape(ClutterX11TexturePixmap *texture, + ClutterGeometry geo) +{ + ClutterX11TexturePixmapPrivate *priv; + ClutterGeometry *ageo; + + g_return_if_fail (CLUTTER_X11_IS_TEXTURE_PIXMAP (texture)); + priv = texture->priv; + + ageo = (ClutterGeometry*)g_malloc(sizeof(ClutterGeometry)); + *ageo = geo; + priv->shapes = g_list_append(priv->shapes, ageo); +} Modified: projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.h =================================================================== --- projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.h 2009-01-14 15:21:31 UTC (rev 17177) +++ projects/haf/trunk/clutter/clutter/x11/clutter-x11-texture-pixmap.h 2009-01-14 19:21:35 UTC (rev 17178) @@ -55,6 +55,7 @@ gint y, gint width, gint height); + void (*overridden_paint)(ClutterActor *actor); }; struct _ClutterX11TexturePixmap @@ -87,6 +88,9 @@ void clutter_x11_texture_pixmap_set_automatic (ClutterX11TexturePixmap *texture, gboolean setting); +void clutter_x11_texture_pixmap_clear_shapes(ClutterX11TexturePixmap *texture); +void clutter_x11_texture_pixmap_add_shape(ClutterX11TexturePixmap *texture, + ClutterGeometry geo); G_END_DECLS Modified: projects/haf/trunk/clutter/debian/changelog =================================================================== --- projects/haf/trunk/clutter/debian/changelog 2009-01-14 15:21:31 UTC (rev 17177) +++ projects/haf/trunk/clutter/debian/changelog 2009-01-14 19:21:35 UTC (rev 17178) @@ -6,8 +6,10 @@ we found it didn't help much. * Added CLUTTER_TEXTURE_FLAG_16_BIT to force 16 bit textures in set_from_rgb_data + * Added clutter_x11_texture_pixmap_add_shape to deal with transparency in + textures via XShapeGetRectangles - -- Gordon Williams <gordon.williams at collabora.co.uk> Mon, 12 Jan 2009 16:21:48 +0000 + -- Gordon Williams <gordon.williams at collabora.co.uk> Mon, 14 Jan 2009 19:21:48 +0000 clutter (0.8.2-0maemo13) unstable; urgency=low
- Previous message: [maemo-commits] r17177 - projects/haf/tags/gtkfilesystemmemory
- Next message: [maemo-commits] r17179 - in projects/haf/trunk/libmatchbox2: . matchbox/comp-mgr
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]