diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 3916485..5649738 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -2584,6 +2584,29 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s filter = getFilterForSurface (image, interpolate); cairo_surface_mark_dirty (image); + { + cairo_surface_t *combined = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); + cairo_t *cr = cairo_create (combined); + + cairo_matrix_init_translate (&maskMatrix, 0, 0); + cairo_matrix_scale (&maskMatrix, maskWidth * 1.0 / width, maskHeight * 1.0 / height); + + cairo_pattern_set_extend (maskPattern, CAIRO_EXTEND_PAD); + cairo_pattern_set_filter (maskPattern, maskFilter); + cairo_pattern_set_matrix (maskPattern, &maskMatrix); + + if (cairo_pattern_status (maskPattern)) { + cairo_destroy (cr); + cairo_pattern_destroy (maskPattern); + goto cleanup; + } + + cairo_set_source_surface (cr, image, 0.0, 0.0); + cairo_mask (cr, maskPattern); + cairo_destroy (cr); + cairo_surface_destroy (image); + image = combined; + } setMimeData(state, str, ref, colorMap, image); @@ -2595,11 +2618,9 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s LOG (printf ("drawSoftMaskedImage %dx%d\n", width, height)); cairo_pattern_set_filter (pattern, filter); - cairo_pattern_set_filter (maskPattern, maskFilter); if (!printing) { cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); - cairo_pattern_set_extend (maskPattern, CAIRO_EXTEND_PAD); } cairo_matrix_init_translate (&matrix, 0, height); @@ -2611,36 +2632,14 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s goto cleanup; } - cairo_matrix_init_translate (&maskMatrix, 0, maskHeight); - cairo_matrix_scale (&maskMatrix, maskWidth, -maskHeight); - cairo_pattern_set_matrix (maskPattern, &maskMatrix); - if (cairo_pattern_status (maskPattern)) { - cairo_pattern_destroy (maskPattern); - cairo_pattern_destroy (pattern); - goto cleanup; - } - - if (fill_opacity != 1.0) - cairo_push_group (cairo); - else - cairo_save (cairo); - cairo_set_source (cairo, pattern); - if (!printing) { - cairo_rectangle (cairo, 0., 0., 1., 1.); - cairo_clip (cairo); - } - cairo_mask (cairo, maskPattern); - if (fill_opacity != 1.0) { - cairo_pop_group_to_source (cairo); cairo_save (cairo); if (!printing) { cairo_rectangle (cairo, 0., 0., 1., 1.); cairo_clip (cairo); } cairo_paint_with_alpha (cairo, fill_opacity); - } cairo_restore (cairo); if (cairo_shape) {