St: Take the cairo fallback for large corners

The cogl path pads the corners out to the maximum corner radius to make the
math and painting logic easier. Unfortunately, when the radius exceeds the
actor's halfsize, the padding ends up interfering with other corners, creating
a big mess of rendering errors.

It'd be extremely complicated to fix this properly in the Cogl code,
so take the Cairo fallback.

https://bugzilla.gnome.org/show_bug.cgi?id=649513
This commit is contained in:
Jasper St. Pierre 2011-05-16 19:02:24 -04:00
parent ee4ae62946
commit 325462d9bf

View File

@ -1330,6 +1330,7 @@ st_theme_node_render_resources (StThemeNode *node,
gboolean has_border; gboolean has_border;
gboolean has_border_radius; gboolean has_border_radius;
gboolean has_inset_box_shadow; gboolean has_inset_box_shadow;
gboolean has_large_corners;
StShadow *box_shadow_spec; StShadow *box_shadow_spec;
StShadow *background_image_shadow_spec; StShadow *background_image_shadow_spec;
const char *background_image; const char *background_image;
@ -1367,6 +1368,27 @@ st_theme_node_render_resources (StThemeNode *node,
else else
has_border_radius = FALSE; has_border_radius = FALSE;
/* The cogl code pads each corner to the maximum border radius,
* which results in overlapping corner areas if the radius
* exceeds the actor's halfsize, causing rendering errors.
* Fall back to cairo in these cases. */
has_large_corners = FALSE;
if (has_border_radius) {
guint border_radius[4];
int corner;
st_theme_node_reduce_border_radius (node, border_radius);
for (corner = 0; corner < 4; corner ++) {
if (border_radius[corner] * 2 > height ||
border_radius[corner] * 2 > width) {
has_large_corners = TRUE;
break;
}
}
}
/* Load referenced images from disk and draw anything we need with cairo now */ /* Load referenced images from disk and draw anything we need with cairo now */
background_image = st_theme_node_get_background_image (node); background_image = st_theme_node_get_background_image (node);
border_image = st_theme_node_get_border_image (node); border_image = st_theme_node_get_border_image (node);
@ -1387,7 +1409,8 @@ st_theme_node_render_resources (StThemeNode *node,
/* Use cairo to prerender the node if there is a gradient, or /* Use cairo to prerender the node if there is a gradient, or
* background image with borders and/or rounded corners, * background image with borders and/or rounded corners,
* since we can't do those things easily with cogl. * or large corners, since we can't do those things
* easily with cogl.
* *
* FIXME: if we could figure out ahead of time that a * FIXME: if we could figure out ahead of time that a
* background image won't overlap with the node borders, * background image won't overlap with the node borders,
@ -1395,7 +1418,8 @@ st_theme_node_render_resources (StThemeNode *node,
*/ */
if ((node->background_gradient_type != ST_GRADIENT_NONE) if ((node->background_gradient_type != ST_GRADIENT_NONE)
|| (has_inset_box_shadow && (has_border || node->background_color.alpha > 0)) || (has_inset_box_shadow && (has_border || node->background_color.alpha > 0))
|| (background_image && (has_border || has_border_radius))) || (background_image && (has_border || has_border_radius))
|| has_large_corners)
node->prerendered_texture = st_theme_node_prerender_background (node); node->prerendered_texture = st_theme_node_prerender_background (node);
if (node->prerendered_texture) if (node->prerendered_texture)