[poppler] 2 commits - poppler/CairoOutputDev.cc poppler/CairoOutputDev.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Fri Mar 20 06:12:52 PDT 2009


 poppler/CairoOutputDev.cc |   34 ++++++++++++++++++++++++++++++++--
 poppler/CairoOutputDev.h  |    5 +++++
 2 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit 121c44db0884f0d70ba1470a66aa78441257c421
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Mar 20 23:25:19 2009 +1030

    Fix cairo luminosity smask when cairo ctm != identity

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index fd93e05..91e1d04 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -949,8 +949,22 @@ void CairoOutputDev::setSoftMask(GfxState * state, double * bbox, GBool alpha,
      * So we paint the group to an image surface convert it to a luminocity map
      * and then use that as the mask. */
 
-    double x1, y1, x2, y2;
+    double x1, y1, x2, y2, tmp;
     cairo_clip_extents(cairo, &x1, &y1, &x2, &y2);
+    cairo_user_to_device(cairo, &x1, &y1);
+    cairo_user_to_device(cairo, &x2, &y2);
+    if (x1 > x2) {
+      tmp = x1;
+      x1 = x2;
+      x2 = tmp;
+    }
+
+    if (y1 > y2) {
+      tmp = y1;
+      y1 = y2;
+      y2 = tmp;
+    }
+
     int width = (int)(ceil(x2) - floor(x1));
     int height = (int)(ceil(y2) - floor(y1));
 
commit 3f55aff56a1d2002ba79f3efba5eb77e94575439
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Thu Mar 19 22:34:23 2009 +1030

    Fix bug in cairo backend with nested masks
    
    The previous smask was not restored after a q/Q pair or form xobject.

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 822d66d..fd93e05 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -132,6 +132,7 @@ CairoOutputDev::CairoOutputDev() {
   t3_glyph_has_bbox = gFalse;
 
   groupColorSpaceStack = NULL;
+  maskStack = NULL;
   group = NULL;
   mask = NULL;
   shape = NULL;
@@ -242,6 +243,11 @@ void CairoOutputDev::saveState(GfxState *state) {
   cairo_save (cairo);
   if (cairo_shape)
       cairo_save (cairo_shape);
+
+  MaskStack *ms = new MaskStack;
+  ms->mask = cairo_pattern_reference(mask);
+  ms->next = maskStack;
+  maskStack = ms;
 }
 
 void CairoOutputDev::restoreState(GfxState *state) {
@@ -256,6 +262,14 @@ void CairoOutputDev::restoreState(GfxState *state) {
   updateStrokeColor(state);
   updateFillOpacity(state);
   updateStrokeOpacity(state);
+
+  MaskStack* ms = maskStack;
+  if (mask)
+    cairo_pattern_destroy(mask);
+
+  mask = ms->mask;
+  maskStack = ms->next;
+  delete ms;
 }
 
 void CairoOutputDev::updateAll(GfxState *state) {
@@ -1024,7 +1038,9 @@ void CairoOutputDev::popTransparencyGroup() {
 
 
 void CairoOutputDev::clearSoftMask(GfxState * /*state*/) {
-  //XXX: should we be doing anything here?
+  if (mask)
+    cairo_pattern_destroy(mask);
+  mask = NULL;
 }
 
 void CairoOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 1e410c1..5ec2bf0 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -271,6 +271,11 @@ protected:
     GfxColorSpace *cs;
     struct ColorSpaceStack *next;
   } * groupColorSpaceStack;
+
+  struct MaskStack {
+      cairo_pattern_t *mask;
+      struct MaskStack *next;
+  } *maskStack;
 };
 
 //------------------------------------------------------------------------


More information about the poppler mailing list