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



commit 712326d5121b96991e19c2c1d67e92044472554d
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.
    
    StBoxLayout needs to be corrected for the fade effect to work - it never
    paints outside its allocation. It is unknown why it worked when chaining
    up to the near-identical StContainer implementation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670034

 src/st/st-box-layout.c            |   21 ++++++++++++++++++---
 src/st/st-container.c             |   34 ----------------------------------
 src/st/st-shadow.c                |   27 +++++++++------------------
 src/st/st-theme-node-transition.c |   19 +++----------------
 src/st/st-theme-node.c            |    6 +++++-
 src/st/st-widget.c                |   13 +++++--------
 6 files changed, 40 insertions(+), 80 deletions(-)
---
diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c
index fb19c4f..8a9246d 100644
--- a/src/st/st-box-layout.c
+++ b/src/st/st-box-layout.c
@@ -1006,8 +1006,25 @@ st_box_layout_get_paint_volume (ClutterActor       *actor,
 {
   StBoxLayout *self = ST_BOX_LAYOUT (actor);
   gdouble x, y;
+  StBoxLayoutPrivate *priv = self->priv;
+  StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (actor));
+  ClutterActorBox allocation_box;
+  ClutterActorBox content_box;
+  ClutterVertex origin;
 
-  if (!CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->get_paint_volume (actor, volume))
+  /* When have an adjustment we are clipped to the content box, so base
+   * our paint volume on that. */
+  if (priv->hadjustment || priv->vadjustment)
+    {
+      clutter_actor_get_allocation_box (actor, &allocation_box);
+      st_theme_node_get_content_box (theme_node, &allocation_box, &content_box);
+      origin.x = content_box.x1 - allocation_box.x1;
+      origin.y = content_box.y1 - allocation_box.y2;
+      origin.z = 0.f;
+      clutter_paint_volume_set_width (volume, content_box.x2 - content_box.x1);
+      clutter_paint_volume_set_height (volume, content_box.y2 - content_box.y1);
+    }
+  else if (!CLUTTER_ACTOR_CLASS (st_box_layout_parent_class)->get_paint_volume (actor, volume))
     return FALSE;
 
   /* When scrolled, st_box_layout_apply_transform() includes the scroll offset
@@ -1018,8 +1035,6 @@ st_box_layout_get_paint_volume (ClutterActor       *actor,
   get_border_paint_offsets (self, &x, &y);
   if (x != 0 || y != 0)
     {
-      ClutterVertex origin;
-
       clutter_paint_volume_get_origin (volume, &origin);
       origin.x += x;
       origin.y += y;
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-transition.c b/src/st/st-theme-node-transition.c
index 26a6347..4a15137 100644
--- a/src/st/st-theme-node-transition.c
+++ b/src/st/st-theme-node-transition.c
@@ -179,21 +179,6 @@ st_theme_node_transition_update (StThemeNodeTransition *transition,
     }
 }
 
-static void
-calculate_offscreen_box (StThemeNodeTransition *transition,
-                         const ClutterActorBox *allocation)
-{
-  ClutterActorBox paint_box;
-
-  st_theme_node_transition_get_paint_box (transition,
-                                          allocation,
-                                          &paint_box);
-  transition->priv->offscreen_box.x1 = paint_box.x1 - allocation->x1;
-  transition->priv->offscreen_box.y1 = paint_box.y1 - allocation->y1;
-  transition->priv->offscreen_box.x2 = paint_box.x2 - allocation->x1;
-  transition->priv->offscreen_box.y2 = paint_box.y2 - allocation->y1;
-}
-
 void
 st_theme_node_transition_get_paint_box (StThemeNodeTransition *transition,
                                         const ClutterActorBox *allocation,
@@ -326,7 +311,9 @@ st_theme_node_transition_paint (StThemeNodeTransition *transition,
     {
       priv->last_allocation = *allocation;
 
-      calculate_offscreen_box (transition, allocation);
+      st_theme_node_transition_get_paint_box (transition,
+                                              allocation,
+                                              &transition->priv->offscreen_box);
       priv->needs_setup = !setup_framebuffers (transition, allocation);
 
       if (priv->needs_setup) /* setting up framebuffers failed */
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..62d32d3 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -688,12 +688,15 @@ 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))
     return FALSE;
 
+  /* Ignore the return value from here... Clutter is conservative
+   * with its return values, and we know better. */
+  CLUTTER_ACTOR_CLASS (st_widget_parent_class)->get_paint_volume (self, volume);
+
   priv = ST_WIDGET (self)->priv;
 
   theme_node = st_widget_get_theme_node (ST_WIDGET (self));
@@ -705,13 +708,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]