From 551c0f468f27876dc11526a03026f3e15826cb66 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sat, 20 Apr 2013 16:41:56 +0200 Subject: [PATCH] cairo: Always use the trasnfer function if present in setSoftMask "If the subtype is Alpha, the transparency group XObject G shall be evaluated to compute a group alpha only. The colours of the constituent objects shall be ignored and the colour compositing computations shall not be performed. The transfer function TR shall then be applied to the computed group alpha to produce the mask values." We were using the transfer function only for luminosity soft masks. https://bugs.freedesktop.org/show_bug.cgi?id=63587 --- poppler/CairoOutputDev.cc | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 2ff84b6..37e0f1c 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -1577,7 +1577,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, LOG(printf ("set softMask\n")); - if (alpha == false) { + if (!alpha || transferFunc) { /* We need to mask according to the luminocity of the group. * So we paint the group to an image surface convert it to a luminocity map * and then use that as the mask. */ @@ -1620,13 +1620,15 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, cairo_t *maskCtx = cairo_create(source); //XXX: hopefully this uses the correct color space */ - GfxRGB backdropColorRGB; - groupColorSpaceStack->cs->getRGB(backdropColor, &backdropColorRGB); - /* paint the backdrop */ - cairo_set_source_rgb(maskCtx, - colToDbl(backdropColorRGB.r), - colToDbl(backdropColorRGB.g), - colToDbl(backdropColorRGB.b)); + if (!alpha) { + GfxRGB backdropColorRGB; + groupColorSpaceStack->cs->getRGB(backdropColor, &backdropColorRGB); + /* paint the backdrop */ + cairo_set_source_rgb(maskCtx, + colToDbl(backdropColorRGB.r), + colToDbl(backdropColorRGB.g), + colToDbl(backdropColorRGB.b)); + } cairo_paint(maskCtx); /* Copy source ctm to mask ctm and translate origin so that the @@ -1653,15 +1655,14 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, int stride = cairo_image_surface_get_stride(source)/4; for (int y=0; ytransform(&lum_in, &lum_out); - lum = (int)(lum_out * 255.0 + 0.5); - } - source_data[y*stride + x] = lum << 24; + int lum = alpha ? fill_opacity : luminocity(source_data[y*stride + x]); + if (transferFunc) { + double lum_in, lum_out; + lum_in = lum/256.0; + transferFunc->transform(&lum_in, &lum_out); + lum = (int)(lum_out * 255.0 + 0.5); + } + source_data[y*stride + x] = lum << 24; } } cairo_surface_mark_dirty (source); @@ -1681,7 +1682,7 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha, } cairo_surface_destroy(source); - } else { + } else if (alpha) { mask = cairo_pattern_reference(group); cairo_get_matrix(cairo, &mask_matrix); } -- 1.7.10.4