[mutter/wip/wayland] shaped-texture: support shaped mask + texture tower



commit f627067ff4242884510da096fcfe731c88a743df
Author: Robert Bragg <robert linux intel com>
Date:   Wed Jan 11 01:16:55 2012 +0000

    shaped-texture: support shaped mask + texture tower
    
    The initial wayland integration into meta-shaped-texture.[ch] disabled
    support for shaped windows and didn't keep the texture tower updated
    correctly, this patch addresses both of those limitations.

 src/compositor/meta-shaped-texture.c |   89 ++++++++++++++++++++++------------
 src/compositor/meta-shaped-texture.h |   10 +++-
 2 files changed, 66 insertions(+), 33 deletions(-)
---
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 4e81b7a..e79c2c5 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -38,10 +38,8 @@
 #include <string.h>
 
 static void meta_shaped_texture_dispose  (GObject    *object);
-#ifndef HAVE_WAYLAND
 static void meta_shaped_texture_notify   (GObject    *object,
 					  GParamSpec *pspec);
-#endif
 
 static void meta_shaped_texture_paint (ClutterActor       *actor);
 static void meta_shaped_texture_pick  (ClutterActor       *actor,
@@ -53,6 +51,12 @@ static void meta_shaped_texture_update_area (ClutterX11TexturePixmap *texture,
 					     int                      y,
 					     int                      width,
 					     int                      height);
+#else
+static void meta_shaped_texture_queue_damage_redraw (ClutterWaylandSurface *surface,
+                                                     int                    x,
+                                                     int                    y,
+                                                     int                    width,
+                                                     int                    height);
 #endif
 
 static void meta_shaped_texture_dirty_mask (MetaShapedTexture *stex);
@@ -95,18 +99,20 @@ meta_shaped_texture_class_init (MetaShapedTextureClass *klass)
   ClutterActorClass *actor_class = (ClutterActorClass *) klass;
 #ifndef HAVE_WAYLAND
   ClutterX11TexturePixmapClass *x11_texture_class = (ClutterX11TexturePixmapClass *) klass;
+#else
+  ClutterWaylandSurfaceClass *wayland_surface_class = (ClutterWaylandSurfaceClass *) klass;
 #endif
 
   gobject_class->dispose = meta_shaped_texture_dispose;
-#ifndef HAVE_WAYLAND
   gobject_class->notify = meta_shaped_texture_notify;
-#endif
 
   actor_class->paint = meta_shaped_texture_paint;
   actor_class->pick = meta_shaped_texture_pick;
 
 #ifndef HAVE_WAYLAND
   x11_texture_class->update_area = meta_shaped_texture_update_area;
+#else
+  wayland_surface_class->queue_damage_redraw = meta_shaped_texture_queue_damage_redraw;
 #endif
 
   g_type_class_add_private (klass, sizeof (MetaShapedTexturePrivate));
@@ -158,7 +164,6 @@ meta_shaped_texture_dispose (GObject *object)
   G_OBJECT_CLASS (meta_shaped_texture_parent_class)->dispose (object);
 }
 
-#ifndef HAVE_WAYLAND
 static void
 meta_shaped_texture_notify (GObject    *object,
 			    GParamSpec *pspec)
@@ -179,11 +184,18 @@ meta_shaped_texture_notify (GObject    *object,
       meta_shaped_texture_clear (stex);
 
       if (priv->create_mipmaps)
-	meta_texture_tower_set_base_texture (priv->paint_tower,
-					       clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex)));
+        {
+          CoglHandle texture = 
+#ifndef HAVE_WAYLAND
+            clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex));
+#else
+            clutter_wayland_surface_get_cogl_texture (
+                                              CLUTTER_WAYLAND_SURFACE (stex));
+#endif
+	  meta_texture_tower_set_base_texture (priv->paint_tower, texture);
+        }
     }
 }
-#endif
 
 static void
 meta_shaped_texture_dirty_mask (MetaShapedTexture *stex)
@@ -326,30 +338,21 @@ install_overlay_path (MetaShapedTexture *stex,
 static void
 meta_shaped_texture_ensure_mask (MetaShapedTexture *stex)
 {
-#ifdef HAVE_WAYLAND
-#warning "FIXME: support meta_shaped_texture_ensure_mask()"
-  return;
-#else
-
   MetaShapedTexturePrivate *priv = stex->priv;
   guint tex_width, tex_height;
-#ifndef HAVE_WAYLAND
   CoglHandle paint_tex;
 
+#ifndef HAVE_WAYLAND
   paint_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex));
+#else
+  paint_tex = clutter_wayland_surface_get_cogl_texture (CLUTTER_WAYLAND_SURFACE (stex));
+#endif
 
   if (paint_tex == COGL_INVALID_HANDLE)
     return;
 
   tex_width = cogl_texture_get_width (paint_tex);
   tex_height = cogl_texture_get_height (paint_tex);
-#else
-  gfloat width, height;
-  clutter_actor_get_preferred_width (CLUTTER_ACTOR (stex), -1, NULL, &width);
-  clutter_actor_get_preferred_height (CLUTTER_ACTOR (stex), -1, NULL, &height);
-  tex_width = width;
-  tex_height = height;
-#endif
 
   /* If the mask texture we have was created for a different size then
      recreate it */
@@ -444,13 +447,11 @@ meta_shaped_texture_ensure_mask (MetaShapedTexture *stex)
       priv->mask_width = tex_width;
       priv->mask_height = tex_height;
     }
