diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-11-19 19:18:53 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-12-13 09:46:09 +0100 |
commit | ec4c085624d12cef51e583c18306fd4f4c2b6aaa (patch) | |
tree | a989ac57ad9c3b18e876975ad62d6780bb7d921e /src/cairo-pdf-surface.c | |
parent | 6579bf728f802e13b45292b11e3782db1844316f (diff) |
ps, pdf, pattern: Implement _cairo_pattern_alpha_range to analyse patterns.
Both the ps and pdf backends are open coding analyses of the
range of pattern alphas. This patch factors out a new function
_cairo_pattern_alpha_range() to do that for them.
Reviewed-by: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
Diffstat (limited to 'src/cairo-pdf-surface.c')
-rw-r--r-- | src/cairo-pdf-surface.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index d25dd910..99e9d0ce 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -1244,18 +1244,6 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t *surface, return status; } -static cairo_bool_t -_gradient_stops_are_opaque (const cairo_gradient_pattern_t *gradient) -{ - unsigned int i; - - for (i = 0; i < gradient->n_stops; i++) - if (! CAIRO_COLOR_IS_OPAQUE (&gradient->stops[i].color)) - return FALSE; - - return TRUE; -} - static cairo_status_t _cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t *surface, const cairo_pattern_t *pattern, @@ -1289,8 +1277,10 @@ _cairo_pdf_surface_add_pdf_pattern (cairo_pdf_surface_t *surface, if (pattern->type == CAIRO_PATTERN_TYPE_LINEAR || pattern->type == CAIRO_PATTERN_TYPE_RADIAL) { - cairo_gradient_pattern_t *gradient = (cairo_gradient_pattern_t *) pattern; - if (! _gradient_stops_are_opaque (gradient)) { + double min_alpha; + + _cairo_pattern_alpha_range (pattern, &min_alpha, NULL); + if (! CAIRO_ALPHA_IS_OPAQUE (min_alpha)) { pdf_pattern.gstate_res = _cairo_pdf_surface_new_object (surface); if (pdf_pattern.gstate_res.id == 0) { cairo_pattern_destroy (pdf_pattern.pattern); |