update to 0.10.4

changes:
-fixed some crashes and a memory leak
-fixed pdfimages to work for jpeg
pkgsrc change: pulled in color management support from the development
branch (but tested by me for many weeks), as an option which is on
per default
This commit is contained in:
drochner 2009-02-12 20:55:07 +00:00
parent bc1a4f1675
commit aa77e743df
13 changed files with 1559 additions and 16 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.17 2008/11/20 14:28:22 dillo Exp $
# $NetBSD: Makefile,v 1.18 2009/02/12 20:55:07 drochner Exp $
#
.include "../../print/poppler/Makefile.common"
@ -24,6 +24,7 @@ CONFIGURE_ARGS+= --disable-poppler-qt
# Don't compile GTK+ test program.
CONFIGURE_ARGS+= --disable-gtk-test
CONFIGURE_ARGS+= --disable-utils
CONFIGURE_ARGS+= --disable-cms
BUILD_DIRS= goo fofi poppler glib
INSTALL_DIRS= glib

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.17 2008/11/20 14:28:22 dillo Exp $
# $NetBSD: Makefile,v 1.18 2009/02/12 20:55:07 drochner Exp $
#
.include "../../print/poppler/Makefile.common"
@ -14,6 +14,7 @@ CONFIGURE_ARGS+= --disable-splash-output
CONFIGURE_ARGS+= --enable-poppler-qt
CONFIGURE_ARGS+= --disable-gtk-test
CONFIGURE_ARGS+= --disable-utils
CONFIGURE_ARGS+= --disable-cms
PKGCONFIG_OVERRIDE+= ${WRKSRC}/poppler-qt.pc.in

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.6 2008/11/20 14:28:22 dillo Exp $
# $NetBSD: Makefile,v 1.7 2009/02/12 20:55:07 drochner Exp $
#
.include "../../print/poppler/Makefile.common"
@ -13,6 +13,7 @@ CONFIGURE_ARGS+= --disable-cairo-output
CONFIGURE_ARGS+= --enable-poppler-qt4
CONFIGURE_ARGS+= --disable-gtk-test
CONFIGURE_ARGS+= --disable-utils
CONFIGURE_ARGS+= --disable-cms
PKGCONFIG_OVERRIDE+= ${WRKSRC}/poppler-qt4.pc.in

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.6 2008/11/20 14:28:22 dillo Exp $
# $NetBSD: Makefile,v 1.7 2009/02/12 20:55:07 drochner Exp $
#
.include "../../print/poppler/Makefile.common"
@ -27,6 +27,7 @@ CONFIGURE_ARGS+= --disable-gtk-test
CONFIGURE_ARGS+= --disable-poppler-glib
# Enable build and install of the tools
CONFIGURE_ARGS+= --enable-utils # the default
CONFIGURE_ARGS+= --disable-cms
BUILD_DIRS= utils # implies INSTALL_DIRS too

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.34 2009/01/07 13:54:14 wiz Exp $
# $NetBSD: Makefile,v 1.35 2009/02/12 20:55:07 drochner Exp $
#
.include "../../print/poppler/Makefile.common"
@ -30,6 +30,18 @@ CONFIGURE_ARGS+= --disable-poppler-glib
# Don't build and install the tools
CONFIGURE_ARGS+= --disable-utils
PKG_OPTIONS_VAR= PKG_OPTIONS.poppler
PKG_SUPPORTED_OPTIONS= poppler-cms
PKG_SUGGESTED_OPTIONS= poppler-cms
.include "../../mk/bsd.options.mk"
.if !empty(PKG_OPTIONS:Mpoppler-cms)
CONFIGURE_ARGS+= --enable-cms
.include "../../graphics/lcms/buildlink3.mk"
.else
CONFIGURE_ARGS+= --disable-cms
.endif
.include "../../mk/bsd.prefs.mk"
post-install:

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile.common,v 1.26 2009/01/13 10:18:56 wiz Exp $
# $NetBSD: Makefile.common,v 1.27 2009/02/12 20:55:07 drochner Exp $
#
# used by print/poppler/Makefile
# used by print/poppler-glib/Makefile
@ -7,7 +7,7 @@
# used by print/poppler-qt4/Makefile
# used by print/poppler-utils/Makefile
POPPLER_VERS= 0.10.3
POPPLER_VERS= 0.10.4
DISTNAME= poppler-${POPPLER_VERS}
CATEGORIES= print
MASTER_SITES= http://poppler.freedesktop.org/

View file

@ -1,4 +1,4 @@
# $NetBSD: buildlink3.mk,v 1.13 2009/01/13 10:18:56 wiz Exp $
# $NetBSD: buildlink3.mk,v 1.14 2009/02/12 20:55:07 drochner Exp $
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
POPPLER_BUILDLINK3_MK:= ${POPPLER_BUILDLINK3_MK}+
@ -21,6 +21,12 @@ PRINT_PLIST_AWK+= /^@dirrm include\/poppler$$/ \
{ print "@comment in poppler: " $$0; next; }
.endif # POPPLER_BUILDLINK3_MK
pkgbase := poppler
.include "../../mk/pkg-build-options.mk"
.if !empty(PKG_BUILD_OPTIONS.poppler:Mpoppler-cms)
.include "../../graphics/lcms/buildlink3.mk"
.endif
.include "../../fonts/fontconfig/buildlink3.mk"
.include "../../graphics/jpeg/buildlink3.mk"

View file

@ -1,9 +1,13 @@
$NetBSD: distinfo,v 1.38 2009/01/13 10:18:56 wiz Exp $
$NetBSD: distinfo,v 1.39 2009/02/12 20:55:07 drochner Exp $
SHA1 (poppler-0.10.3.tar.gz) = 04e4d132fedf7f4633ed3438f9da9a580d985811
RMD160 (poppler-0.10.3.tar.gz) = f3c70686d130c784543719aefbe600e85fda2e33
Size (poppler-0.10.3.tar.gz) = 1530394 bytes
SHA1 (poppler-0.10.4.tar.gz) = e8a5a1090394a2cfab3c9aa67d188f3628c60165
RMD160 (poppler-0.10.4.tar.gz) = 62815f486a4f1eaa226e84aa953134be6a209ed6
Size (poppler-0.10.4.tar.gz) = 1513213 bytes
SHA1 (patch-aa) = 43c63c16d3a845e394a8eb0c3a321944fcf17615
SHA1 (patch-ab) = 5a2785bccd71990e20cd81a3cd2697804e31788d
SHA1 (patch-ag) = 0bf1bc080cad55792fe6cc761bf22ecccba7d13a
SHA1 (patch-ai) = d3d4411092b5c6dd61d3f197c01c3bcdad88cc0e
SHA1 (patch-ai) = 852332490394756c496d06eb109f3d1d637f8717
SHA1 (patch-aj) = 8bb1fe169bddb76ecc72129cc1dbd32030073dfd
SHA1 (patch-ak) = ab4d0c91a6f2806b405954f8dab6e3d61a03b054
SHA1 (patch-ca) = ba4190663bc0c0e9a7d9477922665e0ed5d4c0e4
SHA1 (patch-cb) = e8cfb16a0641788759b13cf5fcf97d82f9485adc

