[ps] Only use fallback images if the gradient has non-constant alpha.

If the gradient has constant alpha, then we can express it as a flattened
linear gradient. Otherwise, should the opacity vary across the gradient we
need to fallback.
This commit is contained in:
Chris Wilson 2008-09-07 14:57:16 +01:00
parent 94fd60d5ec
commit 7439c45039
14 changed files with 15 additions and 1 deletions

View file

@ -1437,11 +1437,25 @@ static cairo_bool_t
_gradient_pattern_supported (cairo_ps_surface_t *surface,
cairo_pattern_t *pattern)
{
cairo_gradient_pattern_t *gradient = (cairo_gradient_pattern_t *) pattern;
uint16_t alpha;
cairo_extend_t extend;
int i;
if (surface->ps_level == CAIRO_PS_LEVEL_2)
return FALSE;
if (gradient->n_stops == 0)
return TRUE;
/* Alpha gradients are only supported (by flattening the alpha)
* if there is no variation in the alpha across the gradient. */
alpha = gradient->stops[0].color.alpha_short;
for (i = 0; i < gradient->n_stops; i++) {
if (gradient->stops[i].color.alpha_short != alpha)
return FALSE;
}
surface->ps_level_used = CAIRO_PS_LEVEL_3;
extend = cairo_pattern_get_extend (pattern);

1
test/.gitignore vendored
View file

@ -91,6 +91,7 @@ get-xrender-format
glitz-surface-source
glyph-cache-pressure
gradient-alpha
gradient-constant-alpha
gradient-zero-stops
group-paint
imagediff

View file

@ -455,7 +455,6 @@ REFERENCE_IMAGES = \
gradient-alpha-rgb24-ref.png \
gradient-constant-alpha-pdf-argb32-ref.png \
gradient-constant-alpha-pdf-rgb24-ref.png \
gradient-constant-alpha-ps-argb32-ref.png \
gradient-constant-alpha-ps-rgb24-ref.png \
gradient-constant-alpha-ref.png \
gradient-constant-alpha-rgb24-ref.png \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB