[gnome-shell/wip/clutter-deprecation-fixes: 11/27] st: Simplify paint_volume handling



commit 2eb1644c07a13dc14c60660130a5f121b3b7df13
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.

 src/st/st-shadow.c     |   27 +++++++++------------------
 src/st/st-theme-node.c |    6 +++++-
 src/st/st-widget.c     |   14 +++-----------
 3 files changed, 17 insertions(+), 30 deletions(-)
---
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 319fd34..ea0f774 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -759,15 +759,13 @@ 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;
 
-  theme_node = st_widget_get_theme_node (ST_WIDGET(self));
+  theme_node = st_widget_get_theme_node (ST_WIDGET (self));
   clutter_actor_get_allocation_box (self, &alloc_box);
 
   if (priv->transition_animation)
@@ -776,13 +774,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]