[gnome-shell] theme-node: Fix box-shadows for prerendered textures



commit ab80c5080ae9fec3914d6b6160255dac0529e59a
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 4 01:45:16 2011 +0100

    theme-node: Fix box-shadows for prerendered textures
    
    The material of prerendered backgrounds is now painted in the
    rectangle determined by st_theme_node_get_paint_box(). As the
    ClutterActorBox returned from that function includes the space
    needed to draw the box shadow, the background ends up occluding
    the shadow.
    As the box shadow is not part of the background, factor out a new
    helper function which excludes the box shadow, and use it to
    prerender and place the background material.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=641522

 src/st/st-theme-node-drawing.c |    6 +++-
 src/st/st-theme-node.c         |   52 +++++++++++++++++++++++++++++----------
 src/st/st-theme-node.h         |    4 +++
 3 files changed, 46 insertions(+), 16 deletions(-)
---
diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c
index 52c737e..409fbd4 100644
--- a/src/st/st-theme-node-drawing.c
+++ b/src/st/st-theme-node-drawing.c
@@ -748,7 +748,7 @@ st_theme_node_render_background_with_border (StThemeNode *node)
    * may need to create an image bigger than the nodes
    * allocation
    */
-  st_theme_node_get_paint_box (node, &actor_box, &paint_box);
+  st_theme_node_get_background_paint_box (node, &actor_box, &paint_box);
 
   /* translate the boxes so the paint box is at 0,0
   */
@@ -1691,7 +1691,9 @@ st_theme_node_paint (StThemeNode           *node,
         {
           ClutterActorBox paint_box;
 
-          st_theme_node_get_paint_box (node, &allocation, &paint_box);
+          st_theme_node_get_background_paint_box (node,
+                                                  &allocation,
+                                                  &paint_box);
 
           paint_material_with_opacity (node->prerendered_material,
                                        &paint_box,
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index b57afb6..6fb579f 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -3226,6 +3226,42 @@ st_theme_node_get_content_box (StThemeNode           *node,
 }
 
 /**
+ * st_theme_node_get_background_paint_box:
+ * @node: a #StThemeNode
+ * @allocation: the box allocated to a #ClutterActor
+ * @paint_box: computed box occupied when painting the actor's background
+ *
+ * Gets the box used to paint the actor's background, including the area
+ * occupied by properties which paint outside the actor's assigned allocation.
+ */
+void
+st_theme_node_get_background_paint_box (StThemeNode           *node,
+                                        const ClutterActorBox *actor_box,
+                                        ClutterActorBox       *paint_box)
+{
+  StShadow *background_image_shadow;
+  ClutterActorBox shadow_box;
+
+  g_return_if_fail (ST_IS_THEME_NODE (node));
+  g_return_if_fail (actor_box != NULL);
+  g_return_if_fail (paint_box != NULL);
+
+  background_image_shadow = st_theme_node_get_background_image_shadow (node);
+
+  *paint_box = *actor_box;
+
+  if (!background_image_shadow)
+    return;
+
+  st_shadow_get_box (background_image_shadow, actor_box, &shadow_box);
+
+  paint_box->x1 = MIN (paint_box->x1, shadow_box.x1);
+  paint_box->x2 = MAX (paint_box->x2, shadow_box.x2);
+  paint_box->y1 = MIN (paint_box->y1, shadow_box.y1);
+  paint_box->y2 = MAX (paint_box->y2, shadow_box.y2);
+}
+
+/**
  * st_theme_node_get_paint_box:
  * @node: a #StThemeNode
  * @allocation: the box allocated to a #ClutterActor
@@ -3242,7 +3278,6 @@ st_theme_node_get_paint_box (StThemeNode           *node,
                              ClutterActorBox       *paint_box)
 {
   StShadow *box_shadow;
-  StShadow *background_image_shadow;
   ClutterActorBox shadow_box;
   int outline_width;
 
@@ -3251,12 +3286,11 @@ st_theme_node_get_paint_box (StThemeNode           *node,
   g_return_if_fail (paint_box != NULL);
 
   box_shadow = st_theme_node_get_box_shadow (node);
-  background_image_shadow = st_theme_node_get_background_image_shadow (node);
   outline_width = st_theme_node_get_outline_width (node);
 
-  *paint_box = *actor_box;
+  st_theme_node_get_background_paint_box (node, actor_box, paint_box);
 
-  if (!box_shadow && !background_image_shadow && !outline_width)
+  if (!box_shadow && !outline_width)
     return;
 
   paint_box->x1 -= outline_width;
@@ -3273,16 +3307,6 @@ st_theme_node_get_paint_box (StThemeNode           *node,
       paint_box->y1 = MIN (paint_box->y1, shadow_box.y1);
       paint_box->y2 = MAX (paint_box->y2, shadow_box.y2);
     }
-
-  if (background_image_shadow)
-    {
-      st_shadow_get_box (background_image_shadow, actor_box, &shadow_box);
-
-      paint_box->x1 = MIN (paint_box->x1, shadow_box.x1);
-      paint_box->x2 = MAX (paint_box->x2, shadow_box.x2);
-      paint_box->y1 = MIN (paint_box->y1, shadow_box.y1);
-      paint_box->y2 = MAX (paint_box->y2, shadow_box.y2);
-    }
 }
 
 /**
diff --git a/src/st/st-theme-node.h b/src/st/st-theme-node.h
index ad9e4e0..46d38b6 100644
--- a/src/st/st-theme-node.h
+++ b/src/st/st-theme-node.h
@@ -228,6 +228,10 @@ void st_theme_node_get_content_box         (StThemeNode        *node,
 void st_theme_node_get_paint_box           (StThemeNode           *node,
                                             const ClutterActorBox *allocation,
                                             ClutterActorBox       *paint_box);
+/* Helper for background prerendering */
+void st_theme_node_get_background_paint_box (StThemeNode           *node,
+                                             const ClutterActorBox *allocation,
+                                             ClutterActorBox       *paint_box);
 
 gboolean st_theme_node_geometry_equal (StThemeNode *node,
                                        StThemeNode *other);



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