[poppler] configure.ac poppler/GfxState.cc qt4/src utils/pdftocairo.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Feb 20 13:04:27 PST 2012


 configure.ac                |   24 ++++++
 poppler/GfxState.cc         |  159 +++++++++++++++++++++++++++-----------------
 qt4/src/poppler-document.cc |    5 +
 utils/pdftocairo.cc         |   17 ++++
 4 files changed, 143 insertions(+), 62 deletions(-)

New commits:
commit e48c22d3b70412015b9cc07a9a6ce07845274e13
Author: Koji Otani <sho at bbr.jp>
Date:   Mon Feb 20 22:04:01 2012 +0100

    Add support for lcms2

diff --git a/configure.ac b/configure.ac
index d839022..91b0d70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -586,15 +586,28 @@ AC_ARG_ENABLE(cms,
               enable_cms=$enableval,
               enable_cms="try")
 if test x$enable_cms = xyes; then
-  PKG_CHECK_MODULES(LCMS, lcms)
+  PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no])
+  if test x$lcms2 = xno; then
+      PKG_CHECK_MODULES(LCMS, lcms)
+  fi
 elif test x$enable_cms = xtry; then
-  PKG_CHECK_MODULES(LCMS, lcms, [enable_cms=yes], [enable_cms=no])
+  PKG_CHECK_MODULES(LCMS, lcms2,[lcms2=yes],[lcms2=no])
+  if test x$lcms2 = xyes; then
+    enable_cms=yes
+  else
+      PKG_CHECK_MODULES(LCMS, lcms,[enable_cms=yes],[enable_cms=no])
+  fi
 fi
 
 if test "x$enable_cms" = "xyes"; then
   AC_DEFINE(USE_CMS, 1, [Defines if use cms])
+  if test "x$lcms2" != "xyes"; then
+    lcms1=yes;
+    AC_DEFINE(USE_LCMS1, 1, [Defines if use lcms1])
+  fi
 fi
 AM_CONDITIONAL(USE_CMS, test x$enable_cms = xyes)
