PDF: Use cairo_image_analyse_transparency during analysis

OPERATOR_SOURCE is only supported for opaque images. Check if and ARGB
image really contains transparency before returing unsupported.
This commit is contained in:
Adrian Johnson 2008-03-10 17:18:07 +10:30
parent 61d45c9d1f
commit f534fe434d

View file

@ -4021,6 +4021,35 @@ _cairo_pdf_surface_write_page (cairo_pdf_surface_t *surface)
return CAIRO_STATUS_SUCCESS;
}
static cairo_int_status_t
_cairo_pdf_surface_analyze_surface_pattern_transparency (cairo_pdf_surface_t *surface,
cairo_surface_pattern_t *pattern)
{
cairo_image_surface_t *image;
void *image_extra;
cairo_int_status_t status;
cairo_image_transparency_t transparency;
status = _cairo_surface_acquire_source_image (pattern->surface,
&image,
&image_extra);
if (status)
return status;
if (image->base.status)
return image->base.status;
transparency = _cairo_image_analyze_transparency (image);
if (transparency == CAIRO_IMAGE_IS_OPAQUE)
status = CAIRO_STATUS_SUCCESS;
else
status = CAIRO_INT_STATUS_FLATTEN_TRANSPARENCY;
_cairo_surface_release_source_image (pattern->surface, image, image_extra);
return status;
}
static cairo_bool_t
_surface_pattern_supported (cairo_surface_pattern_t *pattern)
{
@ -4129,9 +4158,16 @@ _cairo_pdf_surface_analyze_operation (cairo_pdf_surface_t *surface,
if (op == CAIRO_OPERATOR_OVER)
return CAIRO_STATUS_SUCCESS;
/* The SOURCE operator supported if the pattern is opaque or if
/* The SOURCE operator is supported if the pattern is opaque or if
* there is nothing painted underneath. */
if (op == CAIRO_OPERATOR_SOURCE) {
if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE) {
cairo_surface_pattern_t *surface_pattern = (cairo_surface_pattern_t *) pattern;
return _cairo_pdf_surface_analyze_surface_pattern_transparency (surface,
surface_pattern);
}
if (_cairo_pattern_is_opaque (pattern))
return CAIRO_STATUS_SUCCESS;
else