View file

@ -1,8 +1,66 @@
$NetBSD: patch-ai,v 1.5 2008/07/15 10:34:21 drochner Exp $
$NetBSD: patch-ai,v 1.6 2009/02/12 20:55:07 drochner Exp $
--- configure.orig 2008-07-02 16:30:43.000000000 +0200
--- configure.orig 2009-02-10 20:06:59.000000000 +0100
+++ configure
@@ -27984,7 +27984,7 @@ fi
@@ -945,6 +945,8 @@ BUILD_ABIWORD_OUTPUT_TRUE
BUILD_ABIWORD_OUTPUT_FALSE
BUILD_UTILS_TRUE
BUILD_UTILS_FALSE
+USE_CMS_TRUE
+USE_CMS_FALSE
PC_REQUIRES
PC_REQUIRES_PRIVATE
LIBOBJS
@@ -1594,6 +1596,7 @@ Optional Features:
--enable-compile-warnings=[no/yes/kde]
Turn on compiler warnings.
+ --disable-cms Don't use color management system.
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -19915,13 +19918,11 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <sys/types.h> /* for off_t */
- #include <stdio.h>
+#include <stdio.h>
int
main ()
{
-int (*fp) (FILE *, off_t, int) = fseeko;
- return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
;
return 0;
}
@@ -19961,13 +19962,11 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define _LARGEFILE_SOURCE 1
-#include <sys/types.h> /* for off_t */
- #include <stdio.h>
+#include <stdio.h>
int
main ()
{
-int (*fp) (FILE *, off_t, int) = fseeko;
- return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
;
return 0;
}
@@ -21325,7 +21324,7 @@ for i in $jpeg_incdirs;
do
for j in jpeglib.h;
do
- echo "configure: 21328: $i/$j" >&5
+ echo "configure: 21327: $i/$j" >&5
if test -r "$i/$j"; then
echo "taking that" >&5
jpeg_incdir=$i
@@ -23687,7 +23686,7 @@ fi
if test x$enable_poppler_qt4 = xyes; then
{ echo "$as_me:$LINENO: checking for Qt4 moc" >&5
echo $ECHO_N "checking for Qt4 moc... $ECHO_C" >&6; }
@ -11,3 +69,292 @@ $NetBSD: patch-ai,v 1.5 2008/07/15 10:34:21 drochner Exp $
mocversion=`$MOCQT4 -v 2>&1`
mocversiongrep=`echo $mocversion | grep "Qt 4"`
if test x"$mocversiongrep" != x"$mocversion"; then
@@ -24142,6 +24141,249 @@ else
fi
+
+# Check whether --enable-cms was given.
+if test "${enable_cms+set}" = set; then
+ enableval=$enable_cms; enable_cms=$enableval
+else
+ enable_cms="yes"
+fi
+
+if test x$enable_cms = xyes; then
+
+{ echo "$as_me:$LINENO: checking for cmsOpenProfileFromFile in -llcms" >&5
+echo $ECHO_N "checking for cmsOpenProfileFromFile in -llcms... $ECHO_C" >&6; }
+if test "${ac_cv_lib_lcms_cmsOpenProfileFromFile+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-llcms $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char cmsOpenProfileFromFile ();
+int
+main ()
+{
+return cmsOpenProfileFromFile ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_lib_lcms_cmsOpenProfileFromFile=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_lcms_cmsOpenProfileFromFile=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_lcms_cmsOpenProfileFromFile" >&5
+echo "${ECHO_T}$ac_cv_lib_lcms_cmsOpenProfileFromFile" >&6; }
+if test $ac_cv_lib_lcms_cmsOpenProfileFromFile = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBLCMS 1
+_ACEOF
+
+ LIBS="-llcms $LIBS"
+
+else
+ { { echo "$as_me:$LINENO: error: \"*** lcms library not found ***\"" >&5
+echo "$as_me: error: \"*** lcms library not found ***\"" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+
+for ac_header in lcms.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+
+ ;;
+esac
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ { { echo "$as_me:$LINENO: error: \"*** lcms headers not found ***\"" >&5
+echo "$as_me: error: \"*** lcms headers not found ***\"" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+done
+
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_CMS 1
+_ACEOF
+
+fi
+ if test x$enable_cms = xyes; then
+ USE_CMS_TRUE=
+ USE_CMS_FALSE='#'
+else
+ USE_CMS_TRUE='#'
+ USE_CMS_FALSE=
+fi
+
+
if test "x$GCC" != xyes; then
enable_compile_warnings=no
fi
@@ -24413,6 +24655,13 @@ echo "$as_me: error: conditional \"BUILD
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${USE_CMS_TRUE}" && test -z "${USE_CMS_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"USE_CMS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"USE_CMS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
@@ -25542,13 +25791,15 @@ BUILD_ABIWORD_OUTPUT_TRUE!$BUILD_ABIWORD
BUILD_ABIWORD_OUTPUT_FALSE!$BUILD_ABIWORD_OUTPUT_FALSE$ac_delim
BUILD_UTILS_TRUE!$BUILD_UTILS_TRUE$ac_delim
BUILD_UTILS_FALSE!$BUILD_UTILS_FALSE$ac_delim
+USE_CMS_TRUE!$USE_CMS_TRUE$ac_delim
+USE_CMS_FALSE!$USE_CMS_FALSE$ac_delim
PC_REQUIRES!$PC_REQUIRES$ac_delim
PC_REQUIRES_PRIVATE!$PC_REQUIRES_PRIVATE$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 91; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 93; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -26961,6 +27212,7 @@ echo " use gtk-doc: $enable_gtk_
echo " use libjpeg: $enable_libjpeg"
echo " use zlib: $enable_zlib"
echo " use libopenjpeg: $enable_libopenjpeg"
+echo " use cms: $enable_cms"
echo " command line utils: $enable_utils"
echo ""

View file

@ -0,0 +1,51 @@
$NetBSD: patch-aj,v 1.7 2009/02/12 20:55:07 drochner Exp $
--- poppler/Makefile.in.orig 2008-12-18 00:09:45.000000000 +0100
+++ poppler/Makefile.in
@@ -70,19 +70,20 @@ am__libpoppler_cairo_la_SOURCES_DIST = C
@BUILD_CAIRO_OUTPUT_TRUE@ CairoFontEngine.lo CairoOutputDev.lo
libpoppler_cairo_la_OBJECTS = $(am_libpoppler_cairo_la_OBJECTS)
@BUILD_CAIRO_OUTPUT_TRUE@am_libpoppler_cairo_la_rpath =
-@BUILD_SPLASH_OUTPUT_TRUE@am__DEPENDENCIES_1 = \
+am__DEPENDENCIES_1 =
+@BUILD_SPLASH_OUTPUT_TRUE@am__DEPENDENCIES_2 = \
@BUILD_SPLASH_OUTPUT_TRUE@ $(top_builddir)/splash/libsplash.la
-am__DEPENDENCIES_2 =
-@BUILD_LIBJPEG_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_2)
-@BUILD_ZLIB_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_2)
-@BUILD_LIBOPENJPEG_TRUE@am__DEPENDENCIES_5 = $(am__DEPENDENCIES_2)
-@BUILD_ABIWORD_OUTPUT_TRUE@am__DEPENDENCIES_6 = $(am__DEPENDENCIES_2)
+@BUILD_LIBJPEG_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1)
+@BUILD_ZLIB_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1)
+@BUILD_LIBOPENJPEG_TRUE@am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1)
+@BUILD_ABIWORD_OUTPUT_TRUE@am__DEPENDENCIES_6 = $(am__DEPENDENCIES_1)
libpoppler_la_DEPENDENCIES = $(top_builddir)/goo/libgoo.la \
$(top_builddir)/fofi/libfofi.la $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) \
- $(am__DEPENDENCIES_5) $(am__DEPENDENCIES_6) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2) \
- $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2)
+ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3) \
+ $(am__DEPENDENCIES_4) $(am__DEPENDENCIES_5) \
+ $(am__DEPENDENCIES_6) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
am__libpoppler_la_SOURCES_DIST = SplashOutputDev.cc DCTStream.h \
DCTStream.cc FlateStream.h FlateStream.cc JPXStream.h \
JPXStream.cc JPEG2000Stream.h JPEG2000Stream.cc ABWOutputDev.h \
@@ -394,6 +395,7 @@ win32_libs = @win32_libs@
@BUILD_ABIWORD_OUTPUT_TRUE@abiword_libs = \
@BUILD_ABIWORD_OUTPUT_TRUE@ $(ABIWORD_LIBS)
+@USE_CMS_TRUE@cms_libs = -llcms
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/goo \
@@ -411,6 +413,7 @@ noinst_LTLIBRARIES = $(poppler_cairo) \
libpoppler_la_LIBADD = \
$(top_builddir)/goo/libgoo.la \
$(top_builddir)/fofi/libfofi.la \
+ $(cms_libs) \
$(splash_libs) \
$(libjpeg_libs) \
$(zlib_libs) \

