diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 294471732..155d9b3df 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -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); diff --git a/test/.gitignore b/test/.gitignore index 14cc7df6c..456b96925 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -91,6 +91,7 @@ get-xrender-format glitz-surface-source glyph-cache-pressure gradient-alpha +gradient-constant-alpha gradient-zero-stops group-paint imagediff diff --git a/test/Makefile.am b/test/Makefile.am index 0ded81d0f..e00cbd640 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 \ diff --git a/test/clip-operator-ps-argb32-ref.png b/test/clip-operator-ps-argb32-ref.png deleted file mode 100644 index 35014bd83..000000000 Binary files a/test/clip-operator-ps-argb32-ref.png and /dev/null differ diff --git a/test/clip-operator-ps-rgb24-ref.png b/test/clip-operator-ps-rgb24-ref.png index 1736e4bb8..6ed9fc456 100644 Binary files a/test/clip-operator-ps-rgb24-ref.png and b/test/clip-operator-ps-rgb24-ref.png differ diff --git a/test/gradient-alpha-ps-argb32-ref.png b/test/gradient-alpha-ps-argb32-ref.png index 323238bd8..37eafba3c 100644 Binary files a/test/gradient-alpha-ps-argb32-ref.png and b/test/gradient-alpha-ps-argb32-ref.png differ diff --git a/test/gradient-alpha-ps-rgb24-ref.png b/test/gradient-alpha-ps-rgb24-ref.png index 430052cb6..2432c2996 100644 Binary files a/test/gradient-alpha-ps-rgb24-ref.png and b/test/gradient-alpha-ps-rgb24-ref.png differ diff --git a/test/gradient-constant-alpha-ps-ref.png b/test/gradient-constant-alpha-ps-ref.png new file mode 100644 index 000000000..7089f4fdc Binary files /dev/null and b/test/gradient-constant-alpha-ps-ref.png differ diff --git a/test/gradient-constant-alpha-ps-rgb24-ref.png b/test/gradient-constant-alpha-ps-rgb24-ref.png new file mode 100644 index 000000000..5962925f2 Binary files /dev/null and b/test/gradient-constant-alpha-ps-rgb24-ref.png differ diff --git a/test/gradient-constant-alpha-ref.png b/test/gradient-constant-alpha-ref.png new file mode 100644 index 000000000..9a24e8cda Binary files /dev/null and b/test/gradient-constant-alpha-ref.png differ diff --git a/test/gradient-constant-alpha-rgb24-ref.png b/test/gradient-constant-alpha-rgb24-ref.png new file mode 100644 index 000000000..f190009dd Binary files /dev/null and b/test/gradient-constant-alpha-rgb24-ref.png differ diff --git a/test/operator-clear-ps-argb32-ref.png b/test/operator-clear-ps-argb32-ref.png deleted file mode 100644 index d9a776941..000000000 Binary files a/test/operator-clear-ps-argb32-ref.png and /dev/null differ diff --git a/test/operator-source-ps-argb32-ref.png b/test/operator-source-ps-argb32-ref.png deleted file mode 100644 index d5cb053a2..000000000 Binary files a/test/operator-source-ps-argb32-ref.png and /dev/null differ diff --git a/test/operator-source-ps-rgb24-ref.png b/test/operator-source-ps-rgb24-ref.png deleted file mode 100644 index eb73a9e3b..000000000 Binary files a/test/operator-source-ps-rgb24-ref.png and /dev/null differ