[gnome-shell/wip/clutter-deprecation-fixes: 12/18] st: Simplify paint_volume handling



commit 09a31fdc9a585699b219b6c79104f9aeb0e93f8c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Feb 13 15:05:38 2012 -0500

    st: Simplify paint_volume handling
    
    Use a new convenience method, clutter_paint_volume_union_box, to grab our
    paint box. Additionally, because the paint box is relative to the actor's
    modelview (its allocation in most cases), make st_theme_node_get_paint_box
    return something relative to the actor box too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670034

 src/st/st-container.c  |   34 ----------------------------------
 src/st/st-shadow.c     |   27 +++++++++------------------
 src/st/st-theme-node.c |    6 +++++-
 src/st/st-widget.c     |   12 ++----------
 4 files changed, 16 insertions(+), 63 deletions(-)
---
diff --git a/src/st/st-container.c b/src/st/st-container.c
index 36174c1..0cbefcb 100644
--- a/src/st/st-container.c
+++ b/src/st/st-container.c
@@ -45,37 +45,6 @@ st_container_get_children_list (StContainer *container)
   return clutter_actor_get_children (CLUTTER_ACTOR (container));
 }
 
-static gboolean
-st_container_get_paint_volume (ClutterActor *actor,
-                               ClutterPaintVolume *volume)
-{
-  if (!CLUTTER_ACTOR_CLASS (st_container_parent_class)->get_paint_volume (actor, volume))
-    return FALSE;
-
-  if (!clutter_actor_get_clip_to_allocation (actor))
-    {
-      ClutterActor *child;
-
-      /* Based on ClutterGroup/ClutterBox; include the children's
-       * paint volumes, since they may paint outside our allocation.
-       */
-      for (child = clutter_actor_get_first_child (actor);
-           child != NULL;
-           child = clutter_actor_get_next_sibling (child))
-        {
-          const ClutterPaintVolume *child_volume;
-
-          child_volume = clutter_actor_get_transformed_paint_volume (child, actor);
-          if (!child_volume)
-            return FALSE;
-
-          clutter_paint_volume_union (volume, child_volume);
-        }
-    }
-
-  return TRUE;
-}
-
 static void
 st_container_init (StContainer *container)
 {
@@ -84,7 +53,4 @@ st_container_init (StContainer *container)
 static void
 st_container_class_init (StContainerClass *klass)
 {
-  ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
-
-  actor_class->get_paint_volume = st_container_get_paint_volume;
 }
diff --git a/src/st/st-shadow.c b/src/st/st-shadow.c
index 9c3784a..fee8b97 100644
--- a/src/st/st-shadow.c
+++ b/src/st/st-shadow.c
@@ -150,29 +150,20 @@ st_shadow_get_box (StShadow              *shadow,
                    const ClutterActorBox *actor_box,
                    ClutterActorBox       *shadow_box)
 {
+  gdouble reach;
   g_return_if_fail (shadow != NULL);
   g_return_if_fail (actor_box != NULL);
   g_return_if_fail (shadow_box != NULL);
 
-  /* Inset shadows are drawn below the border, so returning
-   * the original box is not actually correct; still, it's
-   * good enough for the purpose of determing additional space
-   * required outside the actor box.
-   */
+  reach = shadow->blur + shadow->spread;
+
   if (shadow->inset)
-    {
-      *shadow_box = *actor_box;
-      return;
-    }
-
-  shadow_box->x1 = actor_box->x1 + shadow->xoffset
-                   - shadow->blur - shadow->spread;
-  shadow_box->x2 = actor_box->x2 + shadow->xoffset
-                   + shadow->blur + shadow->spread;
-  shadow_box->y1 = actor_box->y1 + shadow->yoffset
-                   - shadow->blur - shadow->spread;
-  shadow_box->y2 = actor_box->y2 + shadow->yoffset
-                   + shadow->blur + shadow->spread;
+    reach *= -1;
+
+  shadow_box->x1 = shadow->xoffset - reach;
+  shadow_box->x2 = actor_box->x2 + shadow->xoffset + reach;
+  shadow_box->y1 = shadow->yoffset - reach;
+  shadow_box->y2 = actor_box->y2 + shadow->yoffset + reach;
 }
 
 GType
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 47b117c..d4a8c16 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -3361,7 +3361,11 @@ st_theme_node_get_background_paint_box (StThemeNode           *node,
 
   background_image_shadow = st_theme_node_get_background_image_shadow (node);
 
-  *paint_box = *actor_box;
+  /* The paint box should be in the actor's coordinate space. */
+  paint_box->x1 = 0;
+  paint_box->y1 = 0;
+  paint_box->x2 = actor_box->x2 - actor_box->x1;
+  paint_box->y2 = actor_box->y2 - actor_box->y1;
 
   if (!background_image_shadow)
     return;
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index 3d0b64a..dfb43a4 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -688,10 +688,8 @@ st_widget_get_paint_volume (ClutterActor *self,
   ClutterActorBox paint_box, alloc_box;
   StThemeNode *theme_node;
   StWidgetPrivate *priv;
-  ClutterVertex origin;
 
-  /* Setting the paint volume does not make sense when we don't have any allocation */
-  if (!clutter_actor_has_allocation (self))
+  if (!CLUTTER_ACTOR_CLASS (st_widget_parent_class)->get_paint_volume (self, volume))
     return FALSE;
 
   priv = ST_WIDGET (self)->priv;
@@ -705,13 +703,7 @@ st_widget_get_paint_volume (ClutterActor *self,
   else
     st_theme_node_get_paint_box (theme_node, &alloc_box, &paint_box);
 
-  origin.x = paint_box.x1 - alloc_box.x1;
-  origin.y = paint_box.y1 - alloc_box.y1;
-  origin.z = 0.0f;
-
-  clutter_paint_volume_set_origin (volume, &origin);
-  clutter_paint_volume_set_width (volume, paint_box.x2 - paint_box.x1);
-  clutter_paint_volume_set_height (volume, paint_box.y2 - paint_box.y1);
+  clutter_paint_volume_union_box (volume, &paint_box);
 
   return TRUE;
 }



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