[poppler] CMakeLists.txt configure.ac poppler/CairoOutputDev.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Tue Dec 14 02:56:28 PST 2010


 CMakeLists.txt            |    2 ++
 configure.ac              |    1 +
 poppler/CairoOutputDev.cc |   25 ++++++++++++++++++-------
 3 files changed, 21 insertions(+), 7 deletions(-)

New commits:
commit 06da4b46c442778c67b788b747f04b386b5247ac
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Tue Dec 14 09:06:57 2010 +1030

    cairo: Use A1 instead of A8 for imagemask
    
    The cairo PDF surface now optimizes the case of cairo_mask() with
    solid source and A1 mask to use a PDF stencil mask.
    
    Fixes https://bugs.launchpad.net/ubuntu/+source/libcairo/+bug/680628
    where a 65K PDF printed to PDF using poppler-cairo turns into an 8MB
    PDF.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 758c8c9..4043722 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,8 @@ find_package(PkgConfig)
 include(MacroEnsureVersion)
 include(MacroBoolTo01)
 find_package(Threads)
+include(TestBigEndian)
+test_big_endian(WORDS_BIGENDIAN)
 
 set(POPPLER_MAJOR_VERSION "0")
 set(POPPLER_MINOR_VERSION "15")
diff --git a/configure.ac b/configure.ac
index 1249a7d..088aac5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,7 @@ AM_INIT_AUTOMAKE([foreign])
 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
 AM_CONFIG_HEADER(config.h)
 AM_CONFIG_HEADER(poppler/poppler-config.h)
+AC_C_BIGENDIAN
 
 dnl ##### Initialize libtool.
 AC_LIBTOOL_WIN32_DLL
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index e7c9dc5..0507f8c 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1550,7 +1550,7 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
   unsigned char *dest;
   cairo_surface_t *image;
   cairo_pattern_t *pattern;
-  int x, y;
+  int x, y, i, bit;
   ImageStream *imgStr;
   Guchar *pix;
   cairo_matrix_t matrix;
@@ -1562,7 +1562,7 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
   imgStr = new ImageStream(str, width, 1, 1);
   imgStr->reset();
 
-  image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height);
+  image = cairo_image_surface_create (CAIRO_FORMAT_A1, width, height);
   if (cairo_surface_status (image))
     goto cleanup;
 
@@ -1574,12 +1574,23 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
   for (y = 0; y < height; y++) {
     pix = imgStr->getLine();
     dest = buffer + y * row_stride;
+    i = 0;
+    bit = 0;
     for (x = 0; x < width; x++) {
-
-      if (pix[x] ^ invert_bit)
-	*dest++ = 0;
-      else
-	*dest++ = 255;
+      if (bit == 0)
+	dest[i] = 0;
+      if (!(pix[x] ^ invert_bit)) {
+#ifdef WORDS_BIGENDIAN
+	dest[i] |= (1 << (7 - bit));
+#else
+	dest[i] |= (1 << bit);
+#endif
+      }
+      bit++;
+      if (bit > 7) {
+	bit = 0;
+	i++;
+      }
     }
   }
 


More information about the poppler mailing list