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
This commit is contained in:
Florian Müllner 2011-02-04 01:45:16 +01:00
parent acf04d33ef
commit ab80c5080a
3 changed files with 46 additions and 16 deletions

View File

@ -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,

View File

@ -3225,6 +3225,42 @@ st_theme_node_get_content_box (StThemeNode *node,
content_box->y2 = (int)(0.5 + content_box->y1 + content_height);
}
/**
* 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
@ -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;
@ -3268,16 +3302,6 @@ st_theme_node_get_paint_box (StThemeNode *node,
{
st_shadow_get_box (box_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);
}
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);

View File

@ -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);