-#endif /* HAVE_WAYLAND */
 }
 
 static void
 meta_shaped_texture_paint (ClutterActor *actor)
 {
-#ifndef HAVE_WAYLAND
   MetaShapedTexture *stex = (MetaShapedTexture *) actor;
   MetaShapedTexturePrivate *priv = stex->priv;
   CoglHandle paint_tex;
@@ -486,7 +487,11 @@ meta_shaped_texture_paint (ClutterActor *actor)
   if (priv->create_mipmaps)
     paint_tex = meta_texture_tower_get_paint_texture (priv->paint_tower);
   else
+#ifndef HAVE_WAYLAND
     paint_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex));
+#else
+    paint_tex = clutter_wayland_surface_get_cogl_texture (CLUTTER_WAYLAND_SURFACE (stex));
+#endif
 
   if (paint_tex == COGL_INVALID_HANDLE)
     return;
@@ -590,16 +595,12 @@ meta_shaped_texture_paint (ClutterActor *actor)
   cogl_rectangle (0, 0,
 		  alloc.x2 - alloc.x1,
 		  alloc.y2 - alloc.y1);
-#else /* HAVE_WAYLAND */
-  CLUTTER_ACTOR_CLASS (meta_shaped_texture_parent_class)->paint (actor);
-#endif /* HAVE_WAYLAND */
 }
 
 static void
 meta_shaped_texture_pick (ClutterActor       *actor,
 			  const ClutterColor *color)
 {
-#ifndef HAVE_WAYLAND
   MetaShapedTexture *stex = (MetaShapedTexture *) actor;
   MetaShapedTexturePrivate *priv = stex->priv;
 
@@ -613,7 +614,12 @@ meta_shaped_texture_pick (ClutterActor       *actor,
       ClutterActorBox alloc;
       guint tex_width, tex_height;
 
+#ifndef HAVE_WAYLAND
       paint_tex = clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex));
+#else
+      paint_tex =
+        clutter_wayland_surface_get_cogl_texture (CLUTTER_WAYLAND_SURFACE (stex));
+#endif
 
       if (paint_tex == COGL_INVALID_HANDLE)
         return;
@@ -638,9 +644,6 @@ meta_shaped_texture_pick (ClutterActor       *actor,
                                           alloc.y2 - alloc.y1,
                                           0, 0, 1, 1);
     }
-#else /* HAVE_WAYLAND */
-  CLUTTER_ACTOR_CLASS (meta_shaped_texture_parent_class)->pick (actor, color);
-#endif /* HAVE_WAYLAND */
 }
 
 #ifndef HAVE_WAYLAND
@@ -659,7 +662,25 @@ meta_shaped_texture_update_area (ClutterX11TexturePixmap *texture,
 
   meta_texture_tower_update_area (priv->paint_tower, x, y, width, height);
 }
-#endif
+
+#else /* HAVE_WAYLAND */
+
+void
+meta_shaped_texture_queue_damage_redraw (ClutterWaylandSurface *surface,
+                                         int                    x,
+                                         int                    y,
+                                         int                    width,
+                                         int                    height)
+{
+  MetaShapedTexture *stex = (MetaShapedTexture *) surface;
+  MetaShapedTexturePrivate *priv = stex->priv;
+
+  CLUTTER_WAYLAND_SURFACE_CLASS (meta_shaped_texture_parent_class)->queue_damage_redraw (surface,
+                                                                                         x, y, width, height);
+
+  meta_texture_tower_update_area (priv->paint_tower, x, y, width, height);
+}
+#endif /* HAVE_WAYLAND */
 
 ClutterActor *
 meta_shaped_texture_new (Window xwindow)
@@ -712,8 +733,14 @@ meta_shaped_texture_set_create_mipmaps (MetaShapedTexture *stex,
 
       priv->create_mipmaps = create_mipmaps;
 
+#ifdef HAVE_WAYLAND
+      base_texture = create_mipmaps ?
+        clutter_wayland_surface_get_cogl_texture (CLUTTER_WAYLAND_SURFACE (stex)) :
+        COGL_INVALID_HANDLE;
+#else
       base_texture = create_mipmaps ?
 	clutter_texture_get_cogl_texture (CLUTTER_TEXTURE (stex)) : COGL_INVALID_HANDLE;
+#endif
 
       meta_texture_tower_set_base_texture (priv->paint_tower, base_texture);
     }
diff --git a/src/compositor/meta-shaped-texture.h b/src/compositor/meta-shaped-texture.h
index 2df479d..d39f7b3 100644
--- a/src/compositor/meta-shaped-texture.h
+++ b/src/compositor/meta-shaped-texture.h
@@ -83,8 +83,14 @@ void meta_shaped_texture_set_clip_region (MetaShapedTexture *stex,
 					  cairo_region_t    *clip_region);
 
 #ifdef HAVE_WAYLAND
-void meta_shaped_texture_set_wayland_surface (MetaShapedTexture *stex,
-                                              struct wl_surface *surface);
+void meta_shaped_texture_set_wayland_surface   (MetaShapedTexture *stex,
+                                                struct wl_surface *surface);
+void meta_shaped_texture_damage_wayland_buffer (MetaShapedTexture *self,
+                                                struct wl_buffer  *buffer,
+                                                gint32             x,
+                                                gint32             y,
+                                                gint32             width,
+                                                gint32             height);
 #endif
 
 G_END_DECLS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]