View file

@ -0,0 +1,27 @@
$NetBSD: patch-ak,v 1.5 2009/02/12 20:55:07 drochner Exp $
--- config.h.in.orig 2008-12-18 00:32:25.000000000 +0100
+++ config.h.in
@@ -40,6 +40,12 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define to 1 if you have the <lcms.h> header file. */
+#undef HAVE_LCMS_H
+
+/* Define to 1 if you have the `lcms' library (-llcms). */
+#undef HAVE_LIBLCMS
+
/* Define to 1 if you have the `openjpeg' library (-lopenjpeg). */
#undef HAVE_LIBOPENJPEG
@@ -148,6 +154,9 @@
/* Enable word list support. */
#undef TEXTOUT_WORD_LIST
+/* Defines if use cms */
+#undef USE_CMS
+
/* Throw exceptions to deal with not enough memory and similar problems */
#undef USE_EXCEPTIONS

View file

@ -0,0 +1,936 @@
$NetBSD: patch-ca,v 1.1 2009/02/12 20:55:07 drochner Exp $
--- poppler/GfxState.cc.orig 2008-11-05 22:49:26.000000000 +0100
+++ poppler/GfxState.cc
@@ -39,6 +39,7 @@
#include "Page.h"
#include "GfxState.h"
#include "GfxFont.h"
+#include "GlobalParams.h"
//------------------------------------------------------------------------
@@ -224,6 +225,225 @@ void GfxColorSpace::getRGBLine(Guchar *i
}
}
+#ifdef USE_CMS
+cmsHPROFILE GfxColorSpace::RGBProfile = NULL;
+cmsHPROFILE GfxColorSpace::displayProfile = NULL;
+GooString *GfxColorSpace::displayProfileName = NULL;
+unsigned int GfxColorSpace::displayPixelType = 0;
+GfxColorTransform *GfxColorSpace::XYZ2DisplayTransform = NULL;
+
+cmsHPROFILE GfxColorSpace::loadColorProfile(const char *fileName)
+{
+ cmsHPROFILE hp = NULL;
+ FILE *fp;
+
+ if (fileName[0] == '/') {
+ // full path
+ // check if open the file
+ if ((fp = fopen(fileName,"r")) != NULL) {
+ fclose(fp);
+ hp = cmsOpenProfileFromFile(fileName,"r");
+ }
+ return hp;
+ }
+ // try to load from user directory
+ GooString *path = globalParams->getBaseDir();
+ path->append(COLOR_PROFILE_DIR);
+ path->append(fileName);
+ // check if open the file
+ if ((fp = fopen(path->getCString(),"r")) != NULL) {
+ fclose(fp);
+ hp = cmsOpenProfileFromFile(path->getCString(),"r");
+ }
+ delete path;
+ if (hp == NULL) {
+ // load from global directory
+ path = new GooString(GLOBAL_COLOR_PROFILE_DIR);
+ path->append(fileName);
+ // check if open the file
+ if ((fp = fopen(path->getCString(),"r")) != NULL) {
+ fclose(fp);
+ hp = cmsOpenProfileFromFile(path->getCString(),"r");
+ }
+ delete path;
+ }
+ return hp;
+}
+
+static int CMSError(int ecode, const char *msg)
+{
+ error(-1,const_cast<char *>(msg));
+ return 1;
+}
+
+int GfxColorSpace::setupColorProfiles()
+{
+ static GBool initialized = gFalse;
+ cmsHTRANSFORM transform;
+ unsigned int nChannels;
+
+ // do only once
+ if (initialized) return 0;
+ initialized = gTrue;
+
+ // set error handlor
+ cmsSetErrorHandler(CMSError);
+
+ if (displayProfile == NULL) {
+ // load display profile if it was not already loaded.
+ if (displayProfileName == NULL) {
+ displayProfile = loadColorProfile("display.icc");
+ } else if (displayProfileName->getLength() > 0) {
+ displayProfile = loadColorProfile(displayProfileName->getCString());
+ }
+ }
+ // load RGB profile
+ RGBProfile = loadColorProfile("RGB.icc");
+ if (RGBProfile == NULL) {
+ /* use built in sRGB profile */
+ RGBProfile = cmsCreate_sRGBProfile();
+ }
+ // create transforms
+ if (displayProfile != NULL) {
+ displayPixelType = getCMSColorSpaceType(cmsGetColorSpace(displayProfile));
+ nChannels = getCMSNChannels(cmsGetColorSpace(displayProfile));
+ // create transform from XYZ
+ cmsHPROFILE XYZProfile = cmsCreateXYZProfile();
+ if ((transform = cmsCreateTransform(XYZProfile, TYPE_XYZ_DBL,
+ displayProfile,
+ COLORSPACE_SH(displayPixelType) |
+ CHANNELS_SH(nChannels) | BYTES_SH(0),
+ INTENT_RELATIVE_COLORIMETRIC,0)) == 0) {
+ error(-1, "Can't create Lab transform");
+ } else {
+ XYZ2DisplayTransform = new GfxColorTransform(transform);
+ }
+ cmsCloseProfile(XYZProfile);
+ }
+ return 0;
+}
+
+unsigned int GfxColorSpace::getCMSColorSpaceType(icColorSpaceSignature cs)
+{
+ switch (cs) {
+ case icSigXYZData:
+ return PT_XYZ;
+ break;
+ case icSigLabData:
+ return PT_Lab;
+ break;
+ case icSigLuvData:
+ return PT_YUV;
+ break;
+ case icSigYCbCrData:
+ return PT_YCbCr;
+ break;
+ case icSigYxyData:
+ return PT_Yxy;
+ break;
+ case icSigRgbData:
+ return PT_RGB;
+ break;
+ case icSigGrayData:
+ return PT_GRAY;
+ break;
+ case icSigHsvData:
+ return PT_HSV;
+ break;
+ case icSigHlsData:
+ return PT_HLS;
+ break;
+ case icSigCmykData:
+ return PT_CMYK;
+ break;
+ case icSigCmyData:
+ 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:
+ default:
+ break;
+ }
+ return PT_RGB;
+}
+
+unsigned int GfxColorSpace::getCMSNChannels(icColorSpaceSignature cs)
+{
+ switch (cs) {
+ case icSigXYZData:
+ case icSigLuvData:
+ case icSigLabData:
+ case icSigYCbCrData:
+ case icSigYxyData:
+ case icSigRgbData:
+ case icSigHsvData:
+ case icSigHlsData:
+ case icSigCmyData:
+ case icSig3colorData:
+ return 3;
+ break;
+ case icSigGrayData:
+ return 1;
+ break;
+ case icSigCmykData:
+ case icSig4colorData:
+ return 4;
+ break;
+ case icSig2colorData:
+ return 2;
+ break;
+ case icSig5colorData:
+ return 5;
+ break;
+ case icSig6colorData:
+ return 6;
+ break;
+ case icSig7colorData:
+ return 7;
+ break;
+ case icSig8colorData:
+ return 8;
+ break;
+ case icSig9colorData:
+ return 9;
+ break;
+ case icSig10colorData:
+ return 10;
+ break;
+ case icSig11colorData:
+ return 11;
+ break;
+ case icSig12colorData:
+ return 12;
+ break;
+ case icSig13colorData:
+ return 13;
+ break;
+ case icSig14colorData:
+ return 14;
+ break;
+ case icSig15colorData:
+ return 15;
+ default:
+ break;
+ }
+ return 3;
+}
+
+#endif
+
void GfxColorSpace::getGrayLine(Guchar *in, unsigned char *out, int length) {
int i, j, n;
GfxColor color;
@@ -311,6 +531,14 @@ GfxColorSpace *GfxCalGrayColorSpace::cop
return cs;
}
+// This is the inverse of MatrixLMN in Example 4.10 from the PostScript
+// Language Reference, Third Edition.
+static const double xyzrgb[3][3] = {
+ { 3.240449, -1.537136, -0.498531 },
+ { -0.969265, 1.876011, 0.041556 },
+ { 0.055643, -0.204026, 1.057229 }
+};
+
GfxColorSpace *GfxCalGrayColorSpace::parse(Array *arr) {
GfxCalGrayColorSpace *cs;
Object obj1, obj2, obj3;
@@ -353,32 +581,127 @@ GfxColorSpace *GfxCalGrayColorSpace::par
}
obj2.free();
obj1.free();
+
+ cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX +
+ xyzrgb[0][1] * cs->whiteY +
+ xyzrgb[0][2] * cs->whiteZ);
+ cs->kg = 1 / (xyzrgb[1][0] * cs->whiteX +
+ xyzrgb[1][1] * cs->whiteY +
+ xyzrgb[1][2] * cs->whiteZ);
+ cs->kb = 1 / (xyzrgb[2][0] * cs->whiteX +
+ xyzrgb[2][1] * cs->whiteY +
+ xyzrgb[2][2] * cs->whiteZ);
+
return cs;
}
-void GfxCalGrayColorSpace::getGray(GfxColor *color, GfxGray *gray) {
- *gray = clip01(color->c[0]);
+// convert CalGray to media XYZ color space
+// (not multiply by the white point)
+void GfxCalGrayColorSpace::getXYZ(GfxColor *color,
+ double *pX, double *pY, double *pZ) {
+ double A;
+
+ A = colToDbl(color->c[0]);
+ *pX = pow(A,gamma);
+ *pY = pow(A,gamma);
+ *pZ = pow(A,gamma);
}
-void GfxCalGrayColorSpace::getGrayLine(Guchar *in, Guchar *out, int length) {
- memcpy (out, in, length);
-}
+void GfxCalGrayColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+ GfxRGB rgb;
-void GfxCalGrayColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
- rgb->r = rgb->g = rgb->b = clip01(color->c[0]);
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) {
+ double out[gfxColorMaxComps];
+ double in[gfxColorMaxComps];
+ double X, Y, Z;
+
+ getXYZ(color,&X,&Y,&Z);
+ in[0] = clip01(X);
+ in[1] = clip01(Y);
+ in[2] = clip01(Z);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ *gray = dblToCol(out[0]);
+ return;
+ }
+#endif
+ getRGB(color, &rgb);
+ *gray = clip01((GfxColorComp)(0.299 * rgb.r +
+ 0.587 * rgb.g +
+ 0.114 * rgb.b + 0.5));
}
-void GfxCalGrayColorSpace::getRGBLine(Guchar *in, unsigned int *out,
- int length) {
- int i;
+void GfxCalGrayColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+ double X, Y, Z;
+ double r, g, b;
- for (i = 0; i < length; i++)
- out[i] = (in[i] << 16) | (in[i] << 8) | (in[i] << 0);
+ getXYZ(color,&X,&Y,&Z);
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_RGB) {
+ double out[gfxColorMaxComps];
+ double in[gfxColorMaxComps];
+
+ in[0] = clip01(X);
+ in[1] = clip01(Y);
+ in[2] = clip01(Z);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ rgb->r = dblToCol(out[0]);
+ rgb->g = dblToCol(out[1]);
+ rgb->b = dblToCol(out[2]);
+ return;
+ }
+#endif
+ X *= whiteX;
+ Y *= whiteY;
+ Z *= whiteZ;
+ // convert XYZ to RGB, including gamut mapping and gamma correction
+ r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
+ g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
+ b = xyzrgb[2][0] * X + xyzrgb[2][1] * Y + xyzrgb[2][2] * Z;
+ rgb->r = dblToCol(pow(clip01(r * kr), 0.5));
+ rgb->g = dblToCol(pow(clip01(g * kg), 0.5));
+ rgb->b = dblToCol(pow(clip01(b * kb), 0.5));
+ rgb->r = rgb->g = rgb->b = clip01(color->c[0]);
}
void GfxCalGrayColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
- cmyk->c = cmyk->m = cmyk->y = 0;
- cmyk->k = clip01(gfxColorComp1 - color->c[0]);
+ GfxRGB rgb;
+ GfxColorComp c, m, y, k;
+
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_CMYK) {
+ double in[gfxColorMaxComps];
+ double out[gfxColorMaxComps];
+ double X, Y, Z;
+
+ getXYZ(color,&X,&Y,&Z);
+ in[0] = clip01(X);
+ in[1] = clip01(Y);
+ in[2] = clip01(Z);
+
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ cmyk->c = dblToCol(out[0]);
+ cmyk->m = dblToCol(out[1]);
+ cmyk->y = dblToCol(out[2]);
+ cmyk->k = dblToCol(out[3]);
+ return;
+ }
+#endif
+ getRGB(color, &rgb);
+ c = clip01(gfxColorComp1 - rgb.r);
+ m = clip01(gfxColorComp1 - rgb.g);
+ y = clip01(gfxColorComp1 - rgb.b);
+ k = c;
+ if (m < k) {
+ k = m;
+ }
+ if (y < k) {
+ k = y;
+ }
+ cmyk->c = c - k;
+ cmyk->m = m - k;
+ cmyk->y = y - k;
+ cmyk->k = k;
}
void GfxCalGrayColorSpace::getDefaultColor(GfxColor *color) {
@@ -553,47 +876,112 @@ GfxColorSpace *GfxCalRGBColorSpace::pars
}
obj2.free();
obj1.free();
+
+ cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX +
+ xyzrgb[0][1] * cs->whiteY +
+ xyzrgb[0][2] * cs->whiteZ);
+ cs->kg = 1 / (xyzrgb[1][0] * cs->whiteX +
+ xyzrgb[1][1] * cs->whiteY +
+ xyzrgb[1][2] * cs->whiteZ);
+ cs->kb = 1 / (xyzrgb[2][0] * cs->whiteX +
+ xyzrgb[2][1] * cs->whiteY +
+ xyzrgb[2][2] * cs->whiteZ);
+
return cs;
}
-void GfxCalRGBColorSpace::getGray(GfxColor *color, GfxGray *gray) {
- *gray = clip01((GfxColorComp)(0.299 * color->c[0] +
- 0.587 * color->c[1] +
- 0.114 * color->c[2] + 0.5));
+// convert CalRGB to XYZ color space
+void GfxCalRGBColorSpace::getXYZ(GfxColor *color,
+ double *pX, double *pY, double *pZ) {
+ double A, B, C;
+
+ A = colToDbl(color->c[0]);
+ B = colToDbl(color->c[1]);
+ C = colToDbl(color->c[2]);
+ *pX = mat[0]*pow(A,gammaR)+mat[3]*pow(B,gammaG)+mat[6]*pow(C,gammaB);
+ *pY = mat[1]*pow(A,gammaR)+mat[4]*pow(B,gammaG)+mat[7]*pow(C,gammaB);
+ *pZ = mat[2]*pow(A,gammaR)+mat[5]*pow(B,gammaG)+mat[8]*pow(C,gammaB);
}
-void GfxCalRGBColorSpace::getGrayLine(Guchar *in, Guchar *out, int length) {
- int i;
+void GfxCalRGBColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+ GfxRGB rgb;
- for (i = 0; i < length; i++) {
- out[i] =
- (in[i * 3 + 0] * 19595 +
- in[i * 3 + 1] * 38469 +
- in[i * 3 + 2] * 7472) / 65536;
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) {
+ double out[gfxColorMaxComps];
+ double in[gfxColorMaxComps];
+ double X, Y, Z;
+
+ getXYZ(color,&X,&Y,&Z);
+ in[0] = clip01(X);
+ in[1] = clip01(Y);
+ in[2] = clip01(Z);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ *gray = dblToCol(out[0]);
+ return;
}
+#endif
+ getRGB(color, &rgb);
+ *gray = clip01((GfxColorComp)(0.299 * rgb.r +
+ 0.587 * rgb.g +
+ 0.114 * rgb.b + 0.5));
}
void GfxCalRGBColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
- rgb->r = clip01(color->c[0]);
- rgb->g = clip01(color->c[1]);
- rgb->b = clip01(color->c[2]);
-}
-
-void GfxCalRGBColorSpace::getRGBLine(Guchar *in, unsigned int *out,
- int length) {
- Guchar *p;
- int i;
+ double X, Y, Z;
+ double r, g, b;
- for (i = 0, p = in; i < length; i++, p += 3)
- out[i] = (p[0] << 16) | (p[1] << 8) | (p[2] << 0);
+ getXYZ(color,&X,&Y,&Z);
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_RGB) {
+ double out[gfxColorMaxComps];
+ double in[gfxColorMaxComps];
+
+ in[0] = clip01(X/whiteX);
+ in[1] = clip01(Y/whiteY);
+ in[2] = clip01(Z/whiteZ);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ rgb->r = dblToCol(out[0]);
+ rgb->g = dblToCol(out[1]);
+ rgb->b = dblToCol(out[2]);
+ return;
+ }
+#endif
+ // convert XYZ to RGB, including gamut mapping and gamma correction
+ r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
+ g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
+ b = xyzrgb[2][0] * X + xyzrgb[2][1] * Y + xyzrgb[2][2] * Z;
+ rgb->r = dblToCol(pow(clip01(r), 0.5));
+ rgb->g = dblToCol(pow(clip01(g), 0.5));
+ rgb->b = dblToCol(pow(clip01(b), 0.5));
}
void GfxCalRGBColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+ GfxRGB rgb;
GfxColorComp c, m, y, k;
- c = clip01(gfxColorComp1 - color->c[0]);
- m = clip01(gfxColorComp1 - color->c[1]);
- y = clip01(gfxColorComp1 - color->c[2]);
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_CMYK) {
+ double in[gfxColorMaxComps];
+ double out[gfxColorMaxComps];
+ double X, Y, Z;
+
+ getXYZ(color,&X,&Y,&Z);
+ in[0] = clip01(X);
+ in[1] = clip01(Y);
+ in[2] = clip01(Z);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ cmyk->c = dblToCol(out[0]);
+ cmyk->m = dblToCol(out[1]);
+ cmyk->y = dblToCol(out[2]);
+ cmyk->k = dblToCol(out[3]);
+ return;
+ }
+#endif
+ getRGB(color, &rgb);
+ c = clip01(gfxColorComp1 - rgb.r);
+ m = clip01(gfxColorComp1 - rgb.g);
+ y = clip01(gfxColorComp1 - rgb.b);
k = c;
if (m < k) {
k = m;
@@ -714,14 +1102,6 @@ void GfxDeviceCMYKColorSpace::getDefault
// GfxLabColorSpace
//------------------------------------------------------------------------
-// This is the inverse of MatrixLMN in Example 4.10 from the PostScript
-// Language Reference, Third Edition.
-static const double xyzrgb[3][3] = {
- { 3.240449, -1.537136, -0.498531 },
- { -0.969265, 1.876011, 0.041556 },
- { 0.055643, -0.204026, 1.057229 }
-};
-
GfxLabColorSpace::GfxLabColorSpace() {
whiteX = whiteY = whiteZ = 1;
blackX = blackY = blackZ = 0;
@@ -823,18 +1203,30 @@ GfxColorSpace *GfxLabColorSpace::parse(A
void GfxLabColorSpace::getGray(GfxColor *color, GfxGray *gray) {
GfxRGB rgb;
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_GRAY) {
+ double out[gfxColorMaxComps];
+ double in[gfxColorMaxComps];
+
+ getXYZ(color, &in[0], &in[1], &in[2]);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ *gray = dblToCol(out[0]);
+ return;
+ }
+#endif
getRGB(color, &rgb);
*gray = clip01((GfxColorComp)(0.299 * rgb.r +
0.587 * rgb.g +
0.114 * rgb.b + 0.5));
}
-void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+// convert L*a*b* to media XYZ color space
+// (not multiply by the white point)
+void GfxLabColorSpace::getXYZ(GfxColor *color,
+ double *pX, double *pY, double *pZ) {
double X, Y, Z;
double t1, t2;
- double r, g, b;
- // convert L*a*b* to CIE 1931 XYZ color space
t1 = (colToDbl(color->c[0]) + 16) / 116;
t2 = t1 + colToDbl(color->c[1]) / 500;
if (t2 >= (6.0 / 29.0)) {
@@ -842,21 +1234,45 @@ void GfxLabColorSpace::getRGB(GfxColor *
} else {
X = (108.0 / 841.0) * (t2 - (4.0 / 29.0));
}
- X *= whiteX;
if (t1 >= (6.0 / 29.0)) {
Y = t1 * t1 * t1;
} else {
Y = (108.0 / 841.0) * (t1 - (4.0 / 29.0));
}
- Y *= whiteY;
t2 = t1 - colToDbl(color->c[2]) / 200;
if (t2 >= (6.0 / 29.0)) {
Z = t2 * t2 * t2;
} else {
Z = (108.0 / 841.0) * (t2 - (4.0 / 29.0));
}
- Z *= whiteZ;
+ *pX = X;
+ *pY = Y;
+ *pZ = Z;
+}
+
+void GfxLabColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+ double X, Y, Z;
+ double r, g, b;
+ getXYZ(color, &X, &Y, &Z);
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_RGB) {
+ double out[gfxColorMaxComps];
+ double in[gfxColorMaxComps];
+
+ in[0] = clip01(X);
+ in[1] = clip01(Y);
+ in[2] = clip01(Z);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ rgb->r = dblToCol(out[0]);
+ rgb->g = dblToCol(out[1]);
+ rgb->b = dblToCol(out[2]);
+ return;
+ }
+#endif
+ X *= whiteX;
+ Y *= whiteY;
+ Z *= whiteZ;
// convert XYZ to RGB, including gamut mapping and gamma correction
r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
@@ -870,6 +1286,20 @@ void GfxLabColorSpace::getCMYK(GfxColor
GfxRGB rgb;
GfxColorComp c, m, y, k;
+#ifdef USE_CMS
+ if (XYZ2DisplayTransform != NULL && displayPixelType == PT_CMYK) {
+ double in[gfxColorMaxComps];
+ double out[gfxColorMaxComps];
+
+ getXYZ(color, &in[0], &in[1], &in[2]);
+ XYZ2DisplayTransform->doTransform(in,out,1);
+ cmyk->c = dblToCol(out[0]);
+ cmyk->m = dblToCol(out[1]);
+ cmyk->y = dblToCol(out[2]);
+ cmyk->k = dblToCol(out[3]);
+ return;
+ }
+#endif
getRGB(color, &rgb);
c = clip01(gfxColorComp1 - rgb.r);
m = clip01(gfxColorComp1 - rgb.g);
@@ -926,10 +1356,22 @@ GfxICCBasedColorSpace::GfxICCBasedColorS
iccProfileStream = *iccProfileStreamA;
rangeMin[0] = rangeMin[1] = rangeMin[2] = rangeMin[3] = 0;
rangeMax[0] = rangeMax[1] = rangeMax[2] = rangeMax[3] = 1;
+#ifdef USE_CMS
+ transform = NULL;
+ lineTransform = NULL;
+#endif
}
GfxICCBasedColorSpace::~GfxICCBasedColorSpace() {
delete alt;
+#ifdef USE_CMS
+ if (transform != NULL) {
+ if (transform->unref() == 0) delete transform;
+ }
+ if (lineTransform != NULL) {
+ if (lineTransform->unref() == 0) delete lineTransform;
+ }
+#endif
}
GfxColorSpace *GfxICCBasedColorSpace::copy() {
@@ -941,6 +1383,12 @@ GfxColorSpace *GfxICCBasedColorSpace::co
cs->rangeMin[i] = rangeMin[i];
cs->rangeMax[i] = rangeMax[i];
}
+#ifdef USE_CMS
+ cs->transform = transform;
+ if (transform != NULL) transform->ref();
+ cs->lineTransform = lineTransform;
+ if (lineTransform != NULL) lineTransform->ref();
+#endif
return cs;
}
@@ -961,6 +1409,12 @@ GfxColorSpace *GfxICCBasedColorSpace::pa
iccProfileStreamA.gen = 0;
}
obj1.free();
+#ifdef USE_CMS
+ // check cache
+ if (iccProfileStreamA.num > 0
+ && (cs = GfxICCBasedCache::lookup(iccProfileStreamA.num,
+ iccProfileStreamA.gen)) != NULL) return cs;
+#endif
arr->get(1, &obj1);
if (!obj1.isStream()) {
error(-1, "Bad ICCBased color space (stream)");
@@ -1015,24 +1469,167 @@ GfxColorSpace *GfxICCBasedColorSpace::pa
}
obj2.free();
obj1.free();
+
+#ifdef USE_CMS
+ arr->get(1, &obj1);
+ dict = obj1.streamGetDict();
+ Guchar *profBuf;
+ unsigned int bufSize;
+ Stream *iccStream = obj1.getStream();
+ int c;
+ unsigned int size = 0;
+
+ bufSize = 65536;
+ profBuf = (Guchar *)gmallocn(bufSize,1);
+ iccStream->reset();
+ while ((c = iccStream->getChar()) != EOF) {
+ if (bufSize <= size) {
+ bufSize += 65536;
+ profBuf = (Guchar *)greallocn(profBuf,bufSize,1);
+ }
+ profBuf[size++] = c;
+ }
+ cmsHPROFILE hp = cmsOpenProfileFromMem(profBuf,size);
+ gfree(profBuf);
+ if (hp == 0) {
+ error(-1, "read ICCBased color space profile error");
+ } else {
+ cmsHPROFILE dhp = displayProfile;
+ if (dhp == NULL) dhp = RGBProfile;
+ unsigned int cst = getCMSColorSpaceType(cmsGetColorSpace(hp));
+ unsigned int dNChannels = getCMSNChannels(cmsGetColorSpace(dhp));
+ unsigned int dcst = getCMSColorSpaceType(cmsGetColorSpace(dhp));
+ cmsHTRANSFORM transform;
+ if ((transform = cmsCreateTransform(hp,
+ COLORSPACE_SH(cst) |CHANNELS_SH(nCompsA) | BYTES_SH(0),
+ dhp,
+ COLORSPACE_SH(dcst) |
+ CHANNELS_SH(dNChannels) | BYTES_SH(0),
+ INTENT_RELATIVE_COLORIMETRIC,0)) == 0) {
+ error(-1, "Can't create transform");
+ }
+ cs->transform = new GfxColorTransform(transform);
+ if (dcst == PT_RGB) {
+ // 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) {
+ error(-1, "Can't create transform");
+ }
+ cs->lineTransform = new GfxColorTransform(transform);
+ }
+ cmsCloseProfile(hp);
+ }
+ obj1.free();
+ // put this colorSpace into cache
+ if (iccProfileStreamA.num > 0) {
+ GfxICCBasedCache::put(iccProfileStreamA.num,iccProfileStreamA.gen,cs);
+ }
+#endif
return cs;
}
void GfxICCBasedColorSpace::getGray(GfxColor *color, GfxGray *gray) {
+#ifdef USE_CMS
+ if (transform != 0 && displayPixelType == PT_GRAY) {
+ double in[gfxColorMaxComps];
+ double out[gfxColorMaxComps];
+
+ for (int i = 0;i < nComps;i++) {
+ in[i] = colToDbl(color->c[i]);
+ }
+ transform->doTransform(in,out,1);
+ *gray = dblToCol(out[0]);
+ } else {
+ GfxRGB rgb;
+ getRGB(color,&rgb);
+ *gray = clip01((GfxColorComp)(0.3 * rgb.r +
+ 0.59 * rgb.g +
+ 0.11 * rgb.b + 0.5));
+ }
+#else
alt->getGray(color, gray);
+#endif
}
void GfxICCBasedColorSpace::getRGB(GfxColor *color, GfxRGB *rgb) {
+#ifdef USE_CMS
+ if (transform != 0
+ && (displayProfile == NULL || displayPixelType == PT_RGB)) {
+ double in[gfxColorMaxComps];
+ double out[gfxColorMaxComps];
+
+ for (int i = 0;i < nComps;i++) {
+ in[i] = colToDbl(color->c[i]);
+ }
+ transform->doTransform(in,out,1);
+ rgb->r = dblToCol(out[0]);
+ rgb->g = dblToCol(out[1]);
+ rgb->b = dblToCol(out[2]);
+ } else {
+ alt->getRGB(color, rgb);
+ }
+#else
alt->getRGB(color, rgb);
+#endif
}
void GfxICCBasedColorSpace::getRGBLine(Guchar *in, unsigned int *out,
int length) {
+#ifdef USE_CMS
+ if (lineTransform != 0) {
+ for (int i = 0;i < length;i++) {
+ Guchar tmp[gfxColorMaxComps];
+
+ lineTransform->doTransform(in,tmp,1);
+ in += nComps;
+ out[i] = (tmp[0] << 16) | (tmp[1] << 8) | tmp[2];
+ }
+ } else {
+ alt->getRGBLine(in, out, length);
+ }
+#else
alt->getRGBLine(in, out, length);
+#endif
}
void GfxICCBasedColorSpace::getCMYK(GfxColor *color, GfxCMYK *cmyk) {
+#ifdef USE_CMS
+ if (transform != NULL && displayPixelType == PT_CMYK) {
+ double in[gfxColorMaxComps];
+ double out[gfxColorMaxComps];
+
+ for (int i = 0;i < nComps;i++) {
+ in[i] = colToDbl(color->c[i]);
+ }
+ transform->doTransform(in,out,1);
+ cmyk->c = dblToCol(out[0]);
+ cmyk->m = dblToCol(out[1]);
+ cmyk->y = dblToCol(out[2]);
+ cmyk->k = dblToCol(out[3]);
+ } else {
+ GfxRGB rgb;
+ GfxColorComp c, m, y, k;
+
+ getRGB(color,&rgb);
+ c = clip01(gfxColorComp1 - rgb.r);
+ m = clip01(gfxColorComp1 - rgb.g);
+ y = clip01(gfxColorComp1 - rgb.b);
+ k = c;
+ if (m < k) {
+ k = m;
+ }
+ if (y < k) {
+ k = y;
+ }
+ cmyk->c = c - k;
+ cmyk->m = m - k;
+ cmyk->y = y - k;
+ cmyk->k = k;
+ }
+#else
alt->getCMYK(color, cmyk);
+#endif
}
void GfxICCBasedColorSpace::getDefaultColor(GfxColor *color) {
@@ -1066,6 +1663,56 @@ void GfxICCBasedColorSpace::getDefaultRa
#endif
}
+#ifdef USE_CMS
+GfxICCBasedCache
+ GfxICCBasedCache::cache[GFX_ICCBASED_CACHE_SIZE];
+
+GfxICCBasedCache::GfxICCBasedCache()
+{
+ num = 0;
+ gen = 0;
+ colorSpace = 0;
+}
+
+GfxICCBasedColorSpace *GfxICCBasedCache::lookup(int numA, int genA)
+{
+ int i;
+
+ if (cache[0].num == numA && cache[0].gen == genA) {
+ return (GfxICCBasedColorSpace *)cache[0].colorSpace->copy();
+ }
+ for (i = 1;i < GFX_ICCBASED_CACHE_SIZE && cache[i].num > 0;i++) {
+ if (cache[i].num == numA && cache[i].gen == genA) {
+ int j;
+ GfxICCBasedCache hit = cache[i];
+
+ for (j = i;j > 0;j--) {
+ if (cache[j - 1].num > 0) cache[j] = cache[j-1];
+ }
+ cache[0] = hit;
+ return (GfxICCBasedColorSpace *)hit.colorSpace->copy();
+ }
+ }
+ return NULL;
+}
+
+void GfxICCBasedCache::put(int numA, int genA,
+ GfxICCBasedColorSpace *cs)
+{
+ int i;
+
+ if (cache[GFX_ICCBASED_CACHE_SIZE-1].num > 0) {
+ delete cache[GFX_ICCBASED_CACHE_SIZE-1].colorSpace;
+ }
+ for (i = GFX_ICCBASED_CACHE_SIZE; i > 0; i--) {
+ if (cache[i - 1].num > 0) cache[i] = cache[i - 1];
+ }
+ cache[0].num = numA;
+ cache[0].gen = genA;
+ cache[0].colorSpace = (GfxICCBasedColorSpace *)cs->copy();
+}
+#endif
+
//------------------------------------------------------------------------
// GfxIndexedColorSpace
//------------------------------------------------------------------------
@@ -3938,6 +4585,9 @@ GfxState::GfxState(double hDPIA, double
clipYMax = pageHeight;
saved = NULL;
+#ifdef USE_CMS
+ GfxColorSpace::setupColorProfiles();
+#endif
}
GfxState::~GfxState() {

View file

@ -0,0 +1,156 @@
$NetBSD: patch-cb,v 1.1 2009/02/12 20:55:07 drochner Exp $
--- poppler/GfxState.h.orig 2009-01-20 16:54:29.000000000 +0100
+++ poppler/GfxState.h
@@ -32,6 +32,9 @@
#include "goo/gtypes.h"
#include "Object.h"
#include "Function.h"
+#ifdef USE_CMS
+#include "lcms.h"
+#endif
class Array;
class GfxFont;
@@ -151,6 +154,37 @@ enum GfxColorSpaceMode {
csPattern
};
+#ifdef USE_CMS
+
+#define COLOR_PROFILE_DIR "/ColorProfiles/"
+#define GLOBAL_COLOR_PROFILE_DIR POPPLER_DATADIR COLOR_PROFILE_DIR
+
+// wrapper of cmsHTRANSFORM to copy
+class GfxColorTransform {
+public:
+ void doTransform(void *in, void *out, unsigned int size) {
+ cmsDoTransform(transform, in, out, size);
+ }
+ GfxColorTransform(cmsHTRANSFORM transformA) {
+ transform = transformA;
+ refCount = 1;
+ }
+ ~GfxColorTransform() {
+ cmsDeleteTransform(transform);
+ }
+ void ref() {
+ refCount++;
+ }
+ unsigned int unref() {
+ return --refCount;
+ }
+private:
+ GfxColorTransform() {}
+ cmsHTRANSFORM transform;
+ unsigned int refCount;
+};
+#endif
+
class GfxColorSpace {
public:
@@ -191,6 +225,32 @@ public:
static char *getColorSpaceModeName(int idx);
private:
+#ifdef USE_CMS
+protected:
+ static cmsHPROFILE RGBProfile;
+ static GooString *displayProfileName; // display profile file Name
+ static cmsHPROFILE displayProfile; // display profile
+ static unsigned int displayPixelType;
+ static GfxColorTransform *XYZ2DisplayTransform;
+ // convert color space signature to cmsColor type
+ static unsigned int getCMSColorSpaceType(icColorSpaceSignature cs);
+ static unsigned int getCMSNChannels(icColorSpaceSignature cs);
+ static cmsHPROFILE loadColorProfile(const char *fileName);
+public:
+ static int setupColorProfiles();
+ static void setDisplayProfile(cmsHPROFILE displayProfileA) {
+ displayProfile = displayProfileA;
+ }
+ static void setDisplayProfileName(GooString *name) {
+ displayProfileName = name->copy();
+ }
+ static cmsHPROFILE getRGBProfile() {
+ return RGBProfile;
+ }
+ static cmsHPROFILE getDisplayProfile() {
+ return displayProfile;
+ }
+#endif
};
//------------------------------------------------------------------------
@@ -235,8 +295,6 @@ public:
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
- virtual void getGrayLine(Guchar *in, Guchar *out, int length);
- virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
virtual int getNComps() { return 1; }
virtual void getDefaultColor(GfxColor *color);
@@ -255,6 +313,8 @@ private:
double whiteX, whiteY, whiteZ; // white point
double blackX, blackY, blackZ; // black point
double gamma; // gamma value
+ double kr, kg, kb; // gamut mapping mulitpliers
+ void getXYZ(GfxColor *color, double *pX, double *pY, double *pZ);
};
//------------------------------------------------------------------------
@@ -299,8 +359,6 @@ public:
virtual void getGray(GfxColor *color, GfxGray *gray);
virtual void getRGB(GfxColor *color, GfxRGB *rgb);
virtual void getCMYK(GfxColor *color, GfxCMYK *cmyk);
- virtual void getGrayLine(Guchar *in, Guchar *out, int length);
- virtual void getRGBLine(Guchar *in, unsigned int *out, int length);
virtual int getNComps() { return 3; }
virtual void getDefaultColor(GfxColor *color);
@@ -323,6 +381,8 @@ private:
double blackX, blackY, blackZ; // black point
double gammaR, gammaG, gammaB; // gamma values
double mat[9]; // ABC -> XYZ transform matrix
+ double kr, kg, kb; // gamut mapping mulitpliers
+ void getXYZ(GfxColor *color, double *pX, double *pY, double *pZ);
};
//------------------------------------------------------------------------
@@ -390,6 +450,7 @@ private:
double blackX, blackY, blackZ; // black point
double aMin, aMax, bMin, bMax; // range for the a and b components
double kr, kg, kb; // gamut mapping mulitpliers
+ void getXYZ(GfxColor *color, double *pX, double *pY, double *pZ);
};
//------------------------------------------------------------------------
@@ -429,7 +490,26 @@ private:
double rangeMin[4]; // min values for each component
double rangeMax[4]; // max values for each component
Ref iccProfileStream; // the ICC profile
+#ifdef USE_CMS
+ GfxColorTransform *transform;
+ GfxColorTransform *lineTransform; // color transform for line
+#endif
+};
+
+#ifdef USE_CMS
+#define GFX_ICCBASED_CACHE_SIZE 5
+class GfxICCBasedCache {
+public:
+ static GfxICCBasedColorSpace *lookup(int numA, int genA);
+ static void put(int numA, int genA, GfxICCBasedColorSpace *cs);
+private:
+ GfxICCBasedCache();
+ int num;
+ int gen;
+ GfxICCBasedColorSpace *colorSpace;
+ static GfxICCBasedCache cache[GFX_ICCBASED_CACHE_SIZE];
};
+#endif
//------------------------------------------------------------------------
// GfxIndexedColorSpace