[clutter/wip/wayland: 26/45] wayland-surface: Adds queue-damage-redraw signal



commit 8bcd2893029dfbde1be2a924dfa834db35f86bcb
Author: Robert Bragg <robert linux intel com>
Date:   Wed Jan 11 00:08:05 2012 +0000

    wayland-surface: Adds queue-damage-redraw signal
    
    This adds a signal that's emitted whenever a wayland surface is damaged
    that allows sub-classes to override the default handler to change
    how clipped redraws are queued if the sub-class doesn't simply draw
    a rectangle. The signal can also be used just to track damage.

 clutter/wayland/clutter-wayland-surface.c |   53 ++++++++++++++++++++++++----
 clutter/wayland/clutter-wayland-surface.h |    7 ++++
 2 files changed, 52 insertions(+), 8 deletions(-)
---
diff --git a/clutter/wayland/clutter-wayland-surface.c b/clutter/wayland/clutter-wayland-surface.c
index 3be3274..54debaa 100644
--- a/clutter/wayland/clutter-wayland-surface.c
+++ b/clutter/wayland/clutter-wayland-surface.c
@@ -62,14 +62,14 @@ enum
 
 static GParamSpec *obj_props[PROP_LAST];
 
-#if 0
 enum
 {
+  QUEUE_DAMAGE_REDRAW,
+
   LAST_SIGNAL
 };
 
 static guint signals[LAST_SIGNAL] = { 0, };
-#endif
 
 struct _ClutterWaylandSurfacePrivate
 {
@@ -243,10 +243,9 @@ clutter_wayland_surface_set_surface (ClutterWaylandSurface *self,
     {
       free_pipeline (self);
       free_surface_buffers (self);
-      clutter_wayland_surface_queue_damage_redraw (self,
-                                                   0, 0,
-                                                   priv->width,
-                                                   priv->height);
+      g_signal_emit (self, signals[QUEUE_DAMAGE_REDRAW],
+                     0,
+                     0, 0, priv->width, priv->height);
     }
 
   priv->surface = surface;
@@ -448,7 +447,43 @@ clutter_wayland_surface_class_init (ClutterWaylandSurfaceClass *klass)
                               COGL_TYPE_HANDLE,
                               CLUTTER_PARAM_READWRITE);
   obj_props[PROP_COGL_TEXTURE] = pspec;
-  g_object_class_install_property (gobject_class, PROP_COGL_TEXTURE, pspec);
+  g_object_class_install_property (object_class, PROP_COGL_TEXTURE, pspec);
+
+
+  /**
+   * ClutterWaylandSurface::queue-damage-redraw
+   * @texture: the object which received the signal
+   * @x: The top left x position of the damage region
+   * @y: The top left y position of the damage region
+   * @width: The width of the damage region
+   * @height: The height of the damage region
+   *
+   * ::queue-damage-redraw is emitted to notify that some sub-region
+   * of the texture has been changed. This usually means a redraw
+   * needs to be queued for the actor.
+   *
+   * The default handler will queue a clipped redraw in response to
+   * the damage, using the assumption that the pixmap is being painted
+   * to a rectangle covering the transformed allocation of the actor.
+   * If you sub-class and change the paint method so this isn't true
+   * then you must also provide your own damage signal handler to
+   * queue a redraw that blocks this default behaviour.
+   *
+   * Since: 1.10
+   */
+  signals[QUEUE_DAMAGE_REDRAW] =
+    g_signal_new (g_intern_static_string ("queue-damage-redraw"),
+                  G_TYPE_FROM_CLASS (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (ClutterWaylandSurfaceClass, queue_damage_redraw),
+                  NULL, NULL,
+                  _clutter_marshal_VOID__INT_INT_INT_INT,
+                  G_TYPE_NONE, 4,
+                  G_TYPE_INT,
+                  G_TYPE_INT,
+                  G_TYPE_INT,
+                  G_TYPE_INT);
+  klass->queue_damage_redraw = clutter_wayland_surface_queue_damage_redraw;
 }
 
 /**
@@ -588,7 +623,9 @@ clutter_wayland_surface_damage_buffer (ClutterWaylandSurface *self,
                                wl_shm_buffer_get_data (buffer));
     }
 
-  clutter_wayland_surface_queue_damage_redraw (self, x, y, width, height);
+  g_signal_emit (self, signals[QUEUE_DAMAGE_REDRAW],
+                 0,
+                 x, y, width, height);
 }
 
 CoglTexture *
diff --git a/clutter/wayland/clutter-wayland-surface.h b/clutter/wayland/clutter-wayland-surface.h
index 54e4572..e5f64a1 100644
--- a/clutter/wayland/clutter-wayland-surface.h
+++ b/clutter/wayland/clutter-wayland-surface.h
@@ -74,6 +74,13 @@ struct _ClutterWaylandSurfaceClass
 {
   /*< private >*/
   ClutterActorClass parent_class;
+
+  /*< public >*/
+  void (*queue_damage_redraw) (ClutterWaylandSurface *texture,
+                               gint x,
+                               gint y,
+                               gint width,
+                               gint height);
 };
 
 GType clutter_wayland_surface_get_type (void) G_GNUC_CONST;



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