+AM_CONDITIONAL(USE_LCMS1, test x$lcms1 = xyes)
 
 AC_ARG_WITH([testdatadir],
    [AS_HELP_STRING([--testdatadir=/path/to/testdatadir],
@@ -719,6 +732,13 @@ echo "  use zlib:           $enable_zlib"
 echo "  use libcurl:        $enable_libcurl"
 echo "  use libopenjpeg:    $enable_libopenjpeg"
 echo "  use cms:            $enable_cms"
+if test x$enable_cms = xyes;then
+    if test x$lcms1 = xyes;then
+        echo "      with lcms1"
+    else
+        echo "      with lcms2"
+    fi
+fi
 echo "  command line utils: $enable_utils"
 echo "  test data dir:      $TESTDATADIR"
 echo ""
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index beb38f3..b33e9be 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -17,7 +17,7 @@
 // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff at infidigm.net>
 // Copyright (C) 2006, 2010 Carlos Garcia Campos <carlosgc at gnome.org>
 // Copyright (C) 2006-2011 Albert Astals Cid <aacid at kde.org>
-// Copyright (C) 2009 Koji Otani <sho at bbr.jp>
+// Copyright (C) 2009, 2012 Koji Otani <sho at bbr.jp>
 // Copyright (C) 2009, 2011 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2009 Christian Persch <chpe at gnome.org>
 // Copyright (C) 2010 Paweł Wiejacha <pawel.wiejacha at gmail.com>
@@ -152,7 +152,40 @@ static const char *gfxColorSpaceModeNames[] = {
 
 #ifdef USE_CMS
 
+#ifdef USE_LCMS1
 #include <lcms.h>
+#define cmsColorSpaceSignature icColorSpaceSignature
+#define cmsSetLogErrorHandler cmsSetErrorHandler
+#define cmsSigXYZData icSigXYZData
+#define cmsSigLuvData icSigLuvData
+#define cmsSigLabData icSigLabData
+#define cmsSigYCbCrData icSigYCbCrData
+#define cmsSigYxyData icSigYxyData
+#define cmsSigRgbData icSigRgbData
+#define cmsSigHsvData icSigHsvData
+#define cmsSigHlsData icSigHlsData
+#define cmsSigCmyData icSigCmyData
+#define cmsSig3colorData icSig3colorData
+#define cmsSigGrayData icSigGrayData
+#define cmsSigCmykData icSigCmykData
+#define cmsSig4colorData icSig4colorData
+#define cmsSig2colorData icSig2colorData
+#define cmsSig5colorData icSig5colorData
+#define cmsSig6colorData icSig6colorData
+#define cmsSig7colorData icSig7colorData
+#define cmsSig8colorData icSig8colorData
+#define cmsSig9colorData icSig9colorData
+#define cmsSig10colorData icSig10colorData
+#define cmsSig11colorData icSig11colorData
+#define cmsSig12colorData icSig12colorData
+#define cmsSig13colorData icSig13colorData
+#define cmsSig14colorData icSig14colorData
+#define cmsSig15colorData icSig15colorData
+#define LCMS_FLAGS 0
+#else
+#include <lcms2.h>
+#define LCMS_FLAGS cmsFLAGS_NOOPTIMIZE
+#endif
 
 #define COLOR_PROFILE_DIR "/ColorProfiles/"
 #define GLOBAL_COLOR_PROFILE_DIR POPPLER_DATADIR COLOR_PROFILE_DIR
@@ -186,8 +219,8 @@ static unsigned int displayPixelType = 0;
 static GfxColorTransform *XYZ2DisplayTransform = NULL;
 
 // convert color space signature to cmsColor type 
-static unsigned int getCMSColorSpaceType(icColorSpaceSignature cs);
-static unsigned int getCMSNChannels(icColorSpaceSignature cs);
+static unsigned int getCMSColorSpaceType(cmsColorSpaceSignature cs);
+static unsigned int getCMSNChannels(cmsColorSpaceSignature cs);
 static cmsHPROFILE loadColorProfile(const char *fileName);
 
 void GfxColorSpace::setDisplayProfile(void *displayProfileA) {
@@ -344,11 +377,18 @@ cmsHPROFILE loadColorProfile(const char *fileName)
   return hp;
 }
 
+#ifdef USE_LCMS1
 static int CMSError(int ecode, const char *msg)
 {
     error(errSyntaxWarning, -1, "{0:s}", msg);
     return 1;
 }
+#else
+static void CMSError(cmsContext /*contextId*/, cmsUInt32Number /*ecode*/, const char *text)
+{
+    error(errSyntaxWarning, -1, "{0:s}", text);
+}
+#endif
 
 int GfxColorSpace::setupColorProfiles()
 {
@@ -361,7 +401,7 @@ int GfxColorSpace::setupColorProfiles()
   initialized = gTrue;
 
   // set error handlor
-  cmsSetErrorHandler(CMSError);
+  cmsSetLogErrorHandler(CMSError);
 
   if (displayProfile == NULL) {
     // load display profile if it was not already loaded.
@@ -387,7 +427,7 @@ int GfxColorSpace::setupColorProfiles()
 	   displayProfile, 
 	   COLORSPACE_SH(displayPixelType) |
 	     CHANNELS_SH(nChannels) | BYTES_SH(1),
-	  INTENT_RELATIVE_COLORIMETRIC,0)) == 0) {
+	  INTENT_RELATIVE_COLORIMETRIC,LCMS_FLAGS)) == 0) {
       error(errSyntaxWarning, -1, "Can't create Lab transform");
     } else {
       XYZ2DisplayTransform = new GfxColorTransform(transform);
@@ -397,125 +437,124 @@ int GfxColorSpace::setupColorProfiles()
   return 0;
 }
 
-unsigned int getCMSColorSpaceType(icColorSpaceSignature cs)
+unsigned int getCMSColorSpaceType(cmsColorSpaceSignature cs)
 {
     switch (cs) {
-    case icSigXYZData:
+    case cmsSigXYZData:
       return PT_XYZ;
       break;
-    case icSigLabData:
+    case cmsSigLabData:
       return PT_Lab;
       break;
-    case icSigLuvData:
+    case cmsSigLuvData:
       return PT_YUV;
       break;
-    case icSigYCbCrData:
+    case cmsSigYCbCrData:
       return PT_YCbCr;
       break;
-    case icSigYxyData:
+    case cmsSigYxyData:
       return PT_Yxy;
       break;
-    case icSigRgbData:
+    case cmsSigRgbData:
       return PT_RGB;
       break;
-    case icSigGrayData:
+    case cmsSigGrayData:
       return PT_GRAY;
       break;
-    case icSigHsvData:
+    case cmsSigHsvData:
       return PT_HSV;
       break;
-    case icSigHlsData:
+    case cmsSigHlsData:
       return PT_HLS;
       break;
-    case icSigCmykData:
+    case cmsSigCmykData:
       return PT_CMYK;
       break;
-    case icSigCmyData:
+    case cmsSigCmyData:
       return PT_CMY;
       break;
-    case icSig2colorData:
-    case icSig3colorData:
-    case icSig4colorData:
-    case icSig5colorData:
-    case icSig6colorData:
-    case icSig7colorData:
-    case icSig8colorData:
-    case icSig9colorData:
-    case icSig10colorData:
-    case icSig11colorData:
-    case icSig12colorData:
-    case icSig13colorData:
-    case icSig14colorData:
-    case icSig15colorData:
+    case cmsSig2colorData:
+    case cmsSig3colorData:
+    case cmsSig4colorData:
+    case cmsSig5colorData:
+    case cmsSig6colorData:
+    case cmsSig7colorData:
+    case cmsSig8colorData:
+    case cmsSig9colorData:
+    case cmsSig10colorData:
+    case cmsSig11colorData:
+    case cmsSig12colorData:
+    case cmsSig13colorData:
+    case cmsSig14colorData:
+    case cmsSig15colorData:
     default:
       break;
     }
     return PT_RGB;
 }
 
-unsigned int getCMSNChannels(icColorSpaceSignature cs)
+unsigned int getCMSNChannels(cmsColorSpaceSignature cs)
 {
     switch (cs) {
-    case icSigXYZData:
-    case icSigLuvData:
-    case icSigLabData:
-    case icSigYCbCrData:
-    case icSigYxyData:
-    case icSigRgbData:
-    case icSigHsvData:
-    case icSigHlsData:
-    case icSigCmyData:
-    case icSig3colorData:
+    case cmsSigXYZData:
+    case cmsSigLuvData:
+    case cmsSigLabData:
+    case cmsSigYCbCrData:
+    case cmsSigYxyData:
+    case cmsSigRgbData:
+    case cmsSigHsvData:
+    case cmsSigHlsData:
+    case cmsSigCmyData:
+    case cmsSig3colorData:
       return 3;
       break;
-    case icSigGrayData:
+    case cmsSigGrayData:
       return 1;
       break;
-    case icSigCmykData:
-    case icSig4colorData:
+    case cmsSigCmykData:
+    case cmsSig4colorData:
       return 4;
       break;
-    case icSig2colorData:
+    case cmsSig2colorData:
       return 2;
       break;
-    case icSig5colorData:
+    case cmsSig5colorData:
       return 5;
       break;
-    case icSig6colorData:
+    case cmsSig6colorData:
       return 6;
       break;
-    case icSig7colorData:
+    case cmsSig7colorData:
       return 7;
       break;
-    case icSig8colorData:
+    case cmsSig8colorData:
       return 8;
       break;
-    case icSig9colorData:
+    case cmsSig9colorData:
       return 9;
       break;
-    case icSig10colorData:
+    case cmsSig10colorData:
       return 10;
       break;
-    case icSig11colorData:
+    case cmsSig11colorData:
       return 11;
       break;
-    case icSig12colorData:
+    case cmsSig12colorData:
       return 12;
       break;
-    case icSig13colorData:
+    case cmsSig13colorData:
       return 13;
       break;
-    case icSig14colorData:
+    case cmsSig14colorData:
       return 14;
       break;
-    case icSig15colorData:
+    case cmsSig15colorData:
       return 15;
     default:
       break;
     }
     return 3;
 }
-
 #endif
 
 //------------------------------------------------------------------------
@@ -1648,7 +1687,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
 	   dhp,
 	   COLORSPACE_SH(dcst) |
 	     CHANNELS_SH(dNChannels) | BYTES_SH(1),
-	  INTENT_RELATIVE_COLORIMETRIC,0)) == 0) {
+	  INTENT_RELATIVE_COLORIMETRIC,LCMS_FLAGS)) == 0) {
       error(errSyntaxWarning, -1, "Can't create transform");
       cs->transform = NULL;
     } else {
@@ -1658,7 +1697,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx, int recursion)
        // create line transform only when the display is RGB type color space 
       if ((transform = cmsCreateTransform(hp,
 	    CHANNELS_SH(nCompsA) | BYTES_SH(1),dhp,
-	    TYPE_RGB_8,INTENT_RELATIVE_COLORIMETRIC,0)) == 0) {
+	    TYPE_RGB_8,INTENT_RELATIVE_COLORIMETRIC,LCMS_FLAGS)) == 0) {
 	error(errSyntaxWarning, -1, "Can't create transform");
 	cs->lineTransform = NULL;
       } else {
diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc
index 7b3e1af..550e706 100644
--- a/qt4/src/poppler-document.cc
+++ b/qt4/src/poppler-document.cc
@@ -4,6 +4,7 @@
  * Copyright (C) 2005-2010, Albert Astals Cid <aacid at kde.org>
  * Copyright (C) 2006-2010, Pino Toscano <pino at kde.org>
  * Copyright (C) 2010, 2011 Hib Eris <hib at hiberis.nl>
+ * Copyright (C) 2012 Koji Otani <sho at bbr.jp>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -40,7 +41,11 @@
 #include "poppler-page-private.h"
 
 #if defined(USE_CMS)
+#if defined(USE_LCMS1)
 #include <lcms.h>
+#else
+#include <lcms2.h>
+#endif
 #endif
 
 namespace Poppler {
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index d4be6d5..0d920ac 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -25,6 +25,7 @@
 // Copyright (C) 2010 William Bader <williambader at hotmail.com>
 // Copyright (C) 2011 Thomas Freitag <Thomas.Freitag at alfa.de>
 // Copyright (C) 2011 Carlos Garcia Campos <carlosgc at gnome.org>
+// Copyright (C) 2012 Koji Otani <sho at bbr.jp>
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -50,7 +51,11 @@
 #include "PDFDocFactory.h"
 #include "CairoOutputDev.h"
 #if USE_CMS
+#ifdef USE_LCMS1
 #include <lcms.h>
+#else
+#include <lcms2.h>
+#endif
 #endif
 #include <cairo.h>
 #if CAIRO_HAS_PS_SURFACE
@@ -257,10 +262,22 @@ void writePageImage(GooString *filename)
       writer = new PNGWriter(PNGWriter::RGB);
 
 #if USE_CMS
+#ifdef USE_LCMS1
     if (icc_data)
       static_cast<PNGWriter*>(writer)->setICCProfile(cmsTakeProductName(profile), icc_data, icc_data_size);
     else
       static_cast<PNGWriter*>(writer)->setSRGBProfile();
+#else
+    if (icc_data) {
+      cmsUInt8Number profileID[17];
+      profileID[16] = '\0';
+
+      cmsGetHeaderProfileID(profile,profileID);
+      static_cast<PNGWriter*>(writer)->setICCProfile(reinterpret_cast<char *>(profileID), icc_data, icc_data_size);
+    } else {
+      static_cast<PNGWriter*>(writer)->setSRGBProfile();
+    }
+#endif
 #endif
 #endif
 


More information about the poppler mailing list