diff --git a/manual/luatex-modifications.tex b/manual/luatex-modifications.tex index af2c693632bdf0d9fed3256cae4e7e22f9245f2c..ee9a51de6e7b635706b5eb1774ef7c9251e48385 100644 --- a/manual/luatex-modifications.tex +++ b/manual/luatex-modifications.tex @@ -1082,8 +1082,7 @@ difference. Watch your spaces. \NC \NC \NR \HL } - -\starttabulate[|l|pT(0pt)|w(5em)|pT(0pt)|p|] +\starttabulate[|l|Tp(0pt)|w(5em)|Tp(0pt)|p|] \HL \BC \type{\breakafterdirmode} \BC \type{0} diff --git a/manual/luatex-tex.tex b/manual/luatex-tex.tex index 4e8418d55b41bcf968ad4d71d06f8318ad189d9e..250c2cbe6a501f6dcb233de7e3039fae7ffbaf49 100644 --- a/manual/luatex-tex.tex +++ b/manual/luatex-tex.tex @@ -225,10 +225,13 @@ is a \type {glue_spec} node btu when you pass \type {false} as last argument to \type {tex.get} you get the width of the glue and when you pass \type {true} you get all five values. Otherwise you get a node which is a copy of the internal value so you are responsible for its freeing at the \LUA\ end. When you set a -glue quantity you can either pass a \type {glue_spec} or upto five numbers. +glue quantity you can either pass a \type {glue_spec} or upto five numbers. If +you pass \type {true} to \type {get} you get 5 values returned for a glue and +when you pass \type {false} you only get the width returned. For the registers you can use \type {getskip} (node), \type {getglue} (numbers) -\type {setskip} (node) and \type {setglue} (numbers). +\type {setskip} (node) and \type {setglue} (numbers). If you pass \type {false} +as second argument to \type {getglue} you only get the width returned. There are also dedicated setters, getters and checkers: @@ -776,13 +779,14 @@ called xforms in \PDF). You can (re)use the box with \type {\useboxresource} or by creating a rule node with subtype~2. \starttyping -local index = tex.saveboxresource(n,attributes,resources,immediate,type) +local index = tex.saveboxresource(n,attributes,resources,immediate,type,margin) \stoptyping The optional second and third arguments are strings, the fourth is a boolean. The fifth argument is a type. When set to non|-|zero the \type {/Type} entry is omitted. A value of 1 or 3 still writes a \type {/BBox}, while 2 or 3 will write -a \type {/Matrix}. +a \type {/Matrix}. The sixth argument is the (virtual) margin that extends beyond +the effective boundingbox as seen by \TEX. You can generate the reference (a rule type) with: @@ -795,9 +799,11 @@ following is just a bonus (no dimensions returned means that the resource is unknown): \starttyping -local w, h, d = tex.getboxresourcedimensions(n) +local w, h, d, m = tex.getboxresourcedimensions(n) \stoptyping +This returns the width, height, depth and margin of the resource. + You can split a box: \starttyping diff --git a/manual/luatex.pdf b/manual/luatex.pdf index 39b903d44be1cf025df4fae9b4046b97837fc2f4..5dc9ebba2e091d48a3acff0e2210c7490700da7a 100644 Binary files a/manual/luatex.pdf and b/manual/luatex.pdf differ diff --git a/manual/luatex.tex b/manual/luatex.tex index 68f88ed08d9ab3eb953f94536ce51a0c0f89758d..4a9489865ea766fea97696072d0c0a0b2b33b5ac 100644 --- a/manual/luatex.tex +++ b/manual/luatex.tex @@ -45,7 +45,7 @@ \startdocument [status=beta, - version=1.06.1] + version=1.06.2] \startnotmode[*export] \component luatex-titlepage diff --git a/source/libs/poppler/ChangeLog b/source/libs/poppler/ChangeLog index 02dd81b55b52efb6fcd9bd05ffe719ba08be67dc..5faeaf54d6360f127355c0e262b7c8a96b72b4e0 100644 --- a/source/libs/poppler/ChangeLog +++ b/source/libs/poppler/ChangeLog @@ -1,3 +1,11 @@ +2017-10-04 Luigi Scarso <luigi.scarso@gmail.com> + + Import poppler-0.60.0. + * version.ac: Adjust. + * manually created poppler-config.h.in from poppler-config.h.cmake + * deleted useless files from splash folder + + 2017-02-17 Akira Kakuto <kakuto@fuk.kindai.ac.jp> Import poppler-0.52.0. diff --git a/source/libs/poppler/Makefile.am b/source/libs/poppler/Makefile.am index 627f70c5da58321f3a0f95c6846b19c3ef14be92..c145329ee89726459418b5bf1850eb92ee8960fb 100644 --- a/source/libs/poppler/Makefile.am +++ b/source/libs/poppler/Makefile.am @@ -41,17 +41,22 @@ nodist_libpoppler_a_SOURCES = \ $(poppler_libpoppler_a_sources) goo_libGoo_a_sources = \ + @POPPLER_TREE@/goo/FixedPoint.cc \ + @POPPLER_TREE@/goo/GooHash.cc \ + @POPPLER_TREE@/goo/GooList.cc \ + @POPPLER_TREE@/goo/GooString.cc \ + @POPPLER_TREE@/goo/GooTimer.cc \ + @POPPLER_TREE@/goo/ImgWriter.cc \ + @POPPLER_TREE@/goo/JpegWriter.cc \ + @POPPLER_TREE@/goo/NetPBMWriter.cc \ + @POPPLER_TREE@/goo/PNGWriter.cc \ + @POPPLER_TREE@/goo/TiffWriter.cc \ @POPPLER_TREE@/goo/gfile.cc \ @POPPLER_TREE@/goo/glibc.cc \ @POPPLER_TREE@/goo/gmem.cc \ @POPPLER_TREE@/goo/gmempp.cc \ @POPPLER_TREE@/goo/grandom.cc \ - @POPPLER_TREE@/goo/gstrtod.cc \ - @POPPLER_TREE@/goo/FixedPoint.cc \ - @POPPLER_TREE@/goo/GooHash.cc \ - @POPPLER_TREE@/goo/GooList.cc \ - @POPPLER_TREE@/goo/GooString.cc \ - @POPPLER_TREE@/goo/GooTimer.cc + @POPPLER_TREE@/goo/gstrtod.cc fofi_libfofi_a_sources = \ @POPPLER_TREE@/fofi/FoFiBase.cc \ @@ -59,9 +64,7 @@ fofi_libfofi_a_sources = \ @POPPLER_TREE@/fofi/FoFiIdentifier.cc \ @POPPLER_TREE@/fofi/FoFiTrueType.cc \ @POPPLER_TREE@/fofi/FoFiType1.cc \ - @POPPLER_TREE@/fofi/FoFiType1C.cc - - + @POPPLER_TREE@/fofi/FoFiType1C.cc poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/Annot.cc \ @@ -77,6 +80,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/Dict.cc \ @POPPLER_TREE@/poppler/Error.cc \ @POPPLER_TREE@/poppler/FileSpec.cc \ + @POPPLER_TREE@/poppler/FlateEncoder.cc \ @POPPLER_TREE@/poppler/FlateStream.cc \ @POPPLER_TREE@/poppler/FontEncodingTables.cc \ @POPPLER_TREE@/poppler/FontInfo.cc \ @@ -93,6 +97,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/Lexer.cc \ @POPPLER_TREE@/poppler/Linearization.cc \ @POPPLER_TREE@/poppler/Link.cc \ + @POPPLER_TREE@/poppler/LocalPDFDocBuilder.cc \ @POPPLER_TREE@/poppler/MarkedContentOutputDev.cc \ @POPPLER_TREE@/poppler/Movie.cc \ @POPPLER_TREE@/poppler/NameToCharCode.cc \ @@ -103,6 +108,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/PDFDoc.cc \ @POPPLER_TREE@/poppler/PDFDocEncoding.cc \ @POPPLER_TREE@/poppler/PDFDocFactory.cc \ + @POPPLER_TREE@/poppler/PSOutputDev.cc \ @POPPLER_TREE@/poppler/PSTokenizer.cc \ @POPPLER_TREE@/poppler/Page.cc \ @POPPLER_TREE@/poppler/PageLabelInfo.cc \ @@ -125,8 +131,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/UnicodeTypeTable.cc \ @POPPLER_TREE@/poppler/ViewerPreferences.cc \ @POPPLER_TREE@/poppler/XRef.cc \ - @POPPLER_TREE@/poppler/XpdfPluginAPI.cc \ - @POPPLER_TREE@/poppler/strtok_r.cpp + @POPPLER_TREE@/poppler/XpdfPluginAPI.cc $(libpoppler_a_OBJECTS): config.force diff --git a/source/libs/poppler/Makefile.in b/source/libs/poppler/Makefile.in index b32e442d3905a3de1d521c67191739d942ca1d98..ebb0426b2acc5b7499a28b93f08493f4179b7a25 100644 --- a/source/libs/poppler/Makefile.in +++ b/source/libs/poppler/Makefile.in @@ -114,17 +114,22 @@ am__v_AR_1 = libpoppler_a_AR = $(AR) $(ARFLAGS) libpoppler_a_LIBADD = am__dirstamp = $(am__leading_dot)dirstamp -am__objects_1 = @POPPLER_TREE@/goo/gfile.$(OBJEXT) \ +am__objects_1 = @POPPLER_TREE@/goo/FixedPoint.$(OBJEXT) \ + @POPPLER_TREE@/goo/GooHash.$(OBJEXT) \ + @POPPLER_TREE@/goo/GooList.$(OBJEXT) \ + @POPPLER_TREE@/goo/GooString.$(OBJEXT) \ + @POPPLER_TREE@/goo/GooTimer.$(OBJEXT) \ + @POPPLER_TREE@/goo/ImgWriter.$(OBJEXT) \ + @POPPLER_TREE@/goo/JpegWriter.$(OBJEXT) \ + @POPPLER_TREE@/goo/NetPBMWriter.$(OBJEXT) \ + @POPPLER_TREE@/goo/PNGWriter.$(OBJEXT) \ + @POPPLER_TREE@/goo/TiffWriter.$(OBJEXT) \ + @POPPLER_TREE@/goo/gfile.$(OBJEXT) \ @POPPLER_TREE@/goo/glibc.$(OBJEXT) \ @POPPLER_TREE@/goo/gmem.$(OBJEXT) \ @POPPLER_TREE@/goo/gmempp.$(OBJEXT) \ @POPPLER_TREE@/goo/grandom.$(OBJEXT) \ - @POPPLER_TREE@/goo/gstrtod.$(OBJEXT) \ - @POPPLER_TREE@/goo/FixedPoint.$(OBJEXT) \ - @POPPLER_TREE@/goo/GooHash.$(OBJEXT) \ - @POPPLER_TREE@/goo/GooList.$(OBJEXT) \ - @POPPLER_TREE@/goo/GooString.$(OBJEXT) \ - @POPPLER_TREE@/goo/GooTimer.$(OBJEXT) + @POPPLER_TREE@/goo/gstrtod.$(OBJEXT) am__objects_2 = @POPPLER_TREE@/fofi/FoFiBase.$(OBJEXT) \ @POPPLER_TREE@/fofi/FoFiEncodings.$(OBJEXT) \ @POPPLER_TREE@/fofi/FoFiIdentifier.$(OBJEXT) \ @@ -144,6 +149,7 @@ am__objects_3 = @POPPLER_TREE@/poppler/Annot.$(OBJEXT) \ @POPPLER_TREE@/poppler/Dict.$(OBJEXT) \ @POPPLER_TREE@/poppler/Error.$(OBJEXT) \ @POPPLER_TREE@/poppler/FileSpec.$(OBJEXT) \ + @POPPLER_TREE@/poppler/FlateEncoder.$(OBJEXT) \ @POPPLER_TREE@/poppler/FlateStream.$(OBJEXT) \ @POPPLER_TREE@/poppler/FontEncodingTables.$(OBJEXT) \ @POPPLER_TREE@/poppler/FontInfo.$(OBJEXT) \ @@ -160,6 +166,7 @@ am__objects_3 = @POPPLER_TREE@/poppler/Annot.$(OBJEXT) \ @POPPLER_TREE@/poppler/Lexer.$(OBJEXT) \ @POPPLER_TREE@/poppler/Linearization.$(OBJEXT) \ @POPPLER_TREE@/poppler/Link.$(OBJEXT) \ + @POPPLER_TREE@/poppler/LocalPDFDocBuilder.$(OBJEXT) \ @POPPLER_TREE@/poppler/MarkedContentOutputDev.$(OBJEXT) \ @POPPLER_TREE@/poppler/Movie.$(OBJEXT) \ @POPPLER_TREE@/poppler/NameToCharCode.$(OBJEXT) \ @@ -170,6 +177,7 @@ am__objects_3 = @POPPLER_TREE@/poppler/Annot.$(OBJEXT) \ @POPPLER_TREE@/poppler/PDFDoc.$(OBJEXT) \ @POPPLER_TREE@/poppler/PDFDocEncoding.$(OBJEXT) \ @POPPLER_TREE@/poppler/PDFDocFactory.$(OBJEXT) \ + @POPPLER_TREE@/poppler/PSOutputDev.$(OBJEXT) \ @POPPLER_TREE@/poppler/PSTokenizer.$(OBJEXT) \ @POPPLER_TREE@/poppler/Page.$(OBJEXT) \ @POPPLER_TREE@/poppler/PageLabelInfo.$(OBJEXT) \ @@ -192,8 +200,7 @@ am__objects_3 = @POPPLER_TREE@/poppler/Annot.$(OBJEXT) \ @POPPLER_TREE@/poppler/UnicodeTypeTable.$(OBJEXT) \ @POPPLER_TREE@/poppler/ViewerPreferences.$(OBJEXT) \ @POPPLER_TREE@/poppler/XRef.$(OBJEXT) \ - @POPPLER_TREE@/poppler/XpdfPluginAPI.$(OBJEXT) \ - @POPPLER_TREE@/poppler/strtok_r.$(OBJEXT) + @POPPLER_TREE@/poppler/XpdfPluginAPI.$(OBJEXT) nodist_libpoppler_a_OBJECTS = $(am__objects_1) $(am__objects_2) \ $(am__objects_3) libpoppler_a_OBJECTS = $(nodist_libpoppler_a_OBJECTS) @@ -452,17 +459,22 @@ nodist_libpoppler_a_SOURCES = \ $(poppler_libpoppler_a_sources) goo_libGoo_a_sources = \ + @POPPLER_TREE@/goo/FixedPoint.cc \ + @POPPLER_TREE@/goo/GooHash.cc \ + @POPPLER_TREE@/goo/GooList.cc \ + @POPPLER_TREE@/goo/GooString.cc \ + @POPPLER_TREE@/goo/GooTimer.cc \ + @POPPLER_TREE@/goo/ImgWriter.cc \ + @POPPLER_TREE@/goo/JpegWriter.cc \ + @POPPLER_TREE@/goo/NetPBMWriter.cc \ + @POPPLER_TREE@/goo/PNGWriter.cc \ + @POPPLER_TREE@/goo/TiffWriter.cc \ @POPPLER_TREE@/goo/gfile.cc \ @POPPLER_TREE@/goo/glibc.cc \ @POPPLER_TREE@/goo/gmem.cc \ @POPPLER_TREE@/goo/gmempp.cc \ @POPPLER_TREE@/goo/grandom.cc \ - @POPPLER_TREE@/goo/gstrtod.cc \ - @POPPLER_TREE@/goo/FixedPoint.cc \ - @POPPLER_TREE@/goo/GooHash.cc \ - @POPPLER_TREE@/goo/GooList.cc \ - @POPPLER_TREE@/goo/GooString.cc \ - @POPPLER_TREE@/goo/GooTimer.cc + @POPPLER_TREE@/goo/gstrtod.cc fofi_libfofi_a_sources = \ @POPPLER_TREE@/fofi/FoFiBase.cc \ @@ -470,7 +482,7 @@ fofi_libfofi_a_sources = \ @POPPLER_TREE@/fofi/FoFiIdentifier.cc \ @POPPLER_TREE@/fofi/FoFiTrueType.cc \ @POPPLER_TREE@/fofi/FoFiType1.cc \ - @POPPLER_TREE@/fofi/FoFiType1C.cc + @POPPLER_TREE@/fofi/FoFiType1C.cc poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/Annot.cc \ @@ -486,6 +498,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/Dict.cc \ @POPPLER_TREE@/poppler/Error.cc \ @POPPLER_TREE@/poppler/FileSpec.cc \ + @POPPLER_TREE@/poppler/FlateEncoder.cc \ @POPPLER_TREE@/poppler/FlateStream.cc \ @POPPLER_TREE@/poppler/FontEncodingTables.cc \ @POPPLER_TREE@/poppler/FontInfo.cc \ @@ -502,6 +515,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/Lexer.cc \ @POPPLER_TREE@/poppler/Linearization.cc \ @POPPLER_TREE@/poppler/Link.cc \ + @POPPLER_TREE@/poppler/LocalPDFDocBuilder.cc \ @POPPLER_TREE@/poppler/MarkedContentOutputDev.cc \ @POPPLER_TREE@/poppler/Movie.cc \ @POPPLER_TREE@/poppler/NameToCharCode.cc \ @@ -512,6 +526,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/PDFDoc.cc \ @POPPLER_TREE@/poppler/PDFDocEncoding.cc \ @POPPLER_TREE@/poppler/PDFDocFactory.cc \ + @POPPLER_TREE@/poppler/PSOutputDev.cc \ @POPPLER_TREE@/poppler/PSTokenizer.cc \ @POPPLER_TREE@/poppler/Page.cc \ @POPPLER_TREE@/poppler/PageLabelInfo.cc \ @@ -534,8 +549,7 @@ poppler_libpoppler_a_sources = \ @POPPLER_TREE@/poppler/UnicodeTypeTable.cc \ @POPPLER_TREE@/poppler/ViewerPreferences.cc \ @POPPLER_TREE@/poppler/XRef.cc \ - @POPPLER_TREE@/poppler/XpdfPluginAPI.cc \ - @POPPLER_TREE@/poppler/strtok_r.cpp + @POPPLER_TREE@/poppler/XpdfPluginAPI.cc # Reconfig @@ -550,7 +564,7 @@ all: config.h poppler-config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: -.SUFFIXES: .cc .cpp .o .obj +.SUFFIXES: .cc .o .obj am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../am/dist_hook.am $(srcdir)/../../am/reconfig.am $(srcdir)/../../am/rebuild.am $(am__configure_deps) @@ -617,36 +631,51 @@ clean-noinstLIBRARIES: @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) @POPPLER_TREE@/goo/$(DEPDIR) @: > @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/gfile.$(OBJEXT): \ +@POPPLER_TREE@/goo/FixedPoint.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/glibc.$(OBJEXT): \ +@POPPLER_TREE@/goo/GooHash.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/gmem.$(OBJEXT): @POPPLER_TREE@/goo/$(am__dirstamp) \ +@POPPLER_TREE@/goo/GooList.$(OBJEXT): \ + @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/gmempp.$(OBJEXT): \ +@POPPLER_TREE@/goo/GooString.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/grandom.$(OBJEXT): \ +@POPPLER_TREE@/goo/GooTimer.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/gstrtod.$(OBJEXT): \ +@POPPLER_TREE@/goo/ImgWriter.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/FixedPoint.$(OBJEXT): \ +@POPPLER_TREE@/goo/JpegWriter.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/GooHash.$(OBJEXT): \ +@POPPLER_TREE@/goo/NetPBMWriter.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/GooList.$(OBJEXT): \ +@POPPLER_TREE@/goo/PNGWriter.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/GooString.$(OBJEXT): \ +@POPPLER_TREE@/goo/TiffWriter.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/goo/GooTimer.$(OBJEXT): \ +@POPPLER_TREE@/goo/gfile.$(OBJEXT): \ + @POPPLER_TREE@/goo/$(am__dirstamp) \ + @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/goo/glibc.$(OBJEXT): \ + @POPPLER_TREE@/goo/$(am__dirstamp) \ + @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/goo/gmem.$(OBJEXT): @POPPLER_TREE@/goo/$(am__dirstamp) \ + @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/goo/gmempp.$(OBJEXT): \ + @POPPLER_TREE@/goo/$(am__dirstamp) \ + @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/goo/grandom.$(OBJEXT): \ + @POPPLER_TREE@/goo/$(am__dirstamp) \ + @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/goo/gstrtod.$(OBJEXT): \ @POPPLER_TREE@/goo/$(am__dirstamp) \ @POPPLER_TREE@/goo/$(DEPDIR)/$(am__dirstamp) @POPPLER_TREE@/fofi/$(am__dirstamp): @@ -718,6 +747,9 @@ clean-noinstLIBRARIES: @POPPLER_TREE@/poppler/FileSpec.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/poppler/FlateEncoder.$(OBJEXT): \ + @POPPLER_TREE@/poppler/$(am__dirstamp) \ + @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) @POPPLER_TREE@/poppler/FlateStream.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) @@ -766,6 +798,9 @@ clean-noinstLIBRARIES: @POPPLER_TREE@/poppler/Link.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/poppler/LocalPDFDocBuilder.$(OBJEXT): \ + @POPPLER_TREE@/poppler/$(am__dirstamp) \ + @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) @POPPLER_TREE@/poppler/MarkedContentOutputDev.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) @@ -796,6 +831,9 @@ clean-noinstLIBRARIES: @POPPLER_TREE@/poppler/PDFDocFactory.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) +@POPPLER_TREE@/poppler/PSOutputDev.$(OBJEXT): \ + @POPPLER_TREE@/poppler/$(am__dirstamp) \ + @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) @POPPLER_TREE@/poppler/PSTokenizer.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) @@ -865,9 +903,6 @@ clean-noinstLIBRARIES: @POPPLER_TREE@/poppler/XpdfPluginAPI.$(OBJEXT): \ @POPPLER_TREE@/poppler/$(am__dirstamp) \ @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) -@POPPLER_TREE@/poppler/strtok_r.$(OBJEXT): \ - @POPPLER_TREE@/poppler/$(am__dirstamp) \ - @POPPLER_TREE@/poppler/$(DEPDIR)/$(am__dirstamp) libpoppler.a: $(libpoppler_a_OBJECTS) $(libpoppler_a_DEPENDENCIES) $(EXTRA_libpoppler_a_DEPENDENCIES) $(AM_V_at)-rm -f libpoppler.a @@ -894,6 +929,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/GooList.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/GooString.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/GooTimer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/ImgWriter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/JpegWriter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/NetPBMWriter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/PNGWriter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/TiffWriter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/gfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/glibc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/goo/$(DEPDIR)/gmem.Po@am__quote@ @@ -913,6 +953,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/Dict.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/Error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/FileSpec.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/FlateEncoder.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/FlateStream.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/FontEncodingTables.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/FontInfo.Po@am__quote@ @@ -929,6 +970,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/Lexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/Linearization.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/Link.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/LocalPDFDocBuilder.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/MarkedContentOutputDev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/Movie.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/NameToCharCode.Po@am__quote@ @@ -939,6 +981,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/PDFDoc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/PDFDocEncoding.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/PDFDocFactory.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/PSOutputDev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/PSTokenizer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/Page.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/PageLabelInfo.Po@am__quote@ @@ -962,7 +1005,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/ViewerPreferences.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/XRef.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/XpdfPluginAPI.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@@POPPLER_TREE@/poppler/$(DEPDIR)/strtok_r.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -980,22 +1022,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` -.cpp.o: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, diff --git a/source/libs/poppler/TLpatches/ChangeLog b/source/libs/poppler/TLpatches/ChangeLog index c11001c1006319b1d745e46362dc7d22b5851f85..8b900ff4d67fe56d2d3eb29eb5ef93b77666aab7 100644 --- a/source/libs/poppler/TLpatches/ChangeLog +++ b/source/libs/poppler/TLpatches/ChangeLog @@ -1,3 +1,10 @@ +2017-10-04 Luigi Scarso <luigi.scarso@gmail.com> + + Imported poppler-0.60.0 source tree from: + http://poppler.freedesktop.org/ + * patch-02-LLONG_MAX, patch-03-Object-functions: Adapted. + * removed all files but SplashTypes.h in the splash/ directory + 2017-09-25 Luigi Scarso <luigi.scarso@gmail.com> Imported poppler-0.59.0 source tree from: diff --git a/source/libs/poppler/TLpatches/TL-Changes b/source/libs/poppler/TLpatches/TL-Changes index 883eb5f752a5fe0b607f1d8c2fbc1a8269c0de55..9a1ab73cd2d9e671d0fece5ee600bf1ede51caaf 100644 --- a/source/libs/poppler/TLpatches/TL-Changes +++ b/source/libs/poppler/TLpatches/TL-Changes @@ -1,4 +1,4 @@ -Changes applied to the poppler-0.52.0 tree as obtained from: +Changes applied to the poppler-0.60.0 tree as obtained from: http://poppler.freedesktop.org/ Removed: diff --git a/source/libs/poppler/TLpatches/patch-03-Object-functions b/source/libs/poppler/TLpatches/patch-03-Object-functions index 9a5a411078dc29b3978c3acbc86086045253ffd0..03511d2af609baf0462b71fccddd190a640e1c9a 100644 --- a/source/libs/poppler/TLpatches/patch-03-Object-functions +++ b/source/libs/poppler/TLpatches/patch-03-Object-functions @@ -1,35 +1,33 @@ -diff -u Object.h.std Object.h ---- Object.h.std 2017-09-18 19:14:36.231203342 +0200 -+++ Object.h 2017-09-18 19:15:49.387200342 +0200 +--- Object.h.std 2017-10-02 23:29:21.000000000 +0200 ++++ Object.h 2017-10-03 10:13:36.496259318 +0200 @@ -207,7 +207,7 @@ - GBool isName(const char *nameA) + GBool isName(const char *nameA) const { return type == objName && !strcmp(cString, nameA); } - GBool isDict(const char *dictType); -- GBool isStream(char *dictType); -+ GBool isStream(const char *dictType); - GBool isCmd(const char *cmdA) + GBool isDict(const char *dictType) const; +- GBool isStream(char *dictType) const; ++ GBool isStream(const char *dictType) const; + GBool isCmd(const char *cmdA) const { return type == objCmd && !strcmp(cString, cmdA); } @@ -264,7 +264,7 @@ - Object dictGetValNF(int i); + Object dictGetValNF(int i) const; // Stream accessors. -- GBool streamIs(char *dictType); -+ GBool streamIs(const char *dictType); +- GBool streamIs(char *dictType) const; ++ GBool streamIs(const char *dictType) const; void streamReset(); void streamClose(); - int streamGetChar(); + int streamGetChar() const; @@ -379,10 +379,10 @@ #include "Stream.h" --inline GBool Object::streamIs(char *dictType) -+inline GBool Object::streamIs(const char *dictType) +-inline GBool Object::streamIs(char *dictType) const ++inline GBool Object::streamIs(const char *dictType) const { OBJECT_TYPE_CHECK(objStream); return stream->getDict()->is(dictType); } --inline GBool Object::isStream(char *dictType) -+inline GBool Object::isStream(const char *dictType) +-inline GBool Object::isStream(char *dictType) const ++inline GBool Object::isStream(const char *dictType) const { return type == objStream && streamIs(dictType); } inline void Object::streamReset() - diff --git a/source/libs/poppler/configure b/source/libs/poppler/configure index d8480aad6efba7f3b0da4c4abaa417a113f8ccef..4b6fd0880e61c4a30faae81acd44e0c997250107 100755 --- a/source/libs/poppler/configure +++ b/source/libs/poppler/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.59.0. +# Generated by GNU Autoconf 2.69 for poppler (TeX Live) 0.60.0. # # Report bugs to <tex-k@tug.org>. # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='poppler (TeX Live)' PACKAGE_TARNAME='poppler--tex-live-' -PACKAGE_VERSION='0.59.0' -PACKAGE_STRING='poppler (TeX Live) 0.59.0' +PACKAGE_VERSION='0.60.0' +PACKAGE_STRING='poppler (TeX Live) 0.60.0' PACKAGE_BUGREPORT='tex-k@tug.org' PACKAGE_URL='' @@ -1319,7 +1319,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures poppler (TeX Live) 0.59.0 to adapt to many kinds of systems. +\`configure' configures poppler (TeX Live) 0.60.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1387,7 +1387,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of poppler (TeX Live) 0.59.0:";; + short | recursive ) echo "Configuration of poppler (TeX Live) 0.60.0:";; esac cat <<\_ACEOF @@ -1502,7 +1502,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -poppler (TeX Live) configure 0.59.0 +poppler (TeX Live) configure 0.60.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2092,7 +2092,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by poppler (TeX Live) $as_me 0.59.0, which was +It was created by poppler (TeX Live) $as_me 0.60.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -4015,7 +4015,7 @@ fi # Define the identity of the package. PACKAGE='poppler--tex-live-' - VERSION='0.59.0' + VERSION='0.60.0' # Some tools Automake needs. @@ -6624,7 +6624,7 @@ ac_config_headers="$ac_config_headers poppler-config.h:poppler-src/poppler/poppl cat >>confdefs.h <<_ACEOF -#define POPPLER_VERSION "0.59.0" +#define POPPLER_VERSION "0.60.0" _ACEOF @@ -7318,7 +7318,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by poppler (TeX Live) $as_me 0.59.0, which was +This file was extended by poppler (TeX Live) $as_me 0.60.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7384,7 +7384,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -poppler (TeX Live) config.status 0.59.0 +poppler (TeX Live) config.status 0.60.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/source/libs/poppler/poppler-src/CMakeLists.txt b/source/libs/poppler/poppler-src/CMakeLists.txt index a5b0a5be52c603c3843793e9402c5b0c0c5273a6..887b0cc7fca54056f7fce4e30a166e61a7cac18b 100644 --- a/source/libs/poppler/poppler-src/CMakeLists.txt +++ b/source/libs/poppler/poppler-src/CMakeLists.txt @@ -38,20 +38,26 @@ option(BUILD_CPP_TESTS "Whether compile the CPP test programs." ON) option(ENABLE_SPLASH "Build the Splash graphics backend." ON) option(ENABLE_UTILS "Compile poppler command line utils." ON) option(ENABLE_CPP "Compile poppler cpp wrapper." ON) +option(ENABLE_GLIB "Compile poppler glib wrapper." ON) +option(ENABLE_GTK_DOC "Whether to generate glib API documentation." OFF) +option(ENABLE_QT4 "Compile poppler qt4 wrapper." ON) +option(ENABLE_QT5 "Compile poppler qt5 wrapper." ON) set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2, unmaintained, none. 'auto' prefers openjpeg2 over openjpeg1 if both are available. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no JPX decoder at all. Default: auto") set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available. Unset to disable color management system.") set(ENABLE_DCTDECODER "libjpeg" CACHE STRING "Use libjpeg for DCT streams. Possible values: libjpeg, unmaintained, none. will use libjpeg if available or fail if not. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no DCT decoder at all. Default: libjpeg") -option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF) +option(ENABLE_LIBCURL "Build libcurl based HTTP support." ON) option(ENABLE_ZLIB "Build with zlib." ON) option(ENABLE_ZLIB_UNCOMPRESS "Use zlib to uncompress flate streams (not totally safe)." OFF) option(SPLASH_CMYK "Include support for CMYK rasterization." OFF) option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF) option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF) +option(BUILD_SHARED_LIBS "Build poppler as a shared library" ON) if(WIN32) option(ENABLE_RELOCATABLE "Do not hardcode the poppler library location (on Windows)." ON) else() set(ENABLE_RELOCATABLE OFF) endif() +option(EXTRA_WARN "Enable extra compile warnings" OFF) set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "Share directory name") @@ -129,17 +135,24 @@ elseif(ENABLE_DCTDECODER STREQUAL "none") else() message(FATAL_ERROR "Invalid ENABLE_DCTDECODER value.") endif() -macro_optional_find_package(Qt4) -find_package(Qt5Core) -find_package(Qt5Gui) -find_package(Qt5Xml) -find_package(Qt5Widgets) -find_package(Qt5Test) -if (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Xml_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND) - set(QT5_FOUND true) -else () - message("-- Package Qt5Core or Qt5Gui or Qt5Xml or Qt5Widgets or Qt5Test not found") - set(QT5_FOUND false) + +if (ENABLE_QT4) + macro_optional_find_package(Qt4) + if (NOT QT4_FOUND) + set(ENABLE_QT4 OFF) + endif() +endif() + +if (ENABLE_QT5) + find_package(Qt5Core) + find_package(Qt5Gui) + find_package(Qt5Xml) + find_package(Qt5Widgets) + find_package(Qt5Test) + if (NOT (Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Xml_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND)) + message("-- Package Qt5Core or Qt5Gui or Qt5Xml or Qt5Widgets or Qt5Test not found") + set(ENABLE_QT5 OFF) + endif() endif() macro_optional_find_package(Cairo ${CAIRO_VERSION}) @@ -149,9 +162,13 @@ if(CAIRO_FOUND) set(CAIRO_REQ "cairo") set(POPPLER_GLIB_DISABLE_DEPRECATED "") set(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES "") - macro_optional_find_package(GLIB) - if(GLIB_FOUND) - set(ENABLE_GLIB ON) + if(ENABLE_GLIB) + macro_optional_find_package(GLIB) + if(NOT GLIB_FOUND) + set(ENABLE_GLIB OFF) + endif() + endif() + if(ENABLE_GLIB) # Check for introspection macro_optional_find_package(GObjectIntrospection 0.9.12) set(HAVE_INTROSPECTION ${INTROSPECTION_FOUND}) @@ -161,6 +178,7 @@ if(CAIRO_FOUND) endif() else() set(CAIRO_FEATURE "#undef POPPLER_HAS_CAIRO") + set(ENABLE_GLIB OFF) endif() if(ENABLE_CPP) macro_optional_find_package(Iconv) @@ -238,8 +256,12 @@ elseif(ENABLE_CMS STREQUAL "lcms2") endif() if(ENABLE_LIBCURL) find_package(CURL) - include_directories(${CURL_INCLUDE_DIR}) - set(POPPLER_HAS_CURL_SUPPORT ON) + if(CURL_FOUND) + include_directories(${CURL_INCLUDE_DIR}) + set(POPPLER_HAS_CURL_SUPPORT ON) + else() + set(ENABLE_LIBCURL OFF) + endif() endif() add_definitions(-DHAVE_CONFIG_H=1) @@ -319,21 +341,12 @@ if(NOT DEFINED POPPLER_DATADIR) set(POPPLER_DATADIR "${CMAKE_INSTALL_PREFIX}/share/poppler") endif() -if(DEFINED COMPILE_WARNINGS) -else() - set(COMPILE_WARNINGS "yes") -endif() -string(TOLOWER "${COMPILE_WARNINGS}" _comp_warnings) -if(_comp_warnings STREQUAL "no") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_NO} ${CMAKE_CXX_FLAGS}") -endif() -if(_comp_warnings STREQUAL "yes") +if(EXTRA_WARN) set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_YES} ${CMAKE_CXX_FLAGS}") -endif() -if(_comp_warnings STREQUAL "kde") + set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_EXTRA} ${CMAKE_CXX_FLAGS}") +else() set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_KDE} ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS} ${CMAKE_CXX_FLAGS}") endif() @@ -535,7 +548,7 @@ add_definitions(-D_CRT_SECURE_NO_WARNINGS) set(CMAKE_CXX_FLAGS "/Zc:wchar_t- ${CMAKE_CXX_FLAGS}") add_library(poppler STATIC ${poppler_SRCS}) else() -add_library(poppler SHARED ${poppler_SRCS}) +add_library(poppler ${poppler_SRCS}) endif() set_target_properties(poppler PROPERTIES VERSION 70.0.0 SOVERSION 70) target_link_libraries(poppler LINK_PRIVATE ${poppler_LIBS}) @@ -716,10 +729,10 @@ if(ENABLE_GLIB) add_subdirectory(glib) endif() add_subdirectory(test) -if(QT4_FOUND) +if(ENABLE_QT4) add_subdirectory(qt4) endif() -if(QT5_FOUND) +if(ENABLE_QT5) add_subdirectory(qt5) endif() if(ENABLE_CPP) @@ -743,10 +756,10 @@ poppler_create_install_pkgconfig(poppler.pc lib${LIB_SUFFIX}/pkgconfig) if(ENABLE_SPLASH) poppler_create_install_pkgconfig(poppler-splash.pc lib${LIB_SUFFIX}/pkgconfig) endif() -if(QT4_FOUND) +if(ENABLE_QT4) poppler_create_install_pkgconfig(poppler-qt4.pc lib${LIB_SUFFIX}/pkgconfig) endif() -if(QT5_FOUND) +if(ENABLE_QT5) poppler_create_install_pkgconfig(poppler-qt5.pc lib${LIB_SUFFIX}/pkgconfig) endif() if(ENABLE_GLIB) @@ -767,12 +780,12 @@ if(SPLASH_CMYK) message(" with CMYK support") endif() show_end_message_yesno("cairo output" CAIRO_FOUND) -show_end_message_yesno("qt4 wrapper" QT4_FOUND) -show_end_message_yesno("qt5 wrapper" QT5_FOUND) +show_end_message_yesno("qt4 wrapper" ENABLE_QT4) +show_end_message_yesno("qt5 wrapper" ENABLE_QT5) show_end_message_yesno("glib wrapper" ENABLE_GLIB) show_end_message_yesno(" introspection" INTROSPECTION_FOUND) +show_end_message_yesno(" gtk-doc" ENABLE_GTK_DOC) show_end_message_yesno("cpp wrapper" ENABLE_CPP) -show_end_message("use gtk-doc" "not supported with this CMake build system") show_end_message_yesno("use libjpeg" ENABLE_LIBJPEG) show_end_message_yesno("use libpng" ENABLE_LIBPNG) show_end_message_yesno("use libtiff" ENABLE_LIBTIFF) @@ -824,3 +837,13 @@ endif() if(NOT HAVE_JPX_DECODER) message("Warning: You're not compiling any JPX decoder. Some files will fail to display properly.") endif() + +set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${POPPLER_VERSION}) +add_custom_target(dist + COMMAND + COMMAND git log --stat | fmt --split-only > ${CMAKE_BINARY_DIR}/ChangeLog + COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar + COMMAND tar -C ${CMAKE_BINARY_DIR} -rf ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar ChangeLog --transform='s,,${ARCHIVE_NAME}/,' + COMMAND tar -C ${CMAKE_BINARY_DIR} -rf ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar glib/reference/html --transform='s,,${ARCHIVE_NAME}/,' + COMMAND xz -9 ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) diff --git a/source/libs/poppler/poppler-src/COPYING3 b/source/libs/poppler/poppler-src/COPYING3 new file mode 100644 index 0000000000000000000000000000000000000000..94a9ed024d3859793618152ea559a168bbcbb5e2 --- /dev/null +++ b/source/libs/poppler/poppler-src/COPYING3 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/source/libs/poppler/poppler-src/ChangeLog b/source/libs/poppler/poppler-src/ChangeLog index a0b4add845a0f8771f2068a743363d600ed9fcce..00799729a1c15a58702f4ea3494712fa3f6074f3 100644 --- a/source/libs/poppler/poppler-src/ChangeLog +++ b/source/libs/poppler/poppler-src/ChangeLog @@ -1,3 +1,861 @@ +commit 9432e0bfc4c4f2e16b7c152aa8b04d6d19ed4898 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 2 23:29:21 2017 +0200 + + Add missing (C) + + cpp/poppler-private.cpp | 1 + + fofi/FoFiTrueType.cc | 2 +- + goo/GooString.cc | 2 +- + goo/GooString.h | 2 +- + goo/JpegWriter.cc | 1 + + goo/gmem.h | 2 +- + poppler/CairoOutputDev.cc | 2 +- + poppler/CurlPDFDocBuilder.cc | 2 +- + poppler/Decrypt.cc | 2 +- + poppler/GfxState.h | 2 +- + poppler/GlobalParams.cc | 2 +- + poppler/PSOutputDev.cc | 2 +- + poppler/PSOutputDev.h | 2 +- + poppler/UnicodeMap.cc | 1 + + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-private.cc | 2 +- + qt5/src/poppler-link.cc | 2 +- + qt5/src/poppler-private.cc | 2 +- + qt5/src/poppler-qt5.h | 1 + + splash/Splash.cc | 2 +- + splash/SplashFTFontFile.cc | 1 + + splash/SplashFTFontFile.h | 1 + + utils/pdfseparate.cc | 2 +- + 23 files changed, 23 insertions(+), 17 deletions(-) + +commit da02d7c683f1788d38cccb3716edd1ba011cb94c +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Oct 2 23:05:59 2017 +0200 + + remove m4 gtk-doc.make and add comments to poppler-features.h.cmake + + glib/poppler-features.h.cmake | 55 ++++++++ + gtk-doc.make | 305 + ---------------------------------------- + m4/.gitignore | 5 - + m4/ax_pthread.m4 | 317 + ------------------------------------------ + m4/define-dir.m4 | 34 ----- + m4/gtk-doc.m4 | 88 ------------ + m4/iconv.m4 | 180 ------------------------ + m4/introspection.m4 | 94 ------------- + m4/libjpeg.m4 | 114 --------------- + 9 files changed, 55 insertions(+), 1137 deletions(-) + +commit f871b82edfd632f79ec7bdd0b4d560cd348d8b1a +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Sep 8 23:27:45 2017 +0200 + + qt5: ArthurOutputDev: Fix several small bugs related to dash pattern + handling + + qt5/src/ArthurOutputDev.cc | 21 ++++++++++++++++++++- + 1 file changed, 20 insertions(+), 1 deletion(-) + +commit 3ec5e86ca000653525650a99755c85e512a04bdc +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Sep 29 21:24:23 2017 +0200 + + qt5: ArthurOutputDev: Implement the drawSoftMaskedImage method + + qt5/src/ArthurOutputDev.cc | 67 + ++++++++++++++++++++++++++++++++++++++++++++++ + qt5/src/ArthurOutputDev.h | 9 +++++++ + 2 files changed, 76 insertions(+) + +commit 376ae2f8b8a92fd7bd751fbfcd0aa46530b59ca4 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 30 11:27:44 2017 +0200 + + Remove the gir-girs target + + It depends on the same files (subset) as the gir-typelibs target + meaning that sometimes when doing a parallel build you'd get the + two commands trying to generate the same file at once and bad + things happen + + cmake/modules/GObjectIntrospectionMacros.cmake | 1 - + 1 file changed, 1 deletion(-) + +commit 19eedc6fb693a62f305e13079501e3105f869f3c +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 30 11:12:31 2017 +0200 + + Fix crash in broken files + + Bug #103045 + + fofi/FoFiTrueType.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 5df4a8b0ad56b11c9be3b362e33810c5af57952b +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 26 23:49:41 2017 +0200 + + Enable libcurl support by default + + CMakeLists.txt | 10 +++++++--- + 1 file changed, 7 insertions(+), 3 deletions(-) + +commit 2c92c7b6a828c9db8a38f079ea7a3d51c12a481d +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 25 19:33:44 2017 +0200 + + Fix infinite recursion on broken files + + Bug #102969 + + poppler/Gfx.cc | 46 ++++++++++++++++++++++++++++++++++------------ + poppler/GfxState.cc | 33 ++++++++++++++++++--------------- + poppler/GfxState.h | 15 +++++++++------ + 3 files changed, 61 insertions(+), 33 deletions(-) + +commit d3f12611b30e6421f05603a9838ed9131b1aa61e +Author: Bernd Kuhls <berndkuhls@hotmail.com> +Date: Sun Sep 24 23:56:29 2017 +0200 + + include ctype.h for isdigit + + Bug #102951 + + poppler/Form.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit a1a4be92323ae45f1ecc16595438520309554eb0 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 24 13:21:58 2017 +0200 + + cairo: do not use the custom downscaling for rendering images when + using cairo >= 1.14 + + poppler/CairoOutputDev.cc | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +commit 3b64fc488e7ff10634aa2dd76ad4f152ebfe7edc +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 24 12:39:06 2017 +0200 + + regtest: change default value of utils dir to ../build/utils + + regtest/main.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit deba5f3c57929a96105d822c8cba46e5334694c7 +Author: Carlos Garcia Campos <carlosgc@gnome.org> +Date: Sun Sep 24 12:31:43 2017 +0200 + + cairo: Do not extend the pattern in drawImageMaskRegular + + This is causing some documents with tiling patterns to take ages + to render, + since we switched to use drawImageMaskRegular in 00a536a4. This patch + applies the same changes made in 7d8dfb09 and db87dc7f for + drawImageMaskPrescaled to drawImageMaskRegular. + + poppler/CairoOutputDev.cc | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +commit cceb80b353ca748d1e04373d238195fd548319b8 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Sun Sep 24 08:24:44 2017 +0200 + + glib: Make g-ir-scanner always link to the libs in build directory + + It was using the installed libraries, causing a build failure when + there's new API added to the poppler core. + + glib/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 2afde7084ab55893182c2da59c429b48eb5d5a35 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:54 2017 +0200 + + Remove GlobalParams::splashResolution + + Noone was setting or getting the variable + + poppler/GlobalParams.h | 1 - + 1 file changed, 1 deletion(-) + +commit df783c5d10490e94e911316a6f42bb2d91a22dea +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:50 2017 +0200 + + Add a const to the static structure + + poppler/GlobalParamsWin.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit a309cbfdd831b37461284b95763ca5a872e6af2b +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:46 2017 +0200 + + Remove GlobalParams::setPSFile + + It had a setter but not a getter so wasn't used for anything + + poppler/GlobalParams.cc | 13 ------------- + poppler/GlobalParams.h | 2 -- + 2 files changed, 15 deletions(-) + +commit 7af5f7cadbdb89e0eaab148940c2c65cb12cc6d6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:42 2017 +0200 + + Remove GlobalParams::ccFontFiles + + it was never filled so it was basically a noop + + poppler/GfxFont.cc | 10 ---------- + poppler/GlobalParams.cc | 14 -------------- + poppler/GlobalParams.h | 3 --- + 3 files changed, 27 deletions(-) + +commit b5f8be7ede64e55d44ed484797a66ca068ba955f +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:39 2017 +0200 + + Remove GlobalParams::fontDirs + + It was only read but never filled so it was basically a noop + + poppler/GlobalParams.cc | 31 +------------------------------ + poppler/GlobalParams.h | 1 - + 2 files changed, 1 insertion(+), 31 deletions(-) + +commit 3463537624a24e3bdcaa42c135d337c6cd452ea5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 22 18:18:22 2017 +0200 + + Remove GlobalParams::getPSResidentFont* + + There was no way to set its contents so it's basically a noop + + poppler/GfxFont.cc | 38 ---------------------- + poppler/GlobalParams.cc | 85 + ------------------------------------------------- + poppler/GlobalParams.h | 29 ----------------- + poppler/PSOutputDev.cc | 6 ---- + 4 files changed, 158 deletions(-) + +commit 851bc59c6f4b007333d064af5c6992702b92cdf6 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 21 20:45:52 2017 +0200 + + Remove the autotools based build system + + .gitignore | 20 +- + INSTALL | 244 ++------ + INSTALL.cmake | 76 --- + Makefile.am | 133 ----- + autogen.sh | 117 ---- + configure.ac | 1154 + -------------------------------------- + cpp/Makefile.am | 74 --- + cpp/tests/Makefile.am | 21 - + fofi/Makefile.am | 28 - + glib/Makefile.am | 122 ---- + glib/demo/Makefile.am | 56 -- + glib/poppler-features.h.in | 88 --- + glib/reference/Makefile.am | 92 --- + glib/reference/version.xml.in | 1 - + goo/Makefile.am | 69 --- + poppler-cairo-uninstalled.pc.in | 6 - + poppler-cairo.pc.in | 9 - + poppler-cpp-uninstalled.pc.in | 7 - + poppler-cpp.pc.in | 13 - + poppler-glib-uninstalled.pc.in | 7 - + poppler-glib.pc.in | 13 - + poppler-qt4-uninstalled.pc.in | 7 - + poppler-qt4.pc.in | 13 - + poppler-qt5-uninstalled.pc.in | 7 - + poppler-qt5.pc.in | 13 - + poppler-splash-uninstalled.pc.in | 7 - + poppler-splash.pc.in | 9 - + poppler-uninstalled.pc.in | 6 - + poppler.pc.in | 11 - + poppler/Makefile.am | 348 ------------ + poppler/poppler-config.h.in | 196 ------- + qt4/Makefile.am | 1 - + qt4/demos/Makefile.am | 65 --- + qt4/src/Makefile.am | 76 --- + qt4/tests/Makefile.am | 141 ----- + qt5/Makefile.am | 1 - + qt5/demos/Makefile.am | 65 --- + qt5/src/Makefile.am | 78 --- + qt5/tests/Makefile.am | 141 ----- + splash/Makefile.am | 73 --- + test/Makefile.am | 67 --- + utils/Makefile.am | 155 ----- + 42 files changed, 43 insertions(+), 3787 deletions(-) + +commit 1a33f60da2996ea64c1b903580885697940cf046 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 21 20:32:25 2017 +0200 + + Add some constness to the basic classes + + goo/GooString.cc | 2 +- + goo/GooString.h | 2 +- + poppler/Array.cc | 8 +-- + poppler/Array.h | 12 ++--- + poppler/Dict.cc | 18 +++---- + poppler/Dict.h | 26 +++++----- + poppler/Object.cc | 4 +- + poppler/Object.h | 152 + +++++++++++++++++++++++++++--------------------------- + 8 files changed, 112 insertions(+), 112 deletions(-) + +commit 135843fa8398364e0559c2b0b96f9be4a44572c5 +Author: Carlos Garcia Campos <cgarcia@igalia.com> +Date: Wed Sep 20 19:38:14 2017 +0200 + + Add gtk-doc support to CMake build + + CMakeLists.txt | 4 +- + glib/CMakeLists.txt | 4 + + glib/reference/CMakeLists.txt | 12 ++ + gtkdoc.py | 440 + ++++++++++++++++++++++++++++++++++++++++++ + make-glib-api-docs | 66 +++++++ + 5 files changed, 525 insertions(+), 1 deletion(-) + +commit e51db61a33cdbe6307f048b65912a85f6cd1ec5b +Author: William Bader <william@newspapersystems.com> +Date: Wed Sep 20 19:36:46 2017 +0200 + + PSOutputDev: Fix wrong text generation + + This patch moves the code to update the max valid glyph hash into its + own function and updates the max valid glyph only if the new value is + higher than the previous value. + This fixes a problem with pages that have multiple copies of the same + font with different glyph counts. If poppler processed the font + with the + smaller count last, and then the PDF wrote text in the font with the + larger count, pdftops would not show the glyphs above the maximum + of the + smaller font. + + Bug #102760 + + poppler/PSOutputDev.cc | 16 ++++++++++------ + poppler/PSOutputDev.h | 1 + + 2 files changed, 11 insertions(+), 6 deletions(-) + +commit 6665839b5ce2e4f6fb2acc682ce2f91ed2404ce8 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 20 19:36:29 2017 +0200 + + qt5: The tests don't need GUI + + qt5/tests/check_actualtext.cpp | 2 +- + qt5/tests/check_attachments.cpp | 2 +- + qt5/tests/check_dateConversion.cpp | 2 +- + qt5/tests/check_fonts.cpp | 2 +- + qt5/tests/check_goostring.cpp | 2 +- + qt5/tests/check_lexer.cpp | 2 +- + qt5/tests/check_links.cpp | 2 +- + qt5/tests/check_metadata.cpp | 2 +- + qt5/tests/check_optcontent.cpp | 2 +- + qt5/tests/check_pagelabelinfo.cpp | 2 +- + qt5/tests/check_pagelayout.cpp | 2 +- + qt5/tests/check_pagemode.cpp | 2 +- + qt5/tests/check_password.cpp | 2 +- + qt5/tests/check_permissions.cpp | 2 +- + qt5/tests/check_search.cpp | 2 +- + qt5/tests/check_strings.cpp | 2 +- + 16 files changed, 16 insertions(+), 16 deletions(-) + +commit 26a067d4a84f80eeb892e30a5ab608d0fbea1de5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 20 10:36:04 2017 +0200 + + Remove the moc includes + + Some people are having trouble with them and automoc really should + be taking care of this so no need to have the include. Let's hope this + doesn't break some other people :D + + qt5/demos/abstractinfodock.cpp | 1 - + qt5/demos/embeddedfiles.cpp | 1 - + qt5/demos/fonts.cpp | 1 - + qt5/demos/info.cpp | 1 - + qt5/demos/metadata.cpp | 1 - + qt5/demos/navigationtoolbar.cpp | 1 - + qt5/demos/optcontent.cpp | 1 - + qt5/demos/pageview.cpp | 1 - + qt5/demos/permissions.cpp | 1 - + qt5/demos/thumbnails.cpp | 1 - + qt5/demos/toc.cpp | 1 - + qt5/demos/viewer.cpp | 1 - + qt5/src/poppler-optcontent.cc | 1 - + 13 files changed, 13 deletions(-) + +commit 939465c40902d72e0c05d4f3a27ee67e4a007ed7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 19 21:19:03 2017 +0200 + + Fix crash in broken files + + Bug #102854 + + poppler/Stream.cc | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit a8aa61f774503c9ebd840e148c4fa31a6959600d +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 19 21:17:49 2017 +0200 + + autotools: Fix build + + qt5/src/Makefile.am | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 6b82904b717994c887f33bfc72e4999363fc8e72 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 17 23:03:48 2017 +0200 + + Fix printf-like format warnings + + poppler/Stream.h | 2 +- + test/perf-test.cc | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +commit b26924e32128b7ba57260e9fdc54be1893bcff77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 17 02:06:32 2017 +0200 + + A few more static markers + + test/perf-test.cc | 2 +- + utils/pdftocairo-win32.cc | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit 4a4e291246f238731429729e10633ee1f627eb77 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 17 01:58:36 2017 +0200 + + Make newer gcc happy about fallthrough + + on HtmlOutputDev.cc fixes a leak when printHtml is false + + fofi/FoFiTrueType.cc | 2 ++ + poppler/Annot.cc | 4 ++-- + poppler/SplashOutputDev.cc | 8 ++++++++ + splash/Splash.cc | 2 ++ + utils/HtmlOutputDev.cc | 9 ++++----- + 5 files changed, 18 insertions(+), 7 deletions(-) + +commit 0790dd3afb8370aebca8e7e154bbd2b5ae5cd5a2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 18:01:49 2017 +0200 + + Fix missing-declarations warnings + + ... and add it to default warning set + + cmake/modules/PopplerMacros.cmake | 2 +- + cpp/tests/poppler-dump.cpp | 2 +- + glib/poppler-action.cc | 1 + + goo/JpegWriter.cc | 2 +- + goo/gmem.h | 2 +- + poppler/Annot.cc | 6 ++-- + poppler/Decrypt.cc | 2 +- + poppler/TextOutputDev.cc | 2 +- + qt4/src/poppler-link.cc | 2 +- + qt4/src/poppler-private.cc | 6 ++-- + qt4/tests/check_links.cpp | 4 +-- + qt4/tests/poppler-forms.cpp | 14 ++++----- + qt5/src/poppler-link.cc | 2 +- + qt5/src/poppler-private.cc | 6 ++-- + qt5/tests/check_links.cpp | 4 +-- + qt5/tests/poppler-forms.cpp | 18 ++++++------ + test/perf-test-preview-dummy.cc | 4 +++ + test/perf-test.cc | 62 + +++++++++++++++++++-------------------- + utils/pdfinfo.cc | 4 +-- + utils/pdfseparate.cc | 2 +- + utils/pdfsig.cc | 6 ++-- + utils/pdftotext.cc | 2 +- + utils/pdfunite.cc | 6 ++-- + 23 files changed, 83 insertions(+), 78 deletions(-) + +commit afd91b148d3d0ba025821740ff4c075b1de2fdc5 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 17:47:42 2017 +0200 + + Fix warning: format ‘%x’ expects argument of type ‘unsigned + int*’, but argument 3 has type ‘int*’ + + poppler/UnicodeMap.cc | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit a0ed20f3fb8025706ad9a580f6a692316bf6df66 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 17:45:42 2017 +0200 + + -Woverflow fixes + + cpp/poppler-private.cpp | 4 ++-- + glib/poppler-document.cc | 3 +-- + goo/GooString.cc | 6 ++++++ + goo/GooString.h | 1 + + poppler/Annot.cc | 9 +++------ + poppler/Form.cc | 13 +++++-------- + qt4/src/poppler-private.cc | 4 ++-- + qt5/src/poppler-private.cc | 4 ++-- + 8 files changed, 22 insertions(+), 22 deletions(-) + +commit d51cc34d7d51b6ddb7bfba318ed12bcbe763be6a +Author: Albert Astals Cid <aacid@kde.org> +Date: Sat Sep 16 17:35:15 2017 +0200 + + -pedantic fixes + + glib/poppler-media.cc | 2 +- + glib/poppler-movie.cc | 2 +- + glib/poppler-structure-element.cc | 2 +- + goo/glibc.h | 2 +- + poppler/StructElement.cc | 14 +++++++------- + utils/JSInfo.cc | 2 +- + 6 files changed, 12 insertions(+), 12 deletions(-) + +commit 804a823a67fedc3e633e89f817232d3c15715b56 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Sat Sep 16 20:16:58 2017 +0930 + + cmake: restructure the warnings into a "default" and "extra" group + + Most of the previous warnings are now in default. Extra warnings that + should be fixed but currently result in a lot of warnings are in the + extra group. + + The old no/yes/kde COMPILE_WARNINGS option has been replaced with the + boolean option EXTRA_WARN (default off) to enable the extra warnings. + + CMakeLists.txt | 18 +++++------------- + cmake/modules/PopplerMacros.cmake | 32 ++++++++++++++++++++++++-------- + 2 files changed, 29 insertions(+), 21 deletions(-) + +commit 6d40d4bad46ce1b53624feca7410b35e4fe0048d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 15 01:07:59 2017 +0200 + + CurlPDFDocBuilder don't crash if given a url that doesn't exist + + poppler/CurlPDFDocBuilder.cc | 6 ++++++ + 1 file changed, 6 insertions(+) + +commit cc43c720e857548175a9e35b0686a1a7a8957f50 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Aug 18 11:51:06 2017 +0200 + + Replace Splash font rendering by Qt font rendering + + Previously, the Arthur backend would use Splash code to do + its font rendering. That was not a satisfactory solution: + Qt can do font rendering directly. Also, the Splash font + rendering in the Arthur code had a few bugs, which lead + to legible-but-not-pretty fonts. + + This patch replaces the Splash font rendering by Qt font + rendering. Some Splash code will have to remain, because + Qt seems unable to do the proper charcode-to-glyph-index + transformations. + + I took a lot of inspiration from Mihai Niculescu's patch at + + https://lists.freedesktop.org/archives/poppler/2013-June/010370.html + + That's why the patch adds Mihai's name in the copyright list. + + qt5/src/ArthurOutputDev.cc | 254 + +++++++++++++++++++++++++-------------------- + qt5/src/ArthurOutputDev.h | 31 +++++- + splash/SplashFTFontFile.cc | 4 + + splash/SplashFTFontFile.h | 3 + + 4 files changed, 177 insertions(+), 115 deletions(-) + +commit da63c35549e8852a410946ab016a3f25ac701bdf +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 14 19:14:41 2017 +0200 + + FoFiType1C::convertToType0: Fix crash in broken files + + Bug #102724 + + fofi/FoFiType1C.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 504b3590182175390f474657a372e78fb1508262 +Author: Albert Astals Cid <aacid@kde.org> +Date: Thu Sep 14 19:14:23 2017 +0200 + + Splash::scaleImage: Do not try to scale if srcHeight or srcWidth + are < 1 + + Bug #102719 + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 500ce88a3b5b0bd556ac6941ba66a86cae44663a +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Wed Sep 13 12:12:29 2017 +0200 + + Fix two minor typos + + qt5/tests/test-render-to-file.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 80f9819b6233f9f9b5fd44f0e4cad026e5d048c2 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 13 23:09:45 2017 +0200 + + isImageInterpolationRequired: Fix divide by 0 on broken documents + + Bug #102688 + + splash/Splash.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit aaf5327649e8f7371c9d3270e7813c43ddfd47ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 13 23:01:03 2017 +0200 + + Gfx::doShowText: Fix infinite recursion on broken files + + Bug #102701 + + poppler/Gfx.cc | 25 +++++++++++++++++++++++-- + poppler/Gfx.h | 1 + + poppler/GfxFont.cc | 8 ++++++++ + poppler/GfxFont.h | 1 + + 4 files changed, 33 insertions(+), 2 deletions(-) + +commit 476394e7a025e02e4897da2e765df2c895d0708f +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 13 22:58:14 2017 +0200 + + XRef::parseEntry: Fix crash in broken file + + Bug #102687 + + poppler/XRef.cc | 3 +++ + 1 file changed, 3 insertions(+) + +commit 0f891b85169dabd3d23348aba40266547bd4bcf6 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Sep 13 20:12:52 2017 +0930 + + pdfinfo: don't truncate dest name + + utils/pdfinfo.cc | 1 - + 1 file changed, 1 deletion(-) + +commit 951e7b3c1f337ceaf490edce3c575f89c45cb6d4 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Wed Sep 13 19:24:07 2017 +0930 + + cmake: ensure user cflags/cxxflags are appended to end + + cmake/modules/PopplerMacros.cmake | 44 + +++++++++++++++++++++------------------ + 1 file changed, 24 insertions(+), 20 deletions(-) + +commit a5c616a65a77bf597836cced6f987e5b93480ca5 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Mon Sep 11 20:55:01 2017 +0930 + + cmake INSTALL file + + INSTALL.cmake | 76 + +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 76 insertions(+) + +commit a5e5649ecf16fa05770620dbbd4985935dc2bbff +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 11 12:35:16 2017 +0200 + + Fix crash in FoFiType1C::convertToType0 in broken files + + Bug #102653 + + fofi/FoFiType1C.cc | 435 + +++++++++++++++++++++++++++-------------------------- + 1 file changed, 220 insertions(+), 215 deletions(-) + +commit 325887ebef8ea1c6ef9d3607a59d95ffea383986 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 10 17:41:47 2017 +0200 + + Make JBIG2Stream::readGenericBitmap return cleanly on error + + instead of causing abort + + Also fixes warning when compiled with newer gcc + + poppler/JBIG2Stream.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit f253a28f4c5bb65c363d31b8b46f984c660499ee +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 19:05:36 2017 +0200 + + qt5: in development -> is stable + + The API itself is done-ish even if it gets improvements from time to + time. In development seems to imply "don't use me yet" + + qt5/src/Mainpage.dox | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1316c7a41f4dd7276f404f775ebb5fef2d24ab1c +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:29:42 2017 +0200 + + Annot: Fix crash on broken files + + Bug #102607 + + poppler/Annot.cc | 42 +++++++++++++++++++++++------------------- + 1 file changed, 23 insertions(+), 19 deletions(-) + +commit 2532df6060092e9fab7f041ae9598aff9cdd94bb +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:28:15 2017 +0200 + + Annot: Fix crash on broken files + + Bug #102601 + + poppler/Annot.cc | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 6472d8493f7e82cc78b41da20a2bf19fcb4e0a7d +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:26:05 2017 +0200 + + SplashOutputDev: Fix crash on broken files + + Bug #102604 + + poppler/SplashOutputDev.cc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 3ab44e2a77b560198c1e1616cfb39c1ac7374e29 +Author: Albert Astals Cid <aacid@kde.org> +Date: Fri Sep 8 18:21:40 2017 +0200 + + Remove unmaintained TODO file + + TODO | 40 ---------------------------------------- + 1 file changed, 40 deletions(-) + +commit dfcf997e6fbca31dbe051fbd9c32aca818825e38 +Author: Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +Date: Wed Sep 6 11:03:52 2017 +0200 + + Added methods to get and set the font size of text fields + + Fixes bug #101692 + + poppler/Annot.cc | 24 +++---------- + poppler/Form.cc | 92 + +++++++++++++++++++++++++++++++++++++++++++++++++ + poppler/Form.h | 16 +++++++++ + qt5/src/poppler-form.cc | 12 ++++++- + qt5/src/poppler-form.h | 10 ++++++ + 5 files changed, 134 insertions(+), 20 deletions(-) + +commit 0bda8bb8eda838316a61238441665abfd24eb020 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Thu Sep 7 19:55:54 2017 +0200 + + Disable glib if cairo is not found + + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) + +commit 118cd73a3c4eba78bbfed16cfc2996dec5491944 +Author: Albert Astals Cid <aacid@kde.org> +Date: Wed Sep 6 19:42:26 2017 +0200 + + cmake: Give people the option to build poppler as a static library + + CMakeLists.txt | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit 766a32ff59dadd9ae4639d8a79861a17be6aec52 +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Sep 5 20:55:45 2017 +0930 + + cmake: add options to disable glib/qt4/qt5 + + CMakeLists.txt | 54 + ++++++++++++++++++++++++++++++++++-------------------- + 1 file changed, 34 insertions(+), 20 deletions(-) + +commit 101aba9a8d6623bca419946262fea6b46a790454 +Author: Albert Astals Cid <aacid@kde.org> +Date: Tue Sep 5 19:34:12 2017 +0200 + + cmake: Fix build when using a cairo different than the system one + + glib/demo/CMakeLists.txt | 2 +- + test/CMakeLists.txt | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 1d3f00e8c53dbbd3a8409993b7b66667df434b5d +Author: Adrian Johnson <ajohnson@redneon.com> +Date: Tue Sep 5 06:39:49 2017 +0930 + + ignore build directory + + .gitignore | 1 + + 1 file changed, 1 insertion(+) + +commit 340a99f580b9f7b6add831e9a0252574bfea66f2 +Author: Oliver Sander <oliver.sander@tu-dresden.de> +Date: Fri Sep 1 22:16:49 2017 +0200 + + Control whether renderToImage shows annotations + + I'd like to control whether the renderToImage and renderToPainter + methods show annotations or not. To this end, this patch introduces + a new value 'HideAnnotations' to the Document::RenderHint enum. + + qt5/src/poppler-page.cc | 36 ++++++++++++++++++++++++++++++++++-- + qt5/src/poppler-qt5.h | 3 ++- + 2 files changed, 36 insertions(+), 3 deletions(-) + +commit dd80c182cbcb188af0dd590f222ba9bbb31e3fb7 +Author: Albert Astals Cid <aacid@kde.org> +Date: Mon Sep 4 19:36:06 2017 +0200 + + Fix building with old clang + + poppler/StructElement.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit a22cd0badbc177f8a2eedb0386895ddf3379c618 +Author: Albert Astals Cid <aacid@kde.org> +Date: Sun Sep 3 23:35:08 2017 +0200 + + Initial make dist support in cmake + + .gitattributes | 5 +++++ + CMakeLists.txt | 9 +++++++++ + 2 files changed, 14 insertions(+) + commit 85bfedad416906b1a5dff377d470387692b5ca70 Author: Albert Astals Cid <aacid@kde.org> Date: Sun Sep 3 22:54:32 2017 +0200 diff --git a/source/libs/poppler/poppler-src/INSTALL b/source/libs/poppler/poppler-src/INSTALL index 56b077d6a0b8773b014bd4381cc09abb17fff351..7b5d65856995ab56dc1c866ea146cce12da48bea 100644 --- a/source/libs/poppler/poppler-src/INSTALL +++ b/source/libs/poppler/poppler-src/INSTALL @@ -1,236 +1,76 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free -Software Foundation, Inc. - -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - Basic Installation ================== -These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - -You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - -By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PREFIX'. +mkdir build +cd build +cmake .. +make +make install - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PREFIX', the package will -use PREFIX as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. +CMake configuration options can be set using the -D option. eg - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= + cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=release -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. +Build Options +============= -Specifying the System Type -========================== +Set install prefix: -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: + -DCMAKE_INSTALL_PREFIX=<path> - CPU-COMPANY-SYSTEM +Set build type. This sets the standard compiler flags for the build +type. -where SYSTEM can have one of these forms: + -DCMAKE_BUILD_TYPE=debug or -DCMAKE_BUILD_TYPE=release - OS KERNEL-OS +Set compiler flags: - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. + -DCMAKE_CXX_FLAGS=<flags> or set CXXFLAGS environment variable - If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will -produce code for. +Set linker flags: - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. + -DCMAKE_LD_FLAGS=<flags> or set LDFLAGS environment variable -Sharing Defaults -================ -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc +Optional Features +================= -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). Here is a another example: + -D<FEATURE>=<ON|OFF> - /bin/bash ./configure CONFIG_SHELL=/bin/bash +eg -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. + -DENABLE_SPLASH=ON -DBUILD_GTK_TESTS=OFF -`configure' Invocation -====================== +A list of all options can be display with the commmand: -`configure' recognizes the following options to control how it operates. + egrep '^ *(option|set.*STRING)' CMakeLists.txt -`--help' -`-h' - Print a summary of the options to `configure', and exit. +Alternatively, the options can be edited by running "ccmake ." in the +build directory. -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. +Cross Compiling +=============== -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. +A toolchain file is required to specify the target specific compiler +tools. Run cmake with the option: -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). + -DCMAKE_TOOLCHAIN_FILE=<Toolchain file> -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. +A sample toolchain for a 64-bit mingw build is shown below. Replace +/path/to/win/root with the install prefix for the target environment. -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. + SET(CMAKE_SYSTEM_NAME Windows) + SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) + SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /path/to/win/root ) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/source/libs/poppler/poppler-src/Makefile.am b/source/libs/poppler/poppler-src/Makefile.am deleted file mode 100644 index bf878bad43e63c48d4ee7015a6ba5c5ae2a949de..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/Makefile.am +++ /dev/null @@ -1,133 +0,0 @@ -ACLOCAL_AMFLAGS = -I m4 -DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --with-testdatadir=$(TESTDATADIR) - -if BUILD_SPLASH_OUTPUT -splash_subdir = splash -splash_pc_file = poppler-splash.pc -endif - -if BUILD_CAIRO_OUTPUT -cairo_pc_file = poppler-cairo.pc -endif - -if BUILD_POPPLER_GLIB -glib_subdir = glib -glib_pc_file = poppler-glib.pc -endif - -if BUILD_POPPLER_QT5 -qt5_subdir = qt5 -qt5_pc_file = poppler-qt5.pc -endif - -if BUILD_POPPLER_QT4 -qt4_subdir = qt4 -qt4_pc_file = poppler-qt4.pc -endif - - -if BUILD_POPPLER_CPP -cpp_subdir = cpp -cpp_pc_file = poppler-cpp.pc -endif - -SUBDIRS = goo fofi $(splash_subdir) poppler utils $(glib_subdir) test $(qt4_subdir) $(qt5_subdir) $(cpp_subdir) - -EXTRA_DIST = \ - README-XPDF \ - poppler.pc.in \ - poppler-uninstalled.pc.in \ - poppler-cairo.pc.in \ - poppler-cairo-uninstalled.pc.in \ - poppler-splash.pc.in \ - poppler-splash-uninstalled.pc.in \ - poppler-qt4.pc.in \ - poppler-qt4-uninstalled.pc.in \ - poppler-qt5.pc.in \ - poppler-qt5-uninstalled.pc.in \ - poppler-cpp.pc.in \ - poppler-cpp-uninstalled.pc.in - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = \ - poppler.pc \ - $(cairo_pc_file) \ - $(splash_pc_file) \ - $(glib_pc_file) \ - $(qt4_pc_file) \ - $(qt5_pc_file) \ - $(cpp_pc_file) - -# Add CMake buildsystem files here so they get added on make dist -EXTRA_DIST += \ - cpp/tests/CMakeLists.txt \ - cpp/CMakeLists.txt \ - glib/demo/CMakeLists.txt \ - glib/CMakeLists.txt \ - glib/poppler-features.h.cmake \ - qt4/src/CMakeLists.txt \ - qt4/tests/CMakeLists.txt \ - qt4/CMakeLists.txt \ - qt4/demos/CMakeLists.txt \ - qt5/src/CMakeLists.txt \ - qt5/tests/CMakeLists.txt \ - qt5/CMakeLists.txt \ - qt5/demos/CMakeLists.txt \ - test/CMakeLists.txt \ - utils/CMakeLists.txt \ - CMakeLists.txt \ - ConfigureChecks.cmake \ - cmake/modules/CheckFileOffsetBits.c \ - cmake/modules/CheckFileOffsetBits.cmake \ - cmake/modules/COPYING-CMAKE-SCRIPTS \ - cmake/modules/FindCairo.cmake \ - cmake/modules/FindFontconfig.cmake \ - cmake/modules/FindGLIB.cmake \ - cmake/modules/FindGObjectIntrospection.cmake \ - cmake/modules/FindGTK.cmake \ - cmake/modules/FindIconv.cmake \ - cmake/modules/FindLCMS.cmake \ - cmake/modules/FindLCMS2.cmake \ - cmake/modules/FindNSS3.cmake \ - cmake/modules/FindQt4.cmake \ - cmake/modules/GObjectIntrospectionMacros.cmake \ - cmake/modules/MacroBoolTo01.cmake \ - cmake/modules/MacroEnsureVersion.cmake \ - cmake/modules/MacroOptionalFindPackage.cmake \ - cmake/modules/MacroPushRequiredVars.cmake \ - cmake/modules/PopplerDefaults.cmake \ - cmake/modules/PopplerMacros.cmake \ - cmake/modules/FindLIBOPENJPEG.cmake \ - cmake/modules/FindLIBOPENJPEG2.cmake \ - config.h.cmake \ - poppler-cairo.pc.cmake \ - poppler/poppler-config.h.cmake \ - poppler-cpp.pc.cmake \ - poppler-glib.pc.cmake \ - poppler-qt4.pc.cmake \ - poppler-qt5.pc.cmake \ - poppler-splash.pc.cmake \ - poppler.pc.cmake - - - -distclean-local: - if test "$(srcdir)" = "."; then :; else \ - rm -f ChangeLog; \ - fi - -ChangeLog: - $(AM_V_GEN) if test -d "$(srcdir)/.git"; then \ - (GIT_DIR=$(top_srcdir)/.git ./missing --run git log --stat) | fmt --split-only > $@.tmp \ - && mv -f $@.tmp $@ \ - || ($(RM) $@.tmp; \ - echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \ - (test -f $@ || echo git log is required to generate this file >> $@)); \ - else \ - test -f $@ || \ - (echo A git checkout and git log is required to generate ChangeLog >&2 && \ - echo A git checkout and git log is required to generate this file >> $@); \ - fi - -.PHONY: ChangeLog - diff --git a/source/libs/poppler/poppler-src/README.contributors b/source/libs/poppler/poppler-src/README.contributors new file mode 100644 index 0000000000000000000000000000000000000000..5e45331e65f314c01308caf3a66f2247da02da8c --- /dev/null +++ b/source/libs/poppler/poppler-src/README.contributors @@ -0,0 +1,21 @@ +If you want to become or are a poppler contributor, this is a README for you, keep reading! + +Licensing +--------- +Only send patches to poppler if you agree to license (or relicense) them under +GPLv2 and later (or something more permissive that can be "upgraded" to GPLv2 +and later). If you do not agree to this license, please explain the problem / bug +and how you would solve it in words instead of code. + +By default all patches attached to the bugzilla or sent to the mailing list will +be assumed to agree with the licensing expressed here. + +Channels of contact +------------------- +Poppler has three main channels of contact: + * The poppler mailing list http://lists.freedesktop.org/mailman/listinfo/poppler + * The poppler bug tracker (bugzilla) http://bugs.freedesktop.org + * The #poppler channel at the freenode network +Do not hesitate to drop by talk to people there. + +And keep hacking on poppler! diff --git a/source/libs/poppler/poppler-src/TODO b/source/libs/poppler/poppler-src/TODO deleted file mode 100644 index e067c2a3156c7d3fbe0965ad1595bbf5b379d4a5..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/TODO +++ /dev/null @@ -1,40 +0,0 @@ -* general items: - - Investigate better (that is, normal) text selection. - - Use PDF font descriptors to create an FcPattern. - - Add simle performance benchmark that takes a pdf and renders - every page 100 times or so. Start keeping track of - performance. - - make color space conversion stuff more sane (right now we - hack around some of it in the cairo backend) - - move away from getChar to a more read(2) like interface - -* core: - - use libtiff for ccitt decoding? - -* Qt4 frontend: - - expose Rendition media through the MovieObject API - - use Q_GLOBAL_STATIC for GlobalParams? - - use QSettings or another system for loading/saving Document/global settings? - - expose API for lcms/color management system - - make the ArthurOutputDev optional - -* glib frontend: - - Sound/Movie actions support - - API to create annotations - -* new frontends: - - Java/JNI-based frontend for Android - -* cairo backend: - - Implement linear/radial gradients with cairo gradients - - PDF Blend Modes - - Make the cairo backend feature complete and optimize the - heck out of it. - -Jeff Muizelaar's TODO: - Short Term: - - factor out some of the color conversion code from CairoOutputDev and ArthurOutputDev. - - fix patterned text fills. - Long Term: - - use cairo glyph cache for type3 fonts. - - try to use cairo pattern support. diff --git a/source/libs/poppler/poppler-src/config.h.cmake b/source/libs/poppler/poppler-src/config.h.cmake deleted file mode 100644 index a8e1bbd7af6a725117820f24c7bd357f74b825f3..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/config.h.cmake +++ /dev/null @@ -1,255 +0,0 @@ -/* config.h. Generated from config.h.cmake by cmake. */ - -/* Build against libcurl. */ -#cmakedefine ENABLE_LIBCURL 1 - -/* Use libjpeg instead of builtin jpeg decoder. */ -#cmakedefine ENABLE_LIBJPEG 1 - -/* Use libopenjpeg instead of builtin jpeg2000 decoder. */ -#cmakedefine ENABLE_LIBOPENJPEG 1 - -/* Build against libtiff. */ -#cmakedefine ENABLE_LIBTIFF 1 - -/* Build against libpng. */ -#cmakedefine ENABLE_LIBPNG 1 - -/* Do not hardcode the library location */ -#cmakedefine ENABLE_RELOCATABLE 1 - -/* Build against zlib. */ -#cmakedefine ENABLE_ZLIB 1 - -/* Use zlib instead of builtin zlib decoder to uncompress flate streams. */ -#cmakedefine ENABLE_ZLIB_UNCOMPRESS 1 - -/* Build against libnss3 for digital signature validation */ -#cmakedefine ENABLE_NSS3 1 - -/* Use cairo for rendering. */ -#cmakedefine HAVE_CAIRO 1 - -/* Do we have any DCT decoder?. */ -#cmakedefine HAVE_DCT_DECODER 1 - -/* Do we have any JPX decoder?. */ -#cmakedefine HAVE_JPX_DECODER 1 - -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#cmakedefine HAVE_DIRENT_H 1 - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#cmakedefine HAVE_DLFCN_H 1 - -/* Define to 1 if you have the <fcntl.h> header file. */ -#cmakedefine HAVE_FCNTL_H 1 - -/* Have FreeType2 include files */ -#cmakedefine HAVE_FREETYPE_H 1 - -/* Define to 1 if you have the `fseek64' function. */ -#cmakedefine HAVE_FSEEK64 1 - -/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ -#cmakedefine HAVE_FSEEKO 1 - -/* Define to 1 if you have the `ftell64' function. */ -#cmakedefine HAVE_FTELL64 1 - -/* Define to 1 if you have the `pread64' function. */ -#cmakedefine HAVE_PREAD64 1 - -/* Define to 1 if you have the `lseek64' function. */ -#cmakedefine HAVE_LSEEK64 1 - -/* Defines if gettimeofday is available on your system */ -#cmakedefine HAVE_GETTIMEOFDAY 1 - -/* Defines if gmtime_r is available on your system */ -#cmakedefine HAVE_GMTIME_R 1 - -/* Defines if timegm is available on your system */ -#cmakedefine HAVE_TIMEGM 1 - -/* Define if you have the iconv() function and it works. */ -#cmakedefine HAVE_ICONV 1 - -/* Define to 1 if you have the <inttypes.h> header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `openjpeg' library (-lopenjpeg). */ -#cmakedefine HAVE_LIBOPENJPEG 1 - -/* Define to 1 if you have the `z' library (-lz). */ -#cmakedefine HAVE_LIBZ 1 - -/* Defines if localtime_r is available on your system */ -#cmakedefine HAVE_LOCALTIME_R 1 - -/* Define to 1 if you have the <memory.h> header file. */ -#cmakedefine HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mkstemp' function. */ -#cmakedefine HAVE_MKSTEMP 1 - -/* Define to 1 if you have the `mkstemps' function. */ -#cmakedefine HAVE_MKSTEMPS 1 - -/* Define to 1 if you have the `rand_r' function. */ -#cmakedefine HAVE_RAND_R 1 - -/* Define to 1 if you have the `strcpy_s' function. */ -#cmakedefine HAVE_STRCPY_S 1 - -/* Define to 1 if you have the `strcat_s' function. */ -#cmakedefine HAVE_STRCAT_S 1 - -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -#cmakedefine HAVE_NDIR_H 1 - -/* Define to 1 if you have the <openjpeg.h> header file. */ -#cmakedefine HAVE_OPENJPEG_H 1 - -/* Define to 1 if you have the `popen' function. */ -#cmakedefine HAVE_POPEN 1 - -/* Define if you have POSIX threads libraries and header files. */ -#cmakedefine HAVE_PTHREAD 1 - -/* Use splash for rendering. */ -#cmakedefine HAVE_SPLASH 1 - -/* Define to 1 if you have the <stdint.h> header file. */ -#cmakedefine HAVE_STDINT_H 1 - -/* Define to 1 if you have the <stdlib.h> header file. */ -#cmakedefine HAVE_STDLIB_H 1 - -/* Define to 1 if you have the <strings.h> header file. */ -#cmakedefine HAVE_STRINGS_H 1 - -/* Define to 1 if you have the <string.h> header file. */ -#cmakedefine HAVE_STRING_H 1 - -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -#cmakedefine HAVE_SYS_DIR_H 1 - -/* Define to 1 if you have the <sys/mman.h> header file. */ -#cmakedefine HAVE_SYS_MMAN_H 1 - -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -#cmakedefine HAVE_SYS_NDIR_H 1 - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#cmakedefine HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the <sys/types.h> header file. */ -#cmakedefine HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the <unistd.h> header file. */ -#cmakedefine HAVE_UNISTD_H 1 - -/* Define to 1 if you have the <zlib.h> header file. */ -#cmakedefine HAVE_ZLIB_H 1 - -/* Define to 1 if you have a big endian machine */ -#cmakedefine WORDS_BIGENDIAN 1 - -/* Define as const if the declaration of iconv() needs const. */ -#define ICONV_CONST ${ICONV_CONST} - -/* Enable multithreading support. */ -#cmakedefine MULTITHREADED 1 - -/* Generate OPI comments in PS output. */ -#cmakedefine OPI_SUPPORT 1 - -/* Name of package */ -#define PACKAGE "poppler" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "https://bugs.freedesktop.org/enter_bug.cgi?product=poppler" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "poppler" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "poppler ${POPPLER_VERSION}" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "poppler" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "${POPPLER_VERSION}" - -/* Poppler data dir */ -#define POPPLER_DATADIR "${POPPLER_DATADIR}" - -/* Support for curl based doc builder is compiled in. */ -#cmakedefine POPPLER_HAS_CURL_SUPPORT 1 - -/* Include support for CMYK rasterization */ -#cmakedefine SPLASH_CMYK 1 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Enable word list support. */ -#cmakedefine TEXTOUT_WORD_LIST 1 - -/* Defines if use cms */ -#cmakedefine USE_CMS 1 - -/* Use fixed point arithmetic in the Splash backend */ -#cmakedefine USE_FIXEDPOINT 1 - -/* Use single precision arithmetic in the Splash backend */ -#cmakedefine USE_FLOAT 1 - -/* Defines if use lcms1 */ -#cmakedefine USE_LCMS1 1 - -/* Version number of package */ -#define VERSION "${POPPLER_VERSION}" - -/* Use fontconfig font configuration backend */ -#cmakedefine WITH_FONTCONFIGURATION_FONTCONFIG 1 - -/* Use win32 font configuration backend */ -#cmakedefine WITH_FONTCONFIGURATION_WIN32 1 - -/* OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag */ -#cmakedefine WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG 1 - -/* Define to 1 if the X Window System is missing or not being used. */ -/* #undef X_DISPLAY_MISSING */ - -/* - * jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system - * headers and I'm too lazy to write a configure test as long as only - * unixware is related - */ -#ifdef _UNIXWARE -#define HAVE_BOOLEAN -#endif - -/* MS defined snprintf as deprecated but then added it in Visual Studio 2015. */ -#if defined(_MSC_VER) && _MSC_VER < 1900 -#define snprintf _snprintf -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@ - -/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ -/* TODO This is wrong, port if needed #undef _LARGEFILE_SOURCE */ - -/* Define for large files, on AIX-style hosts. */ -/* TODO This is wrong, port if needed #undef _LARGE_FILES */ diff --git a/source/libs/poppler/poppler-src/config.h.in b/source/libs/poppler/poppler-src/config.h.in deleted file mode 100644 index 57479a799a101dbbfc4dd9ba6194570bbdd42a04..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/config.h.in +++ /dev/null @@ -1,290 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD - -/* Build against libcurl. */ -#undef ENABLE_LIBCURL - -/* Use libjpeg instead of builtin unmaintained jpeg decoder. */ -#undef ENABLE_LIBJPEG - -/* Use libopenjpeg instead of builtin jpeg2000 decoder. */ -#undef ENABLE_LIBOPENJPEG - -/* Build against libpng. */ -#undef ENABLE_LIBPNG - -/* Build against libtiff. */ -#undef ENABLE_LIBTIFF - -/* Build Poppler against NSS for digital signature support. */ -#undef ENABLE_NSS3 - -/* Do not hardcode the library location */ -#undef ENABLE_RELOCATABLE - -/* Build against zlib. */ -#undef ENABLE_ZLIB - -/* Use zlib instead of builtin zlib decoder to uncompress flate streams. */ -#undef ENABLE_ZLIB_UNCOMPRESS - -/* Use cairo for rendering. */ -#undef HAVE_CAIRO - -/* Do we have any DCT decoder?. */ -#undef HAVE_DCT_DECODER - -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#undef HAVE_DLFCN_H - -/* Define to 1 if you have the <fcntl.h> header file. */ -#undef HAVE_FCNTL_H - -/* Have FreeType2 include files */ -#undef HAVE_FREETYPE_H - -/* Define to 1 if you have the `fseek64' function. */ -#undef HAVE_FSEEK64 - -/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ -#undef HAVE_FSEEKO - -/* Define to 1 if you have the `ftell64' function. */ -#undef HAVE_FTELL64 - -/* Defines if gettimeofday is available on your system */ -#undef HAVE_GETTIMEOFDAY - -/* Defines if gmtime_r is available on your system */ -#undef HAVE_GMTIME_R - -/* Define if you have the iconv() function and it works. */ -#undef HAVE_ICONV - -/* Define to 1 if you have the <inttypes.h> header file. */ -#undef HAVE_INTTYPES_H - -/* Do we have any JPX decoder?. */ -#undef HAVE_JPX_DECODER - -/* Define to 1 if you have the `tiff' library (-ltiff). */ -#undef HAVE_LIBTIFF - -/* Define to 1 if you have the `z' library (-lz). */ -#undef HAVE_LIBZ - -/* Defines if localtime_r is available on your system */ -#undef HAVE_LOCALTIME_R - -/* Define to 1 if you have the `lseek64' function. */ -#undef HAVE_LSEEK64 - -/* Define to 1 if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - -/* Define to 1 if you have the `mkstemps' function. */ -#undef HAVE_MKSTEMPS - -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -#undef HAVE_NDIR_H - -/* Define to 1 if you have the <openjpeg.h> header file. */ -#undef HAVE_OPENJPEG_H - -/* Define to 1 if you have the `popen' function. */ -#undef HAVE_POPEN - -/* Define to 1 if you have the `pread64' function. */ -#undef HAVE_PREAD64 - -/* Define if you have POSIX threads libraries and header files. */ -#undef HAVE_PTHREAD - -/* Have PTHREAD_PRIO_INHERIT. */ -#undef HAVE_PTHREAD_PRIO_INHERIT - -/* Defines if rand_r is available on your system */ -#undef HAVE_RAND_R - -/* Use splash for rendering. */ -#undef HAVE_SPLASH - -/* Define to 1 if you have the <stdint.h> header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the <stdlib.h> header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcat_s' function. */ -#undef HAVE_STRCAT_S - -/* Define to 1 if you have the `strcpy_s' function. */ -#undef HAVE_STRCPY_S - -/* Define to 1 if you have the <strings.h> header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the <string.h> header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_DIR_H - -/* Define to 1 if you have the <sys/mman.h> header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -#undef HAVE_SYS_NDIR_H - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the <sys/types.h> header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the <tiffio.h> header file. */ -#undef HAVE_TIFFIO_H - -/* Defines if timegm is available on your system */ -#undef HAVE_TIMEGM - -/* Define to 1 if you have the <unistd.h> header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the <zlib.h> header file. */ -#undef HAVE_ZLIB_H - -/* Define as const if the declaration of iconv() needs const. */ -#undef ICONV_CONST - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#undef LT_OBJDIR - -/* Enable multithreading support. */ -#undef MULTITHREADED - -/* Generate OPI comments in PS output. */ -#undef OPI_SUPPORT - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Poppler data dir */ -#undef POPPLER_DATADIR - -/* Support for curl based doc builder is compiled in. */ -#undef POPPLER_HAS_CURL_SUPPORT - -/* Defines the poppler version */ -#undef POPPLER_VERSION - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -#undef PTHREAD_CREATE_JOINABLE - -/* Include support for CMYK rasterization */ -#undef SPLASH_CMYK - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Enable word list support. */ -#undef TEXTOUT_WORD_LIST - -/* Defines if use cms */ -#undef USE_CMS - -/* Use fixed point arithmetic in the Splash backend */ -#undef USE_FIXEDPOINT - -/* Use single precision arithmetic in the Splash backend */ -#undef USE_FLOAT - -/* Defines if use lcms1 */ -#undef USE_LCMS1 - -/* Defined if using openjpeg1 */ -#undef USE_OPENJPEG1 - -/* Defined if using openjpeg2 */ -#undef USE_OPENJPEG2 - -/* Version number of package */ -#undef VERSION - -/* Use fontconfig font configuration backend */ -#undef WITH_FONTCONFIGURATION_FONTCONFIG - -/* Use win32 font configuration backend */ -#undef WITH_FONTCONFIGURATION_WIN32 - -/* OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag. */ -#undef WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Define to 1 if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* - * jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system - * headers and I'm too lazy to write a configure test as long as only - * unixware is related - */ -#ifdef _UNIXWARE -#define HAVE_BOOLEAN -#endif - - -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ -#undef _LARGEFILE_SOURCE - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES diff --git a/source/libs/poppler/poppler-src/configure.ac b/source/libs/poppler/poppler-src/configure.ac deleted file mode 100644 index e4054581ea044242aa8046821112bd344f442a80..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/configure.ac +++ /dev/null @@ -1,1154 +0,0 @@ -m4_define([poppler_version_major],[0]) -m4_define([poppler_version_minor],[59]) -m4_define([poppler_version_micro],[0]) -m4_define([poppler_version],[poppler_version_major.poppler_version_minor.poppler_version_micro]) - -AC_PREREQ(2.59) -AC_INIT([poppler],[poppler_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=poppler]) -AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([1.7 foreign]) -m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) -AC_CONFIG_HEADERS([config.h poppler/poppler-config.h]) -AC_C_BIGENDIAN - -dnl ##### Initialize libtool. -AC_LIBTOOL_WIN32_DLL -define([AC_LIBTOOL_LANG_F77_CONFIG], [:]) -AC_PROG_LIBTOOL - -dnl ##### Checks for programs. -AC_PROG_CC -AC_PROG_CXX -AC_ISC_POSIX -AC_PROG_CC_STDC -#if test -z "$CXX" -a "$CC" = "gcc"; then -# CXX="gcc" -#fi -AC_PROG_CXX -AC_PROG_INSTALL -CXXFLAGS="$CXXFLAGS -std=c++11 -D_DEFAULT_SOURCE" - -dnl ##### Check for pkgconfig -PKG_PROG_PKG_CONFIG - -dnl ##### Export the version -AC_DEFINE_UNQUOTED([POPPLER_VERSION], ["poppler_version"], [Defines the poppler version]) - -dnl Enable these unconditionally. -AC_DEFINE([OPI_SUPPORT], [1], [Generate OPI comments in PS output.]) -AC_DEFINE([MULTITHREADED], [1], [Enable multithreading support.]) -AC_DEFINE([TEXTOUT_WORD_LIST], [1], [Enable word list support.]) - -dnl Check for OS specific flags -win32_libs="" -create_shared_lib="" -auto_import_flags="" -case "$host_os" in - cygwin*) - create_shared_lib="-no-undefined" - ;; - mingw*) - os_win32=yes - win32_libs="-lgdi32 -lwinspool -lcomdlg32" - create_shared_lib="-no-undefined" - auto_import_flags="-Wl,--enable-auto-import" - - # Use mingw's ansi stdio extensions - CXXFLAGS="$CXXFLAGS -D__USE_MINGW_ANSI_STDIO=1" - ;; -esac - -AC_SUBST(win32_libs) -AC_SUBST(create_shared_lib) -AC_SUBST(auto_import_flags) - -AX_PTHREAD() - -dnl Install xpdf headers -AC_ARG_ENABLE(xpdf-headers, - AC_HELP_STRING([--enable-xpdf-headers], - [Install unsupported xpdf headers.]), - enable_xpdf_headers=$enableval, - enable_xpdf_headers="no") -AM_CONDITIONAL(ENABLE_XPDF_HEADERS, test x$enable_xpdf_headers = xyes) - -dnl ##### Emulate cmake -DCMAKE_BUILD_TYPE=Release using options from cmake/modules/PopplerMacros.cmake - -AC_ARG_ENABLE(build-type, - AC_HELP_STRING([--enable-build-type=@<:@relwithdebinfo/release/debug/debugfull/profile@:>@], - [Build with options similar to 'cmake -DCMAKE_BUILD_TYPE=' values.]), - [enable_build_type=no; - case "$enableval" in - relwithdebinfo|release|debug|debugfull|profile) enable_build_type="$enableval" ;; - *) AC_MSG_ERROR([bad value $enableval for --enable-build-type option. - Options are relwithdebinfo, release, debug, debugfull, and profile.]) ;; - esac], - enable_build_type=no) - -if test "x$GCC" = "xyes"; then - case "$enable_build_type" in - relwithdebinfo) - CFLAGS="-O2 -g $CFLAGS" - CXXFLAGS="-O2 -g $CXXFLAGS" - ;; - release) - CFLAGS="-O2 $CFLAGS -g0 -DNDEBUG" - CXXFLAGS="-O2 $CXXFLAGS -g0 -DNDEBUG" - ;; - debug) - CFLAGS="-O2 -g $CFLAGS -fno-reorder-blocks -fno-schedule-insns -fno-inline" - CXXFLAGS="-O2 -g $CXXFLAGS -fno-reorder-blocks -fno-schedule-insns -fno-inline" - ;; - debugfull) - CFLAGS="$CFLAGS -g3 -fno-inline" - CXXFLAGS="$CXXFLAGS -g3 -fno-inline" - ;; - profile) - CFLAGS="$CFLAGS -g3 -fno-inline -ftest-coverage -fprofile-arcs" - CXXFLAGS="$CXXFLAGS -g3 -fno-inline -ftest-coverage -fprofile-arcs" - LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage -lgcov" - ;; - *) - enable_build_type=no - ;; - esac -else - case "$enable_build_type" in - relwithdebinfo|release|debug|debugfull|profile) - echo " Warning: --enable-build-type ignored for non-gcc compiler." - ;; - esac - enable_build_type=no -fi - -AC_ARG_ENABLE(single-precision, - AC_HELP_STRING([--enable-single-precision], - [use single precision arithmetic (instead of double - precision) in the Splash backend]), - enable_single_precision=$enableval, - enable_single_precision=no) -if test x$enable_single_precision != xno; then - AC_DEFINE(USE_FLOAT, [1], [Use single precision arithmetic in the Splash backend]) -fi - -AC_ARG_ENABLE(fixedpoint, - AC_HELP_STRING([--enable-fixedpoint], - [use fixed point (instead of double precision) arithmetic - in the Splash backend]), - enable_fixedpoint=$enableval, - enable_fixedpoint=no) -if test x$enable_fixedpoint != xno; then - if test x$enable_single_precision != xno; then - AC_MSG_ERROR([Choose only one of --enable-single-precision or --enable-fixedpoint!]) - fi - AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic in the Splash backend]) -fi - -AC_ARG_ENABLE(cmyk, - AC_HELP_STRING([--enable-cmyk], - [Include support for CMYK rasterization]), - enable_cmyk=$enableval, - enable_cmyk=no) -if test x$enable_cmyk != xno; then - AC_DEFINE(SPLASH_CMYK, [1], [Include support for CMYK rasterization]) -fi - -dnl Relocation support -AC_ARG_ENABLE(relocatable, - AC_HELP_STRING([--disable-relocatable], - [Hardcode the poppler library location (on Windows).]), - enable_relocatable=$enableval, - [if test x$os_win32 = xyes; then - # default to yes on native Windows. - enable_relocatable="yes" - else - # default to no everywhere else. - enable_relocatable="no" - fi - ] -) - -if test x$enable_relocatable = xyes; then - if test x$os_win32 = xyes; then - AC_DEFINE([ENABLE_RELOCATABLE], - [1],[Do not hardcode the library location]) - else - AC_MSG_ERROR( - [Invalid setting for relocatable, only supported on windows]) - - fi -fi - -dnl ##### Check for installed poppler-data. Use the same datarootdir as default otherwise. -PKG_CHECK_EXISTS(poppler-data, - [POPPLER_DATADIR=`$PKG_CONFIG --variable=poppler_datadir poppler-data` - AC_DEFINE_DIR(POPPLER_DATADIR, "{POPPLER_DATADIR}", [Poppler data dir])], - [AC_DEFINE_DIR(POPPLER_DATADIR, "{datarootdir}/poppler", [Poppler data dir])] - ) - -dnl ##### Checks for header files. -AC_PATH_XTRA -AC_HEADER_DIRENT -AC_CHECK_HEADERS([stdint.h]) - -dnl ##### Switch over to C++. This will make the checks below a little -dnl ##### bit stricter (requiring function prototypes in include files). -dnl ##### (99% of xpdf is written in C++.) -AC_LANG_CPLUSPLUS - -AC_CHECK_DECL(gettimeofday, [AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defines if gettimeofday is available on your system]))],[],[#include <sys/time.h>]) -AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system])) -AC_CHECK_FUNC(gmtime_r, AC_DEFINE(HAVE_GMTIME_R, 1, [Defines if gmtime_r is available on your system])) -AC_CHECK_FUNC(timegm, AC_DEFINE(HAVE_TIMEGM, 1, [Defines if timegm is available on your system])) -AC_CHECK_FUNC(rand_r, AC_DEFINE(HAVE_RAND_R, 1, [Defines if rand_r is available on your system])) - -dnl ##### Check for extra libraries needed by X. (LynxOS needs this.) -AC_CHECK_FUNC(nanosleep,,) -dnl try in librt if not found in current LIBS -if test x$ac_cv_func_nanosleep = xno -then - AC_CHECK_LIB(rt,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lrt") -fi - -dnl try in libposix4, if not found so far -if test x$ac_cv_func_nanosleep = xno && test x$ac_cv_lib_rt_nanosleep = xno -then - AC_CHECK_LIB(posix4,nanosleep, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix4") -fi - - -dnl ##### Test for libopenjpeg. Versions prior to 1.4 do not provide a pkgconfig file. -openjpeg1="no" -openjpeg2="no" -AC_ARG_ENABLE(libopenjpeg, - AC_HELP_STRING([--enable-libopenjpeg=@<:@auto/openjpeg1/openjpeg2/unmaintained/none@:>@], - [Use openjpeg for JPEG2000 images. 'auto' prefers openjpeg2 over openjpeg1 if both are available. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no JPX decoder at all. [[default=auto]]]), - [enable_libopenjpeg=$enableval], - [enable_libopenjpeg="auto"]) - -openjpeg_header=yes - -dnl test for libopenjpeg2 -if test x$enable_libopenjpeg = xopenjpeg2 || test x$enable_libopenjpeg = xauto; then - PKG_CHECK_MODULES(LIBOPENJPEG, libopenjp2, - [openjpeg2=yes],[openjpeg2=no]) -fi - -dnl test for libopenjpeg1 -if test x$openjpeg2 = xno; then - if test x$enable_libopenjpeg = xopenjpeg1 || test x$enable_libopenjpeg = xauto; then - PKG_CHECK_MODULES(LIBOPENJPEG, libopenjpeg, - [openjpeg1="yes"], - [AC_CHECK_LIB([openjpeg], [opj_cio_open], - [openjpeg1="yes" - LIBOPENJPEG_LIBS="-lopenjpeg"],[openjpeg_header=no]) - AC_CHECK_HEADERS([openjpeg.h],, - [openjpeg_header="no"])]) - fi -fi - - -if test x$enable_libopenjpeg = xopenjpeg1 && test x$openjpeg1 = xno; then - if test x$openjpeg_header = xno; then - AC_MSG_ERROR("*** libopenjpeg headers not found ***") - else - AC_MSG_ERROR("*** libopenjpeg library not found ***") - fi -fi - -if test x$enable_libopenjpeg = xopenjpeg2 && test x$openjpeg2 = xno; then - AC_MSG_ERROR("*** libopenjp2 library not found ***") -fi - -if test x$openjpeg1 = xyes || test x$openjpeg2 = xyes; then - enable_libopenjpeg=yes - if test x$openjpeg1 = xyes; then - AC_DEFINE(USE_OPENJPEG1, 1, [Defined if using openjpeg1]) - fi - if test x$openjpeg2 = xyes; then - AC_DEFINE(USE_OPENJPEG2, 1, [Defined if using openjpeg2]) - fi - - AC_SUBST(LIBOPENJPEG_CFLAGS) - AC_SUBST(LIBOPENJPEG_LIBS) - AC_DEFINE(ENABLE_LIBOPENJPEG) - PKG_CHECK_EXISTS(libopenjpeg >= 1.5, - [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], - [PKG_CHECK_EXISTS(libopenjpeg1 >= 1.5, - [AC_DEFINE(WITH_OPENJPEG_IGNORE_PCLR_CMAP_CDEF_FLAG, 1, [OpenJPEG with the OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG flag.])], - []) - ]) - have_jpx_decoder=yes - AC_DEFINE(HAVE_JPX_DECODER) -else - if test x$enable_libopenjpeg = xunmaintained; then - enable_libopenjpeg=no - have_jpx_decoder=yes - AC_DEFINE(HAVE_JPX_DECODER) - elif test x$enable_libopenjpeg = xnone; then - enable_libopenjpeg=no - have_jpx_decoder=no - else - if test x$enable_libopenjpeg = xopenjpeg2 || test x$enable_libopenjpeg = xopenjpeg1 || test x$enable_libopenjpeg = xauto; then - AC_MSG_ERROR([Install libopenjpeg2 or libopenjpeg1 before trying to build poppler. You can also decide to use the internal unmaintained JPX decoder or none at all. See --help.]) - else - AC_MSG_ERROR([Invalid --enable-libopenjpeg value. See --help.]) - fi - fi -fi - -AH_TEMPLATE([HAVE_JPX_DECODER], [Do we have any JPX decoder?.]) - -dnl Test for NSS -AC_ARG_ENABLE(libnss, - AC_HELP_STRING([--disable-libnss], - [Do not build against libnss3.]), - enable_libnss=$enableval, - enable_libnss="try") - -if test x$enable_libnss != xno; then - PKG_CHECK_MODULES(NSS3, nss, [enable_nss="yes"], - [enable_nss="no"]) -fi - -if test x$enable_nss = xyes; then - AC_DEFINE(ENABLE_NSS3, 1, [Build against NSS.]) -fi - -AM_CONDITIONAL(BUILD_LIBOPENJPEG, test x$openjpeg1 = xyes || test x$openjpeg2 = xyes) -AH_TEMPLATE([ENABLE_LIBOPENJPEG], - [Use libopenjpeg instead of builtin jpeg2000 decoder.]) - -AM_CONDITIONAL(BUILD_NSS, test x$enable_nss = xyes) -AH_TEMPLATE([ENABLE_NSS3], [Build Poppler against NSS for digital signature support.]) - -dnl ##### Test for libtiff -AC_ARG_ENABLE(libtiff, - AC_HELP_STRING([--disable-libtiff], - [Don't build against libtiff.]), - enable_libtiff=$enableval, - enable_libtiff="try") - -AC_ARG_VAR([LIBTIFF_CFLAGS], [C compiler flags for LIBTIFF]) -AC_ARG_VAR([LIBTIFF_LIBS], [linker flags to link LIBTIFF (default is -ltiff)]) -ac_save_CPPFLAGS="$CPPFLAGS" -ac_save_CXXFLAGS="$CXXFLAGS" -ac_save_LIBS="$LDFLAGS" -CPPFLAGS="$CPPFLAGS $LIBTIFF_CFLAGS" -CXXFLAGS="$CXXFLAGS $LIBTIFF_CFLAGS" -LIBS="$LIBS $LIBTIFF_LIBS" -if test x$enable_libtiff = xyes; then - if test x"$LIBTIFF_LIBS" != x; then - AC_CHECK_FUNC([TIFFOpen],, - AC_MSG_ERROR("*** libtiff library not found ***")) - else - AC_CHECK_LIB([tiff], [TIFFOpen],, - AC_MSG_ERROR("*** libtiff library not found ***")) - fi - AC_CHECK_HEADERS([tiffio.h],, - AC_MSG_ERROR("*** libtiff headers not found ***")) -elif test x$enable_libtiff = xtry; then - if test x"$LIBTIFF_LIBS" != x; then - AC_CHECK_FUNC([TIFFOpen], - [enable_libtiff="yes"], - [enable_libtiff="no"]) - else - AC_CHECK_LIB([tiff], [TIFFOpen], - [enable_libtiff="yes"], - [enable_libtiff="no"]) - fi - AC_CHECK_HEADERS([tiffio.h],, - [enable_libtiff="no"]) -fi -CPPFLAGS="$ac_save_CPPFLAGS" -CXXFLAGS="$ac_save_CXXFLAGS" -LIBS="$ac_save_LIBS" - -if test x$enable_libtiff = xyes; then - if test x"$LIBTIFF_LIBS" = x; then - LIBTIFF_LIBS="-ltiff" - fi - AC_SUBST(LIBTIFF_CFLAGS) - AC_SUBST(LIBTIFF_LIBS) - AC_DEFINE(ENABLE_LIBTIFF) -fi - -AM_CONDITIONAL(BUILD_LIBTIFF, test x$enable_libtiff = xyes) -AH_TEMPLATE([ENABLE_LIBTIFF], [Build against libtiff.]) -if test x$enable_libtiff = xyes; then - AC_DEFINE(ENABLE_LIBTIFF, 1, [Build against libtiff.]) -fi - -dnl ##### Checks for library functions. -AC_CHECK_FUNCS(popen mkstemp mkstemps) -AC_CHECK_FUNCS(strcpy_s strcat_s) - -dnl ##### Back to C for the library tests. -AC_LANG_C - -dnl ##### Check for fseeko/ftello or fseek64/ftell64 -dnl The LARGEFILE and FSEEKO macros have to be called in C, not C++, mode. -AC_SYS_LARGEFILE -AC_FUNC_FSEEKO -AC_CHECK_FUNCS(fseek64, xpdf_cv_func_fseek64=yes, xpdf_cv_func_fseek64=no) -AC_CHECK_FUNCS(ftell64, xpdf_cv_func_ftell64=yes, xpdf_cv_func_ftell64=no) -if test "$xpdf_cv_func_fseek64" = yes -a "$xpdf_cv_func_ftell64" = yes; then - AC_DEFINE(HAVE_FSEEK64) -fi -AC_CHECK_FUNCS(pread64 lseek64) - -dnl Test for zlib -AC_ARG_ENABLE(zlib, - AC_HELP_STRING([--disable-zlib], - [Don't build against zlib.]), - enable_zlib=$enableval, - enable_zlib="try") - -AC_ARG_ENABLE([zlib_uncompress], - AS_HELP_STRING([--enable-zlib-uncompress], - [Use zlib to uncompress flate streams (not totally safe)]), - enable_zlib_uncompress=$enableval, - enable_zlib_uncompress="no") - -if test x$enable_zlib = xyes; then - AC_CHECK_LIB([z], [inflate],, - AC_MSG_ERROR("*** zlib library not found ***")) - AC_CHECK_HEADERS([zlib.h],, - AC_MSG_ERROR("*** zlib headers not found ***")) -elif test x$enable_zlib = xtry; then - AC_CHECK_LIB([z], [inflate], - [enable_zlib="yes"], - [enable_zlib="no"]) - AC_CHECK_HEADERS([zlib.h],, - [enable_zlib="no"]) -fi - -if test x$enable_zlib = xyes; then - ZLIB_LIBS="-lz" - AC_SUBST(ZLIB_LIBS) - AC_DEFINE(ENABLE_ZLIB, 1, [Build against zlib.]) - - if test x$enable_zlib_uncompress = xyes; then - AC_DEFINE(ENABLE_ZLIB_UNCOMPRESS, 1, - [Use zlib instead of builtin zlib decoder to uncompress flate streams.]) - fi -else - if test x$enable_zlib_uncompress = xyes; then - echo " Warning: --enable-zlib-uncompress is incompatible with --disable-zlib." - fi - enable_zlib_uncompress="no" -fi - -AM_CONDITIONAL(BUILD_ZLIB, test x$enable_zlib = xyes) -AH_TEMPLATE([ENABLE_ZLIB], - [Build against zlib.]) -AM_CONDITIONAL(BUILD_ZLIB_UNCOMPRESS, test x$enable_zlib_uncompress = xyes) -AH_TEMPLATE([ENABLE_ZLIB_UNCOMPRESS], - [Use zlib instead of builtin zlib decoder to uncompress flate streams.]) - -dnl Test for libcurl -AC_ARG_ENABLE(libcurl, - AC_HELP_STRING([--enable-libcurl], - [Build with libcurl based HTTP support.]), - enable_libcurl=$enableval, - enable_libcurl="no") - -if test x$enable_libcurl = xyes; then - PKG_CHECK_MODULES(LIBCURL, libcurl) - AC_DEFINE(ENABLE_LIBCURL, 1, [Build against libcurl.]) - AC_DEFINE(POPPLER_HAS_CURL_SUPPORT, 1, - [Support for curl based doc builder is compiled in.]) -fi - -AM_CONDITIONAL(BUILD_LIBCURL, test x$enable_libcurl = xyes) - -dnl Test for dct decoder -AC_ARG_ENABLE(dctdecoder, - AC_HELP_STRING([--enable-dctdecoder=@<:@libjpeg/unmaintained/none@:>@], - [Decides which DCT decoder to use. 'libjpeg' will use libjpeg if available or fail if not. 'unmaintained' gives you the internal unmaintained decoder. Use at your own risk. 'none' compiles no DCT decoder at all. [[default=libjpeg]]]), - [dctdecoder=$enableval], - [dctdecoder="libjpeg"]) - -AC_ARG_VAR([LIBJPEG_CFLAGS], [C compiler flags for LIBJPEG]) -if test x$dctdecoder = x"libjpeg"; then - - dnl - dnl POPPLER_FIND_JPEG uses "USER_INCLUDES" and "USER_LIBS" - dnl to receive the flags for header and library directories. - dnl - ac_save_USER_INCLUDES="$USER_INCLUDES" - ac_save_USER_LDFLAGS="$USER_LDFLAGS" - USER_INCLUDES="$USER_INCLUDES $LIBJPEG_CFLAGS" - USER_LDFLAGS="$USER_LDFLAGS $LIBJPEG_CFLAGS" - POPPLER_FIND_JPEG - - dnl check INT16, INT32 typedef conflict in jmorecfg.h - ac_save_CPPFLAGS="$CPPFLAGS" - ac_save_CFLAGS="$CFLAGS" - CPPFLAGS="$CPPFLAGS $LIBJPEG_CFLAGS" - CFLAGS="$CFLAGS $LIBJPEG_CFLAGS" - AC_MSG_CHECKING([libjpeg.h works correctly]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#ifdef _WIN32 -#include <windows.h> -#endif -#include <sys/types.h> -#include <stdio.h> -#include <jpeglib.h> -],[{return 0;}])],[ - AC_MSG_RESULT([ok]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_CHECKING([libjpeg.h problem can be fixed by XMD_H macro]) - CPPFLAGS="$CPPFLAGS -DXMD_H" - CFLAGS="$CFLAGS -DXMD_H" - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ -#ifdef _WIN32 -#include <windows.h> -#endif -#include <sys/types.h> -#include <stdio.h> -#include <jpeglib.h> -],[{return 0;}])],[ - AC_MSG_RESULT([ok, -DXMD_H is added to LIBJPEG_CFLAGS]) - LIBJPEG_CFLAGS="$LIBJPEG_CFLAGS -DXMD_H" - ],[ - AC_MSG_RESULT([no, disable libjpeg]) - enable_libjpeg="no" - ]) - ]) - CPPFLAGS="$ac_save_CPPFLAGS" - CFLAGS="$ac_save_CFLAGS" - - dnl POPPLER_FIND_JPEG sets LIBJPEG_LIBS - AC_SUBST(LIBJPEG_CFLAGS) - USER_INCLUDES="$ac_save_USER_INCLUDES" - USER_LDFLAGS="$ac_save_USER_LDFLAGS" - - if test x$enable_libjpeg != x"yes"; then - AC_MSG_ERROR([Install libjpeg before trying to build poppler. You can also decide to use the internal unmaintained DCT decoder or none at all. See --help.]) - fi - have_dct_decoder="yes" - AC_DEFINE(HAVE_DCT_DECODER) -elif test x$dctdecoder = x"unmaintained"; then - enable_libjpeg="no" - have_dct_decoder="yes" - AC_DEFINE(HAVE_DCT_DECODER) -elif test x$dctdecoder = x"none"; then - enable_libjpeg="no" - have_dct_decoder="no" -else - AC_MSG_ERROR([Invalid --enable-dctdecoder value. See --help.]) -fi - -AH_TEMPLATE([HAVE_DCT_DECODER], [Do we have any DCT decoder?.]) - -AM_CONDITIONAL(BUILD_LIBJPEG, test x$enable_libjpeg = xyes) -AH_TEMPLATE([ENABLE_LIBJPEG], - [Use libjpeg instead of builtin unmaintained jpeg decoder.]) - -dnl Test for libpng -AC_ARG_ENABLE(libpng, - AC_HELP_STRING([--disable-libpng], - [Do not build against libpng.]), - enable_libpng=$enableval, - enable_libpng="try") - -if test x$enable_libpng != xno; then - PKG_CHECK_MODULES(LIBPNG, libpng, [enable_libpng="yes"], - [enable_libpng="no"]) -fi - -if test x$enable_libpng = xyes; then - AC_DEFINE(ENABLE_LIBPNG, 1, [Build against libpng.]) -fi - -AM_CONDITIONAL(BUILD_LIBPNG, test x$enable_libpng = xyes) - -dnl Check for freetype headers - -PKG_CHECK_MODULES(FREETYPE, freetype2, - [freetype_pkgconfig=yes], [freetype_pkgconfig=no]) - -if test "x$freetype_pkgconfig" = "xyes"; then - - AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) - -else - - FREETYPE_LIBS= - FREETYPE_CFLAGS= - - AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no) - if test "x$FREETYPE_CONFIG" != "xno" ; then - - FREETYPE_CFLAGS=`$FREETYPE_CONFIG --cflags` - FREETYPE_LIBS=`$FREETYPE_CONFIG --libs` - AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files]) - - fi - -fi - -AC_SUBST(FREETYPE_CFLAGS) -AC_SUBST(FREETYPE_LIBS) - -AC_MSG_CHECKING([which font configuration to use]) -AC_ARG_WITH([font_configuration], - [AS_HELP_STRING([--with-font-configuration=fontconfig|win32], - [Select font configuration backend])], - [], - [if test x$os_win32 = xyes; then - # default to win32 on native Windows. - with_font_configuration=win32 - else - # default to fontconig everywhere else. - with_font_configuration=fontconfig - fi - ] -) -AC_MSG_RESULT([$with_font_configuration]) - -case $with_font_configuration in - win32) - AC_DEFINE([WITH_FONTCONFIGURATION_WIN32], - [1],[Use win32 font configuration backend]) - # Set the minimum required Internet Explorer version to 5.0 - CPPFLAGS="$CPPFLAGS -D_WIN32_IE=0x0500" - ;; - fontconfig) - AC_DEFINE([WITH_FONTCONFIGURATION_FONTCONFIG], - [1],[Use fontconfig font configuration backend]) - PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.0.0) - ;; - *) - AC_MSG_ERROR( - [Invalid font configuration setting: $with_font_configuration]) - ;; -esac - -AM_CONDITIONAL(BUILD_WITH_WIN32_FONTCONFIGURATION, - test x$with_font_configuration = xwin32) - -AC_ARG_ENABLE(splash-output, - AC_HELP_STRING([--disable-splash-output], - [Don't build the Splash graphics backend.]),, - enable_splash_output="yes") -AM_CONDITIONAL(BUILD_SPLASH_OUTPUT, test x$enable_splash_output = xyes) -AH_TEMPLATE([HAVE_SPLASH], [Use splash for rendering.]) -if test x$enable_splash_output = xyes; then - AC_DEFINE(HAVE_SPLASH) -fi - -CAIRO_VERSION="1.10.0" -AC_SUBST(CAIRO_VERSION) -CAIRO_DEPS="cairo >= $CAIRO_VERSION cairo-ft >= $CAIRO_VERSION" -AC_ARG_ENABLE(cairo-output, - AC_HELP_STRING([--disable-cairo-output], - [Don't build the cairo graphics backend.]), - enable_cairo_output=$enableval, - enable_cairo_output="try") -use_cairo="" -if test x$enable_cairo_output = xyes; then - PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS) -elif test x$enable_cairo_output = xtry; then - PKG_CHECK_MODULES(CAIRO, $CAIRO_DEPS, - [enable_cairo_output="yes"], - [enable_cairo_output="no" - use_cairo="no (requires cairo >= $CAIRO_VERSION)"]) -fi -if test "x$use_cairo" = "x"; then - use_cairo=$enable_cairo_output -fi - -AC_SUBST(CAIRO_CFLAGS) -AC_SUBST(CAIRO_LIBS) - -AM_CONDITIONAL(BUILD_CAIRO_OUTPUT, test x$enable_cairo_output = xyes) -AH_TEMPLATE([HAVE_CAIRO], [Use cairo for rendering.]) -if test x$enable_cairo_output = xyes; then - PDFTOCAIRO_DEPS="cairo cairo-ft" - dnl Check for optional cairo backends used by pdftocairo - PKG_CHECK_EXISTS(cairo-pdf, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-pdf"], []) - PKG_CHECK_EXISTS(cairo-ps, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-ps"], []) - PKG_CHECK_EXISTS(cairo-svg, [PDFTOCAIRO_DEPS="$PDFTOCAIRO_DEPS cairo-svg"], []) - - PKG_CHECK_MODULES(PDFTOCAIRO, $PDFTOCAIRO_DEPS) - AC_SUBST(PDFTOCAIRO_CFLAGS) - AC_SUBST(PDFTOCAIRO_LIBS) - - AC_DEFINE(HAVE_CAIRO) - CAIRO_FEATURE="#define POPPLER_HAS_CAIRO 1" - CAIRO_REQ="cairo" - AC_CHECK_HEADERS(fcntl.h sys/mman.h sys/stat.h) -else - CAIRO_FEATURE="#undef POPPLER_HAS_CAIRO" - CAIRO_REQ="" -fi -AC_SUBST(CAIRO_FEATURE) -AC_SUBST(CAIRO_REQ) - -use_glib="" -found_introspection=no -if test x$enable_cairo_output = xyes; then - POPPLER_GLIB_DISABLE_DEPRECATED="" - POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="" - - GLIB_REQUIRED=2.41 - AC_SUBST(GLIB_REQUIRED) - AC_ARG_ENABLE(poppler-glib, - AC_HELP_STRING([--disable-poppler-glib], - [Don't compile poppler glib wrapper.]), - enable_poppler_glib=$enableval, - enable_poppler_glib="try") - if test x$enable_poppler_glib = xyes; then - PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION) - elif test x$enable_poppler_glib = xtry; then - PKG_CHECK_MODULES(POPPLER_GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION, - [enable_poppler_glib="yes"], - [enable_poppler_glib="no" - use_glib="no (requires glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED cairo >= $CAIRO_VERSION)"]) - fi - if test x$enable_poppler_glib = xyes; then - # Check for introspection - GOBJECT_INTROSPECTION_CHECK([0.6.7]) - - AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums]) - POPPLER_GLIB_DISABLE_DEPRECATED="$POPPLER_GLIB_DISABLE_DEPRECATED -DG_DISABLE_DEPRECATED" - POPPLER_GLIB_DISABLE_SINGLE_INCLUDES="$POPPLER_GLIB_DISABLE_SINGLE_INCLUDES -DG_DISABLE_SINGLE_INCLUDES" - fi -else - if test x$enable_poppler_glib = xyes; then - AC_MSG_ERROR("Cairo output is required to build glib frontend") - fi - use_glib="no (requires cairo output)" - enable_poppler_glib="no" -fi -if test x"$use_glib" = x; then - use_glib="$enable_poppler_glib" -fi -AM_CONDITIONAL(BUILD_POPPLER_GLIB, test x$enable_poppler_glib = xyes) -AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") -AC_SUBST(GLIB_REQ) -AC_SUBST(POPPLER_GLIB_DISABLE_DEPRECATED) -AC_SUBST(POPPLER_GLIB_DISABLE_SINGLE_INCLUDES) - -GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) - -dnl -dnl Try Qt4 -dnl - -AC_ARG_ENABLE(poppler-qt4, - AC_HELP_STRING([--disable-poppler-qt4], - [Don't compile poppler Qt4 wrapper.]), - enable_poppler_qt4=$enableval, - enable_poppler_qt4="try") -if test x$enable_poppler_qt4 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT4, - QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0) - PKG_CHECK_MODULES(POPPLER_QT4_TEST, - QtTest >= 4.7.0) -elif test x$enable_poppler_qt4 = xtry; then - PKG_CHECK_MODULES(POPPLER_QT4, - QtCore >= 4.7.0 QtGui >= 4.7.0 QtXml >= 4.7.0, - [enable_poppler_qt4="yes"], - [enable_poppler_qt4="no"]) - if test x$enable_poppler_qt4 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT4_TEST, - QtTest >= 4.7.0, - [enable_poppler_qt4="yes"], - [enable_poppler_qt4="no"]) - fi -fi - -AC_SUBST(POPPLER_QT4_CXXFLAGS) -AC_SUBST(POPPLER_QT4_LIBS) -AC_SUBST(POPPLER_QT4_TEST_LIBS) - -if test x$enable_poppler_qt4 = xyes; then - AC_CHECK_TOOL(MOCQT4, moc) - AC_MSG_CHECKING([for Qt4 moc]) - mocversion=`$MOCQT4 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 4"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_MSG_RESULT([no]) - # moc was not the qt4 one, try with moc-qt4 - AC_CHECK_TOOL(MOCQT42, moc-qt4) - AC_MSG_CHECKING([for Qt4 moc-qt4]) - mocversion=`$MOCQT42 -v 2>&1` - mocversiongrep=`echo $mocversion | grep "Qt 4"` - if test x"$mocversiongrep" != x"$mocversion"; then - # no valid moc found - enable_poppler_qt4=no; - MOCQT4="not found" - else - MOCQT4=$MOCQT42 - fi - fi - AC_SUBST(MOCQT4) - AC_MSG_RESULT([$MOCQT4]) -fi - -AM_CONDITIONAL(BUILD_POPPLER_QT4, test "x$enable_poppler_qt4" = "xyes") - -dnl -dnl Try Qt5 -dnl - -AC_ARG_ENABLE(poppler-qt5, - AC_HELP_STRING([--disable-poppler-qt5], - [Don't compile poppler Qt5 wrapper.]), - enable_poppler_qt5=$enableval, - enable_poppler_qt5="try") -if test x$enable_poppler_qt5 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT5, - Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0) - PKG_CHECK_MODULES(POPPLER_QT5_TEST, - Qt5Test >= 5.0.0 ) -elif test x$enable_poppler_qt5 = xtry; then - PKG_CHECK_MODULES(POPPLER_QT5, - Qt5Core >= 5.0.0 Qt5Gui >= 5.0.0 Qt5Xml >= 5.0.0 Qt5Widgets >= 5.0.0, - [enable_poppler_qt5="yes"], - [enable_poppler_qt5="no"]) - if test x$enable_poppler_qt5 = xyes; then - PKG_CHECK_MODULES(POPPLER_QT5_TEST, - Qt5Test >= 5.0.0, - [enable_poppler_qt5="yes"], - [enable_poppler_qt5="no"]) - fi -fi - -AC_SUBST(POPPLER_QT5_CXXFLAGS) -AC_SUBST(POPPLER_QT5_LIBS) -AC_SUBST(POPPLER_QT5_TEST_LIBS) - -if test x$enable_poppler_qt5 = xyes; then - AC_CHECK_TOOL(MOCQT5, moc) - AC_MSG_CHECKING([for Qt5 moc]) - mocversion=`$MOCQT5 -v 2>&1` - mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_MSG_RESULT([no]) - # moc was not the qt5 one, try with moc-qt5 - AC_CHECK_TOOL(MOCQT52, moc-qt5) - AC_MSG_CHECKING([for Qt5 moc-qt5]) - mocversion=`$MOCQT52 -v 2>&1` - mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc-qt5 5|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - AC_CHECK_TOOL(QTCHOOSER, qtchooser) - AC_MSG_CHECKING([for qtchooser]) - qt5tooldir=`QT_SELECT=qt5 qtchooser -print-env | grep QTTOOLDIR | cut -d '=' -f 2 | cut -d \" -f 2` - mocversion=`$qt5tooldir/moc -v 2>&1` - mocversiongrep=`echo $mocversion | grep -E "Qt 5|moc 5"` - if test x"$mocversiongrep" != x"$mocversion"; then - # no valid moc found - enable_poppler_qt5=no; - MOCQT5="not found" - else - MOCQT5=$qt5tooldir/moc - fi - else - MOCQT5=$MOCQT52 - fi - fi - AC_SUBST(MOCQT5) - AC_MSG_RESULT([$MOCQT5]) -fi - -AM_CONDITIONAL(BUILD_POPPLER_QT5, test "x$enable_poppler_qt5" = "xyes") - -dnl -dnl CPP frontend -dnl - -AC_ARG_ENABLE(poppler-cpp, - AC_HELP_STRING([--disable-poppler-cpp], - [Don't compile poppler cpp wrapper.]), - enable_poppler_cpp=$enableval, - enable_poppler_cpp="yes") -if test x$enable_poppler_cpp = xyes; then - AM_ICONV() - if test x$am_func_iconv != xyes; then - enable_poppler_cpp=no - fi -fi - -AM_CONDITIONAL(BUILD_POPPLER_CPP, test "x$enable_poppler_cpp" = "xyes") - - -GTK_TEST_DEPS='gtk+-3.0 >= 3.8 gdk-pixbuf-2.0' -if test x$enable_cairo_output = xyes; then - GTK_TEST_DEPS="$GTK_TEST_DEPS $CAIRO_DEPS" -fi -AC_ARG_ENABLE(gtk-test, - AC_HELP_STRING([--disable-gtk-test], - [Don't compile GTK+ test program.]), - enable_gtk_test=$enableval, - enable_gtk_test="try") -if test x$enable_gtk_test = xyes; then - PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS) -elif test x$enable_gtk_test = xtry; then - PKG_CHECK_MODULES(GTK_TEST, $GTK_TEST_DEPS, - [enable_gtk_test="yes"], - [enable_gtk_test="no"]) -fi -AM_CONDITIONAL(BUILD_GTK_TEST, test x$enable_gtk_test = xyes -a x$enable_poppler_glib = xyes) - -AC_ARG_ENABLE(utils, - AC_HELP_STRING([--disable-utils], - [Don't compile poppler command line utils.]), - enable_utils=$enableval, - enable_utils="yes") -AM_CONDITIONAL(BUILD_UTILS, test x$enable_utils = xyes) - -AC_ARG_ENABLE(compile-warnings, - AC_HELP_STRING([--enable-compile-warnings=@<:@no/yes/kde@:>@], - [Turn on compiler warnings.]),, - [enable_compile_warnings="yes"]) - -dnl -dnl Color Management -dnl - -AC_ARG_ENABLE(cms, - AC_HELP_STRING([--enable-cms=@<:@auto/lcms1/lcms2/none@:>@], - [Use color management system. 'auto' prefers lcms2 over lcms1 if both are available [[default=auto]]]), - [enable_cms=$enableval], - [enable_cms="auto"]) -if test x$enable_cms = xauto; then - PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) - if test x$lcms2 = xno; then - PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) - fi -elif test x$enable_cms = xlcms1; then - PKG_CHECK_MODULES(LCMS, lcms, [lcms1=yes], [lcms1=no]) -elif test x$enable_cms = xlcms2; then - PKG_CHECK_MODULES(LCMS, lcms2, [lcms2=yes], [lcms2=no]) -fi - -if test x$lcms1 = xyes || test x$lcms2 = xyes; then - enable_cms=yes - AC_DEFINE(USE_CMS, 1, [Defines if use cms]) - if test x$lcms1 = xyes; then - lcms1=yes; - AC_DEFINE(USE_LCMS1, 1, [Defines if use lcms1]) - fi -else - enable_cms=no -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([--with-testdatadir=/path/to/testdatadir], - [Specify test data dir])], - [case $withval in - [[\\/]]* | ?:[[\\/]]* ) # Absolute name. - TESTDATADIR=$withval ;; - *) # Relative name. - TESTDATADIR=$ac_pwd/$withval ;; - esac - ], - [case $srcdir in - [[\\/]]* | ?:[[\\/]]* ) # Absolute name. - TESTDATADIR=$srcdir/../test ;; - *) # Relative name. - TESTDATADIR=$ac_pwd/$srcdir/../test ;; - esac - ] -) -AC_MSG_CHECKING([for test data in $TESTDATADIR]) -if test -d $TESTDATADIR && test -f $TESTDATADIR/test-poppler.c; then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) - AC_MSG_WARN([ - No test data found in $TESTDATADIR. - You will not be able to run 'make check' successfully. - - The test data is not included in the source packages - and is also not part of the main git repository. Instead, - you can checkout the test data from its own git - repository with: - - git clone git://git.freedesktop.org/git/poppler/test - - You should checkout the test data as a sibling of your - poppler source folder or specify the location of your - checkout with --with-testdatadir=/path/to/checkoutdir/test. -]) -fi -AC_SUBST(TESTDATADIR) - -# some compilers do not support this flag (see bug #76963) -fno_check_new= -AC_MSG_CHECKING([for -fno-check-new compiler flag]) -AC_LANG_PUSH([C++]) -saved_CXXFLAGS=$CXXFLAGS -CXXFLAGS="-fno-check-new $CXXFLAGS" -AC_TRY_COMPILE([], [], - [AC_MSG_RESULT([yes]) - fno_check_new="-fno-check-new"], - AC_MSG_RESULT([no]) -) -CXXFLAGS=$saved_CXXFLAGS -AC_LANG_POP - -if test "x$GCC" != xyes; then - enable_compile_warnings=no -fi -case "$enable_compile_warnings" in - no) ;; - yes) CXXFLAGS="-Wall -Woverloaded-virtual -Wnon-virtual-dtor -Wcast-align -fno-exceptions $fno_check_new -fno-common $CXXFLAGS"; - CFLAGS="-Wall $CFLAGS" ;; - kde) CXXFLAGS="-Wnon-virtual-dtor -Wno-long-long -Wundef \ - -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -Wcast-align \ - -Wconversion -Wall -W -Wpointer-arith \ - -Wwrite-strings -O2 -Wformat-security \ - -Wmissing-format-attribute -fno-exceptions $fno_check_new \ - -fno-common $CXXFLAGS" ;; -esac - -case "$host_os" in - mingw*|cygwin*) - # mingw and cygwin print "warning: -fPIC ignored for target (all code is position independent)" - # for every file - ;; - *) - CXXFLAGS="-fPIC $CXXFLAGS"; - ;; -esac - - -case `$PKG_CONFIG --version` in - 0.?|0.1[0-7]) - PC_REQUIRES_PRIVATE=""; - PC_REQUIRES="poppler = $VERSION";; - *) - PC_REQUIRES_PRIVATE="Requires.private: poppler = $VERSION"; - PC_REQUIRES="";; -esac - -AC_SUBST(PC_REQUIRES) -AC_SUBST(PC_REQUIRES_PRIVATE) - -AC_SUBST([POPPLER_MAJOR_VERSION],[poppler_version_major]) -AC_SUBST([POPPLER_MINOR_VERSION],[poppler_version_minor]) -AC_SUBST([POPPLER_MICRO_VERSION],[poppler_version_micro]) -AC_SUBST([POPPLER_VERSION],[poppler_version]) - -AC_OUTPUT([ -Makefile -goo/Makefile -fofi/Makefile -splash/Makefile -poppler/Makefile -utils/Makefile -glib/Makefile -glib/poppler-features.h -glib/reference/Makefile -glib/reference/version.xml -glib/demo/Makefile -test/Makefile -qt4/Makefile -qt4/src/Makefile -qt4/tests/Makefile -qt4/demos/Makefile -qt5/Makefile -qt5/src/Makefile -qt5/tests/Makefile -qt5/demos/Makefile -cpp/Makefile -cpp/poppler-version.h -cpp/tests/Makefile -poppler.pc -poppler-uninstalled.pc -poppler-cairo.pc -poppler-cairo-uninstalled.pc -poppler-splash.pc -poppler-splash-uninstalled.pc -poppler-glib.pc -poppler-glib-uninstalled.pc -poppler-qt4.pc -poppler-qt4-uninstalled.pc -poppler-qt5.pc -poppler-qt5-uninstalled.pc -poppler-cpp.pc -poppler-cpp-uninstalled.pc]) - - -echo "" -echo "Building poppler with support for:" -echo " font configuration: $with_font_configuration" -echo " splash output: $enable_splash_output" -if test x$enable_cmyk = xyes;then - echo " with CMYK support" -fi -echo " cairo output: $use_cairo" -echo " qt4 wrapper: $enable_poppler_qt4" -echo " qt5 wrapper: $enable_poppler_qt5" -echo " glib wrapper: $use_glib" -echo " introspection: $found_introspection" -echo " cpp wrapper: $enable_poppler_cpp" -echo " use gtk-doc: $enable_gtk_doc" -echo " use libjpeg: $enable_libjpeg" -echo " use libpng: $enable_libpng" -echo " use libtiff: $enable_libtiff" -echo " use zlib compress: $enable_zlib" -echo " use zlib uncompress: $enable_zlib_uncompress" -echo " use nss: $enable_nss" -echo " use libcurl: $enable_libcurl" -echo " use libopenjpeg: $enable_libopenjpeg" -if test x$enable_libopenjpeg = xyes;then - if test x$openjpeg1 = xyes;then - echo " with openjpeg1" - else - echo " with openjpeg2" - fi -fi -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 -if test x$enable_build_type != xno;then - echo " build type: $enable_build_type" -fi -echo " command line utils: $enable_utils" -echo " test data dir: $TESTDATADIR" -echo "" - -if test x$enable_splash_output = xno -a x$enable_cairo_output = xno; then - echo " Warning: There is no rendering backend enabled" -fi - -if test x$enable_single_precision = xyes -a x$enable_fixedpoint = xyes; then - echo " Warning: Single precision and fixed point options should not be enabled at the same time" -fi - -if test x$enable_libjpeg != xyes -a x$have_dct_decoder = xyes; then - echo " Warning: Using libjpeg is recommended. The internal DCT decoder is unmaintained." -fi - -if test x$have_dct_decoder = xno; then - echo " Warning: You're not compiling any DCT decoder. Some files will fail to display properly." -fi - -if test x$enable_zlib_uncompress != xno; then - echo " Warning: Using zlib for decompression is not totally safe" -fi - -if test x$enable_libopenjpeg != xyes -a x$have_jpx_decoder = xyes; then - echo " Warning: Using libopenjpeg2 is recommended. The internal JPX decoder is unmaintained." -fi - -if test x$have_jpx_decoder = xno; then - echo " Warning: You're not compiling any JPX decoder. Some files will fail to display properly." -fi diff --git a/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc b/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc index f1a15e004da0cc55a488fb58850abf6794e3aac9..2913295687d53bcfe59e94bdb1353519532ed682 100644 --- a/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc +++ b/source/libs/poppler/poppler-src/fofi/FoFiTrueType.cc @@ -16,7 +16,7 @@ // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> // Copyright (C) 2007 Koji Otani <sho@bbr.jp> // Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2008, 2009, 2012, 2014-2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2009, 2012, 2014-2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com> // Copyright (C) 2012 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> @@ -451,7 +451,7 @@ int FoFiTrueType::mapNameToGID(char *name) { GBool FoFiTrueType::getCFFBlock(char **start, int *length) { int i; - if (!openTypeCFF) { + if (!openTypeCFF || !tables) { return gFalse; } i = seekTable("CFF "); @@ -1307,8 +1307,10 @@ Guint FoFiTrueType::computeTableChecksum(Guchar *data, int length) { switch (length & 3) { case 3: word |= (data[i+2] & 0xff) << 8; + // fallthrough case 2: word |= (data[i+1] & 0xff) << 16; + // fallthrough case 1: word |= (data[i ] & 0xff) << 24; break; diff --git a/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc b/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc index c4595a3260ea6a6dec85edee29b15853d43595b0..7c9494f57c6ce09dc6c5c3ed1d72fefed25029d8 100644 --- a/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc +++ b/source/libs/poppler/poppler-src/fofi/FoFiType1C.cc @@ -13,7 +13,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009, 2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> // // To see a description of the changes please see the Changelog file that @@ -33,6 +33,7 @@ #include "goo/gmem.h" #include "goo/gstrtod.h" #include "goo/GooString.h" +#include "poppler/Error.h" #include "FoFiEncodings.h" #include "FoFiType1C.h" @@ -879,253 +880,260 @@ void FoFiType1C::convertToType0(char *psName, int *codeMap, int nCodes, } } + if (privateDicts) { // write the descendant Type 1 fonts - for (i = 0; i < nCIDs; i += 256) { - - //~ this assumes that all CIDs in this block have the same FD -- - //~ to handle multiple FDs correctly, need to somehow divide the - //~ font up by FD; as a kludge we ignore CID 0, which is .notdef - fd = 0; - // if fdSelect is NULL, we have an 8-bit font, so just leave fd=0 - if (fdSelect) { - for (j = i==0 ? 1 : 0; j < 256 && i+j < nCIDs; ++j) { - if (cidMap[i+j] >= 0) { - fd = fdSelect[cidMap[i+j]]; - break; - } + for (i = 0; i < nCIDs; i += 256) { + + //~ this assumes that all CIDs in this block have the same FD -- + //~ to handle multiple FDs correctly, need to somehow divide the + //~ font up by FD; as a kludge we ignore CID 0, which is .notdef + fd = 0; + // if fdSelect is NULL, we have an 8-bit font, so just leave fd=0 + if (fdSelect) { + for (j = i==0 ? 1 : 0; j < 256 && i+j < nCIDs; ++j) { + if (cidMap[i+j] >= 0) { + fd = fdSelect[cidMap[i+j]]; + break; + } + } } - } - // font dictionary (unencrypted section) - (*outputFunc)(outputStream, "16 dict begin\n", 14); - (*outputFunc)(outputStream, "/FontName /", 11); - (*outputFunc)(outputStream, psName, strlen(psName)); - buf = GooString::format("_{0:02x} def\n", i >> 8); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - (*outputFunc)(outputStream, "/FontType 1 def\n", 16); - if (privateDicts[fd].hasFontMatrix) { - buf = GooString::format("/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] def\n", - privateDicts[fd].fontMatrix[0], - privateDicts[fd].fontMatrix[1], - privateDicts[fd].fontMatrix[2], - privateDicts[fd].fontMatrix[3], - privateDicts[fd].fontMatrix[4], - privateDicts[fd].fontMatrix[5]); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - } else if (topDict.hasFontMatrix) { - (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); - } else { - (*outputFunc)(outputStream, - "/FontMatrix [0.001 0 0 0.001 0 0] def\n", 38); - } - buf = GooString::format("/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] def\n", - topDict.fontBBox[0], topDict.fontBBox[1], - topDict.fontBBox[2], topDict.fontBBox[3]); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - buf = GooString::format("/PaintType {0:d} def\n", topDict.paintType); - (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); - delete buf; - if (topDict.paintType != 0) { - buf = GooString::format("/StrokeWidth {0:.4g} def\n", topDict.strokeWidth); + if (fd >= nFDs) + continue; + + // font dictionary (unencrypted section) + (*outputFunc)(outputStream, "16 dict begin\n", 14); + (*outputFunc)(outputStream, "/FontName /", 11); + (*outputFunc)(outputStream, psName, strlen(psName)); + buf = GooString::format("_{0:02x} def\n", i >> 8); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; - } - (*outputFunc)(outputStream, "/Encoding 256 array\n", 20); - for (j = 0; j < 256 && i+j < nCIDs; ++j) { - buf = GooString::format("dup {0:d} /c{1:02x} put\n", j, j); + (*outputFunc)(outputStream, "/FontType 1 def\n", 16); + if (privateDicts[fd].hasFontMatrix) { + buf = GooString::format("/FontMatrix [{0:.8g} {1:.8g} {2:.8g} {3:.8g} {4:.8g} {5:.8g}] def\n", + privateDicts[fd].fontMatrix[0], + privateDicts[fd].fontMatrix[1], + privateDicts[fd].fontMatrix[2], + privateDicts[fd].fontMatrix[3], + privateDicts[fd].fontMatrix[4], + privateDicts[fd].fontMatrix[5]); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } else if (topDict.hasFontMatrix) { + (*outputFunc)(outputStream, "/FontMatrix [1 0 0 1 0 0] def\n", 30); + } else { + (*outputFunc)(outputStream, + "/FontMatrix [0.001 0 0 0.001 0 0] def\n", 38); + } + buf = GooString::format("/FontBBox [{0:.4g} {1:.4g} {2:.4g} {3:.4g}] def\n", + topDict.fontBBox[0], topDict.fontBBox[1], + topDict.fontBBox[2], topDict.fontBBox[3]); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; - } - if (j < 256) { - buf = GooString::format("{0:d} 1 255 {{ 1 index exch /.notdef put }} for\n", - j); + buf = GooString::format("/PaintType {0:d} def\n", topDict.paintType); (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); delete buf; - } - (*outputFunc)(outputStream, "readonly def\n", 13); - (*outputFunc)(outputStream, "currentdict end\n", 16); - - // start the binary section - (*outputFunc)(outputStream, "currentfile eexec\n", 18); - eb.outputFunc = outputFunc; - eb.outputStream = outputStream; - eb.ascii = gTrue; - eb.r1 = 55665; - eb.line = 0; - - // start the private dictionary - eexecWrite(&eb, "\x83\xca\x73\xd5"); - eexecWrite(&eb, "dup /Private 32 dict dup begin\n"); - eexecWrite(&eb, "/RD {string currentfile exch readstring pop}" - " executeonly def\n"); - eexecWrite(&eb, "/ND {noaccess def} executeonly def\n"); - eexecWrite(&eb, "/NP {noaccess put} executeonly def\n"); - eexecWrite(&eb, "/MinFeature {16 16} def\n"); - eexecWrite(&eb, "/password 5839 def\n"); - if (privateDicts[fd].nBlueValues) { - eexecWrite(&eb, "/BlueValues ["); - for (k = 0; k < privateDicts[fd].nBlueValues; ++k) { - buf = GooString::format("{0:s}{1:d}", - k > 0 ? " " : "", - privateDicts[fd].blueValues[k]); + if (topDict.paintType != 0) { + buf = GooString::format("/StrokeWidth {0:.4g} def\n", topDict.strokeWidth); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + (*outputFunc)(outputStream, "/Encoding 256 array\n", 20); + for (j = 0; j < 256 && i+j < nCIDs; ++j) { + buf = GooString::format("dup {0:d} /c{1:02x} put\n", j, j); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + if (j < 256) { + buf = GooString::format("{0:d} 1 255 {{ 1 index exch /.notdef put }} for\n", + j); + (*outputFunc)(outputStream, buf->getCString(), buf->getLength()); + delete buf; + } + (*outputFunc)(outputStream, "readonly def\n", 13); + (*outputFunc)(outputStream, "currentdict end\n", 16); + + // start the binary section + (*outputFunc)(outputStream, "currentfile eexec\n", 18); + eb.outputFunc = outputFunc; + eb.outputStream = outputStream; + eb.ascii = gTrue; + eb.r1 = 55665; + eb.line = 0; + + // start the private dictionary + eexecWrite(&eb, "\x83\xca\x73\xd5"); + eexecWrite(&eb, "dup /Private 32 dict dup begin\n"); + eexecWrite(&eb, "/RD {string currentfile exch readstring pop}" + " executeonly def\n"); + eexecWrite(&eb, "/ND {noaccess def} executeonly def\n"); + eexecWrite(&eb, "/NP {noaccess put} executeonly def\n"); + eexecWrite(&eb, "/MinFeature {16 16} def\n"); + eexecWrite(&eb, "/password 5839 def\n"); + if (privateDicts[fd].nBlueValues) { + eexecWrite(&eb, "/BlueValues ["); + for (k = 0; k < privateDicts[fd].nBlueValues; ++k) { + buf = GooString::format("{0:s}{1:d}", + k > 0 ? " " : "", + privateDicts[fd].blueValues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nOtherBlues) { + eexecWrite(&eb, "/OtherBlues ["); + for (k = 0; k < privateDicts[fd].nOtherBlues; ++k) { + buf = GooString::format("{0:s}{1:d}", + k > 0 ? " " : "", + privateDicts[fd].otherBlues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nFamilyBlues) { + eexecWrite(&eb, "/FamilyBlues ["); + for (k = 0; k < privateDicts[fd].nFamilyBlues; ++k) { + buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", + privateDicts[fd].familyBlues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nFamilyOtherBlues) { + eexecWrite(&eb, "/FamilyOtherBlues ["); + for (k = 0; k < privateDicts[fd].nFamilyOtherBlues; ++k) { + buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", + privateDicts[fd].familyOtherBlues[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].blueScale != 0.039625) { + buf = GooString::format("/BlueScale {0:.4g} def\n", + privateDicts[fd].blueScale); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nOtherBlues) { - eexecWrite(&eb, "/OtherBlues ["); - for (k = 0; k < privateDicts[fd].nOtherBlues; ++k) { - buf = GooString::format("{0:s}{1:d}", - k > 0 ? " " : "", - privateDicts[fd].otherBlues[k]); + if (privateDicts[fd].blueShift != 7) { + buf = GooString::format("/BlueShift {0:d} def\n", + privateDicts[fd].blueShift); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nFamilyBlues) { - eexecWrite(&eb, "/FamilyBlues ["); - for (k = 0; k < privateDicts[fd].nFamilyBlues; ++k) { - buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", - privateDicts[fd].familyBlues[k]); + if (privateDicts[fd].blueFuzz != 1) { + buf = GooString::format("/BlueFuzz {0:d} def\n", + privateDicts[fd].blueFuzz); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nFamilyOtherBlues) { - eexecWrite(&eb, "/FamilyOtherBlues ["); - for (k = 0; k < privateDicts[fd].nFamilyOtherBlues; ++k) { - buf = GooString::format("{0:s}{1:d}", k > 0 ? " " : "", - privateDicts[fd].familyOtherBlues[k]); + if (privateDicts[fd].hasStdHW) { + buf = GooString::format("/StdHW [{0:.4g}] def\n", privateDicts[fd].stdHW); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].blueScale != 0.039625) { - buf = GooString::format("/BlueScale {0:.4g} def\n", - privateDicts[fd].blueScale); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].blueShift != 7) { - buf = GooString::format("/BlueShift {0:d} def\n", - privateDicts[fd].blueShift); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].blueFuzz != 1) { - buf = GooString::format("/BlueFuzz {0:d} def\n", - privateDicts[fd].blueFuzz); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].hasStdHW) { - buf = GooString::format("/StdHW [{0:.4g}] def\n", privateDicts[fd].stdHW); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].hasStdVW) { - buf = GooString::format("/StdVW [{0:.4g}] def\n", privateDicts[fd].stdVW); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].nStemSnapH) { - eexecWrite(&eb, "/StemSnapH ["); - for (k = 0; k < privateDicts[fd].nStemSnapH; ++k) { - buf = GooString::format("{0:s}{1:.4g}", - k > 0 ? " " : "", privateDicts[fd].stemSnapH[k]); + if (privateDicts[fd].hasStdVW) { + buf = GooString::format("/StdVW [{0:.4g}] def\n", privateDicts[fd].stdVW); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].nStemSnapV) { - eexecWrite(&eb, "/StemSnapV ["); - for (k = 0; k < privateDicts[fd].nStemSnapV; ++k) { - buf = GooString::format("{0:s}{1:.4g}", - k > 0 ? " " : "", privateDicts[fd].stemSnapV[k]); + if (privateDicts[fd].nStemSnapH) { + eexecWrite(&eb, "/StemSnapH ["); + for (k = 0; k < privateDicts[fd].nStemSnapH; ++k) { + buf = GooString::format("{0:s}{1:.4g}", + k > 0 ? " " : "", privateDicts[fd].stemSnapH[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].nStemSnapV) { + eexecWrite(&eb, "/StemSnapV ["); + for (k = 0; k < privateDicts[fd].nStemSnapV; ++k) { + buf = GooString::format("{0:s}{1:.4g}", + k > 0 ? " " : "", privateDicts[fd].stemSnapV[k]); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + eexecWrite(&eb, "] def\n"); + } + if (privateDicts[fd].hasForceBold) { + buf = GooString::format("/ForceBold {0:s} def\n", + privateDicts[fd].forceBold ? "true" : "false"); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[fd].forceBoldThreshold != 0) { + buf = GooString::format("/ForceBoldThreshold {0:.4g} def\n", + privateDicts[fd].forceBoldThreshold); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[fd].languageGroup != 0) { + buf = GooString::format("/LanguageGroup {0:d} def\n", + privateDicts[fd].languageGroup); + eexecWrite(&eb, buf->getCString()); + delete buf; + } + if (privateDicts[fd].expansionFactor != 0.06) { + buf = GooString::format("/ExpansionFactor {0:.4g} def\n", + privateDicts[fd].expansionFactor); eexecWrite(&eb, buf->getCString()); delete buf; } - eexecWrite(&eb, "] def\n"); - } - if (privateDicts[fd].hasForceBold) { - buf = GooString::format("/ForceBold {0:s} def\n", - privateDicts[fd].forceBold ? "true" : "false"); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].forceBoldThreshold != 0) { - buf = GooString::format("/ForceBoldThreshold {0:.4g} def\n", - privateDicts[fd].forceBoldThreshold); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].languageGroup != 0) { - buf = GooString::format("/LanguageGroup {0:d} def\n", - privateDicts[fd].languageGroup); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - if (privateDicts[fd].expansionFactor != 0.06) { - buf = GooString::format("/ExpansionFactor {0:.4g} def\n", - privateDicts[fd].expansionFactor); - eexecWrite(&eb, buf->getCString()); - delete buf; - } - // set up the subroutines - ok = gTrue; - getIndex(privateDicts[fd].subrsOffset, &subrIdx, &ok); - if (!ok) { - subrIdx.pos = -1; - } + // set up the subroutines + ok = gTrue; + getIndex(privateDicts[fd].subrsOffset, &subrIdx, &ok); + if (!ok) { + subrIdx.pos = -1; + } - // start the CharStrings - eexecWrite(&eb, "2 index /CharStrings 256 dict dup begin\n"); + // start the CharStrings + eexecWrite(&eb, "2 index /CharStrings 256 dict dup begin\n"); - // write the .notdef CharString - ok = gTrue; - getIndexVal(&charStringsIdx, 0, &val, &ok); - if (ok) { - eexecCvtGlyph(&eb, ".notdef", val.pos, val.len, - &subrIdx, &privateDicts[fd]); - } - - // write the CharStrings - for (j = 0; j < 256 && i+j < nCIDs; ++j) { - if (cidMap[i+j] >= 0) { - ok = gTrue; - getIndexVal(&charStringsIdx, cidMap[i+j], &val, &ok); - if (ok) { - buf = GooString::format("c{0:02x}", j); - eexecCvtGlyph(&eb, buf->getCString(), val.pos, val.len, - &subrIdx, &privateDicts[fd]); - delete buf; - } + // write the .notdef CharString + ok = gTrue; + getIndexVal(&charStringsIdx, 0, &val, &ok); + if (ok) { + eexecCvtGlyph(&eb, ".notdef", val.pos, val.len, + &subrIdx, &privateDicts[fd]); } - } - eexecWrite(&eb, "end\n"); - eexecWrite(&eb, "end\n"); - eexecWrite(&eb, "readonly put\n"); - eexecWrite(&eb, "noaccess put\n"); - eexecWrite(&eb, "dup /FontName get exch definefont pop\n"); - eexecWrite(&eb, "mark currentfile closefile\n"); - // trailer - if (eb.line > 0) { - (*outputFunc)(outputStream, "\n", 1); - } - for (j = 0; j < 8; ++j) { - (*outputFunc)(outputStream, "0000000000000000000000000000000000000000000000000000000000000000\n", 65); + // write the CharStrings + for (j = 0; j < 256 && i+j < nCIDs; ++j) { + if (cidMap[i+j] >= 0) { + ok = gTrue; + getIndexVal(&charStringsIdx, cidMap[i+j], &val, &ok); + if (ok) { + buf = GooString::format("c{0:02x}", j); + eexecCvtGlyph(&eb, buf->getCString(), val.pos, val.len, + &subrIdx, &privateDicts[fd]); + delete buf; + } + } + } + eexecWrite(&eb, "end\n"); + eexecWrite(&eb, "end\n"); + eexecWrite(&eb, "readonly put\n"); + eexecWrite(&eb, "noaccess put\n"); + eexecWrite(&eb, "dup /FontName get exch definefont pop\n"); + eexecWrite(&eb, "mark currentfile closefile\n"); + + // trailer + if (eb.line > 0) { + (*outputFunc)(outputStream, "\n", 1); + } + for (j = 0; j < 8; ++j) { + (*outputFunc)(outputStream, "0000000000000000000000000000000000000000000000000000000000000000\n", 65); + } + (*outputFunc)(outputStream, "cleartomark\n", 12); } - (*outputFunc)(outputStream, "cleartomark\n", 12); + } else { + error(errSyntaxError, -1, "FoFiType1C::convertToType0 without privateDicts"); } // write the Type 0 parent font diff --git a/source/libs/poppler/poppler-src/fofi/Makefile.am b/source/libs/poppler/poppler-src/fofi/Makefile.am deleted file mode 100644 index 4deb7d5e0639cab108a113c1fb484a7a38f44ada..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/fofi/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -noinst_LTLIBRARIES = libfofi.la - -if ENABLE_XPDF_HEADERS -poppler_fofi_includedir = $(includedir)/poppler/fofi -poppler_fofi_include_HEADERS = \ - FoFiBase.h \ - FoFiEncodings.h \ - FoFiTrueType.h \ - FoFiType1.h \ - FoFiIdentifier.h \ - FoFiType1C.h -endif - -libfofi_la_SOURCES = \ - FoFiBase.cc \ - FoFiBase.h \ - FoFiEncodings.cc \ - FoFiEncodings.h \ - FoFiTrueType.cc \ - FoFiTrueType.h \ - FoFiType1.cc \ - FoFiType1.h \ - FoFiType1C.cc \ - FoFiIdentifier.cc \ - FoFiType1C.h - -libfofi_la_CPPFLAGS = \ - -I$(top_srcdir) diff --git a/source/libs/poppler/poppler-src/goo/GooString.cc b/source/libs/poppler/poppler-src/goo/GooString.cc index 12592e4902f7136e241f4f9153cece4ad0a552a4..f055b37f4580f1a9b12b32be5d2742790d180106 100644 --- a/source/libs/poppler/poppler-src/goo/GooString.cc +++ b/source/libs/poppler/poppler-src/goo/GooString.cc @@ -18,7 +18,7 @@ // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> // Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> -// Copyright (C) 2008-2011, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008-2011, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2011 Kenji Uno <ku@digitaldolphins.jp> // Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> @@ -917,7 +917,13 @@ GBool GooString::hasUnicodeMarker(void) const return length > 1 && (s[0] & 0xff) == 0xfe && (s[1] & 0xff) == 0xff; } -GooString *GooString::sanitizedName(GBool psmode) +void GooString::prependUnicodeMarker() +{ + insert(0, (char)0xff); + insert(0, (char)0xfe); +} + +GooString *GooString::sanitizedName(GBool psmode) const { GooString *name; char buf[8]; diff --git a/source/libs/poppler/poppler-src/goo/GooString.h b/source/libs/poppler/poppler-src/goo/GooString.h index 70cfe3b47bdc0d6a29939773ead2e0417cca4707..167ea1ab6bdfed1f8f27845e211b5477b4d9dc37 100644 --- a/source/libs/poppler/poppler-src/goo/GooString.h +++ b/source/libs/poppler/poppler-src/goo/GooString.h @@ -17,7 +17,7 @@ // // Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> -// Copyright (C) 2008-2010, 2012, 2014 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008-2010, 2012, 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2012-2014 Fabio D'Urso <fabiodurso@hotmail.it> // Copyright (C) 2013 Jason Crain <jason@aquaticape.us> // Copyright (C) 2015 Adam Reichold <adam.reichold@t-online.de> @@ -176,13 +176,14 @@ public: GBool endsWith(const char *suffix) const; GBool hasUnicodeMarker(void) const; + void prependUnicodeMarker(); GBool hasJustUnicodeMarker(void) const { return length == 2 && hasUnicodeMarker(); } // Sanitizes the string so that it does // not contain any ( ) < > [ ] { } / % // The postscript mode also has some more strict checks // The caller owns the return value - GooString *sanitizedName(GBool psmode); + GooString *sanitizedName(GBool psmode) const; private: GooString(const GooString &other); diff --git a/source/libs/poppler/poppler-src/goo/JpegWriter.cc b/source/libs/poppler/poppler-src/goo/JpegWriter.cc index a5a4d5a6f5a2fde344e5f3a3b3f1a426a55b9ae3..37c15c2ab85b630d98f9b05157cb689121af50a7 100644 --- a/source/libs/poppler/poppler-src/goo/JpegWriter.cc +++ b/source/libs/poppler/poppler-src/goo/JpegWriter.cc @@ -9,6 +9,7 @@ // Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org> // Copyright (C) 2011 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2013 Peter Breitenlohner <peb@mppmu.mpg.de> +// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -30,7 +31,7 @@ struct JpegWriterPrivate { struct jpeg_error_mgr jerr; }; -void outputMessage(j_common_ptr cinfo) +static void outputMessage(j_common_ptr cinfo) { char buffer[JMSG_LENGTH_MAX]; diff --git a/source/libs/poppler/poppler-src/goo/Makefile.am b/source/libs/poppler/poppler-src/goo/Makefile.am deleted file mode 100644 index 004775a487cfd5f5c03ef3c107f457287ba19ef1..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/goo/Makefile.am +++ /dev/null @@ -1,69 +0,0 @@ -noinst_LTLIBRARIES = libgoo.la - -if ENABLE_XPDF_HEADERS - -poppler_goo_includedir = $(includedir)/poppler/goo -poppler_goo_include_HEADERS = \ - GooHash.h \ - GooList.h \ - GooTimer.h \ - GooMutex.h \ - GooString.h \ - gtypes.h \ - gmem.h \ - gfile.h \ - FixedPoint.h \ - NetPBMWriter.h \ - PNGWriter.h \ - JpegWriter.h \ - TiffWriter.h \ - ImgWriter.h \ - GooLikely.h \ - gstrtod.h \ - grandom.h - -endif - -libgoo_la_SOURCES = \ - gfile.cc \ - gmempp.cc \ - GooHash.cc \ - GooList.cc \ - GooTimer.cc \ - GooString.cc \ - gmem.cc \ - FixedPoint.cc \ - NetPBMWriter.cc \ - PNGWriter.cc \ - JpegWriter.cc \ - TiffWriter.cc \ - ImgWriter.cc \ - gtypes_p.h \ - gstrtod.cc \ - grandom.cc \ - glibc.cc - -if BUILD_LIBJPEG -libjpeg_includes = $(LIBJPEG_CFLAGS) -endif - -if BUILD_LIBTIFF -libtiff_includes = $(LIBTIFF_CFLAGS) -endif - -if BUILD_LIBOPENJPEG -libjpeg2000_includes = $(LIBOPENJPEG_CFLAGS) -endif - -if BUILD_LIBPNG -libpng_includes = $(LIBPNG_CFLAGS) -endif - -libgoo_la_CPPFLAGS = \ - -I$(top_srcdir) \ - $(libjpeg_includes) \ - $(libtiff_includes) \ - $(libjpeg2000_includes) \ - $(libpng_includes) - -EXTRA_DIST = glibc.h \ No newline at end of file diff --git a/source/libs/poppler/poppler-src/goo/glibc.h b/source/libs/poppler/poppler-src/goo/glibc.h index 49479e9d2a632921f4a41a31ae998c4f20282941..45aff9df03cb2cb4c924a54ad6076db760257429 100644 --- a/source/libs/poppler/poppler-src/goo/glibc.h +++ b/source/libs/poppler/poppler-src/goo/glibc.h @@ -31,7 +31,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *result); time_t timegm(struct tm *tm); #endif -}; +} #endif // GLIBC_H diff --git a/source/libs/poppler/poppler-src/goo/gmem.h b/source/libs/poppler/poppler-src/goo/gmem.h index 898f33933f961807ce177d067968b8aa1b3c5751..4c76f0fb65e330803f0d1d179578fc953058323d 100644 --- a/source/libs/poppler/poppler-src/goo/gmem.h +++ b/source/libs/poppler/poppler-src/goo/gmem.h @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2007-2010 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2007-2010, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> // // To see a description of the changes please see the Changelog file that @@ -44,7 +44,7 @@ extern void *gmalloc_checkoverflow(size_t size); * returns NULL. If <p> is NULL, calls malloc instead of realloc(). */ extern void *grealloc(void *p, size_t size); -extern void *grealloc_checkoverflow(size_t size); +extern void *grealloc_checkoverflow(void *p, size_t size); /* * These are similar to gmalloc and grealloc, but take an object count diff --git a/source/libs/poppler/poppler-src/gtk-doc.make b/source/libs/poppler/poppler-src/gtk-doc.make deleted file mode 100644 index 2454c285797e53af46fdfd8a29584588c81911ed..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/gtk-doc.make +++ /dev/null @@ -1,305 +0,0 @@ -# -*- mode: makefile -*- - -#################################### -# Everything below here is generic # -#################################### - -if GTK_DOC_USE_LIBTOOL -GTKDOC_CC = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -GTKDOC_LD = $(LIBTOOL) --tag=CC --mode=link $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -GTKDOC_RUN = $(LIBTOOL) --mode=execute -else -GTKDOC_CC = $(CC) $(INCLUDES) $(GTKDOC_DEPS_CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -GTKDOC_LD = $(CC) $(GTKDOC_DEPS_LIBS) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -GTKDOC_RUN = -endif - -# We set GPATH here; this gives us semantics for GNU make -# which are more like other make's VPATH, when it comes to -# whether a source that is a target of one rule is then -# searched for in VPATH/GPATH. -# -GPATH = $(srcdir) - -TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE) - -SETUP_FILES = \ - $(content_files) \ - $(expand_content_files) \ - $(DOC_MAIN_SGML_FILE) \ - $(DOC_MODULE)-sections.txt \ - $(DOC_MODULE)-overrides.txt - -EXTRA_DIST = \ - $(HTML_IMAGES) \ - $(SETUP_FILES) - -DOC_STAMPS=setup-build.stamp scan-build.stamp sgml-build.stamp \ - html-build.stamp pdf-build.stamp \ - sgml.stamp html.stamp pdf.stamp - -SCANOBJ_FILES = \ - $(DOC_MODULE).args \ - $(DOC_MODULE).hierarchy \ - $(DOC_MODULE).interfaces \ - $(DOC_MODULE).prerequisites \ - $(DOC_MODULE).signals - -REPORT_FILES = \ - $(DOC_MODULE)-undocumented.txt \ - $(DOC_MODULE)-undeclared.txt \ - $(DOC_MODULE)-unused.txt - -gtkdoc-check.test: Makefile - $(AM_V_GEN)echo "#!/bin/sh -e" > $@; \ - echo "$(GTKDOC_CHECK_PATH) || exit 1" >> $@; \ - chmod +x $@ - -CLEANFILES = $(SCANOBJ_FILES) $(REPORT_FILES) $(DOC_STAMPS) gtkdoc-check.test - -if GTK_DOC_BUILD_HTML -HTML_BUILD_STAMP=html-build.stamp -else -HTML_BUILD_STAMP= -endif -if GTK_DOC_BUILD_PDF -PDF_BUILD_STAMP=pdf-build.stamp -else -PDF_BUILD_STAMP= -endif - -all-gtk-doc: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) -.PHONY: all-gtk-doc - -if ENABLE_GTK_DOC -all-local: all-gtk-doc -endif - -docs: $(HTML_BUILD_STAMP) $(PDF_BUILD_STAMP) - -$(REPORT_FILES): sgml-build.stamp - -#### setup #### - -GTK_DOC_V_SETUP=$(GTK_DOC_V_SETUP_$(V)) -GTK_DOC_V_SETUP_=$(GTK_DOC_V_SETUP_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_SETUP_0=@echo " DOC Preparing build"; - -setup-build.stamp: - -$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ - files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \ - if test "x$$files" != "x" ; then \ - for file in $$files ; do \ - destdir=`dirname $(abs_builddir)/$$file`; \ - test -d "$$destdir" || mkdir -p "$$destdir"; \ - test -f $(abs_srcdir)/$$file && \ - cp -pf $(abs_srcdir)/$$file $(abs_builddir)/$$file || true; \ - done; \ - fi; \ - fi - $(AM_V_at)touch setup-build.stamp - - -#### scan #### - -GTK_DOC_V_SCAN=$(GTK_DOC_V_SCAN_$(V)) -GTK_DOC_V_SCAN_=$(GTK_DOC_V_SCAN_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_SCAN_0=@echo " DOC Scanning header files"; - -GTK_DOC_V_INTROSPECT=$(GTK_DOC_V_INTROSPECT_$(V)) -GTK_DOC_V_INTROSPECT_=$(GTK_DOC_V_INTROSPECT_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_INTROSPECT_0=@echo " DOC Introspecting gobjects"; - -scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB) - $(GTK_DOC_V_SCAN)_source_dir='' ; \ - for i in $(DOC_SOURCE_DIR) ; do \ - _source_dir="$${_source_dir} --source-dir=$$i" ; \ - done ; \ - gtkdoc-scan --module=$(DOC_MODULE) --ignore-headers="$(IGNORE_HFILES)" $${_source_dir} $(SCAN_OPTIONS) $(EXTRA_HFILES) - $(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \ - scanobj_options=""; \ - gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$$?" = "0"; then \ - if test "x$(V)" = "x1"; then \ - scanobj_options="--verbose"; \ - fi; \ - fi; \ - CC="$(GTKDOC_CC)" LD="$(GTKDOC_LD)" RUN="$(GTKDOC_RUN)" CFLAGS="$(GTKDOC_CFLAGS) $(CFLAGS)" LDFLAGS="$(GTKDOC_LIBS) $(LDFLAGS)" \ - gtkdoc-scangobj $(SCANGOBJ_OPTIONS) $$scanobj_options --module=$(DOC_MODULE); \ - else \ - for i in $(SCANOBJ_FILES) ; do \ - test -f $$i || touch $$i ; \ - done \ - fi - $(AM_V_at)touch scan-build.stamp - -$(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt: scan-build.stamp - @true - -#### xml #### - -GTK_DOC_V_XML=$(GTK_DOC_V_XML_$(V)) -GTK_DOC_V_XML_=$(GTK_DOC_V_XML_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_XML_0=@echo " DOC Building XML"; - -sgml-build.stamp: setup-build.stamp $(DOC_MODULE)-decl.txt $(SCANOBJ_FILES) $(HFILE_GLOB) $(CFILE_GLOB) $(DOC_MODULE)-sections.txt $(DOC_MODULE)-overrides.txt $(expand_content_files) xml/gtkdocentities.ent - $(GTK_DOC_V_XML)_source_dir='' ; \ - for i in $(DOC_SOURCE_DIR) ; do \ - _source_dir="$${_source_dir} --source-dir=$$i" ; \ - done ; \ - gtkdoc-mkdb --module=$(DOC_MODULE) --output-format=xml --expand-content-files="$(expand_content_files)" --main-sgml-file=$(DOC_MAIN_SGML_FILE) $${_source_dir} $(MKDB_OPTIONS) - $(AM_V_at)touch sgml-build.stamp - -sgml.stamp: sgml-build.stamp - @true - -xml/gtkdocentities.ent: Makefile - $(GTK_DOC_V_XML)$(MKDIR_P) $(@D) && ( \ - echo "<!ENTITY package \"$(PACKAGE)\">"; \ - echo "<!ENTITY package_bugreport \"$(PACKAGE_BUGREPORT)\">"; \ - echo "<!ENTITY package_name \"$(PACKAGE_NAME)\">"; \ - echo "<!ENTITY package_string \"$(PACKAGE_STRING)\">"; \ - echo "<!ENTITY package_tarname \"$(PACKAGE_TARNAME)\">"; \ - echo "<!ENTITY package_url \"$(PACKAGE_URL)\">"; \ - echo "<!ENTITY package_version \"$(PACKAGE_VERSION)\">"; \ - ) > $@ - -#### html #### - -GTK_DOC_V_HTML=$(GTK_DOC_V_HTML_$(V)) -GTK_DOC_V_HTML_=$(GTK_DOC_V_HTML_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_HTML_0=@echo " DOC Building HTML"; - -GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_$(V)) -GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references"; - -html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files) - $(GTK_DOC_V_HTML)rm -rf html && mkdir html && \ - mkhtml_options=""; \ - gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$$?" = "0"; then \ - if test "x$(V)" = "x1"; then \ - mkhtml_options="$$mkhtml_options --verbose"; \ - fi; \ - fi; \ - gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \ - if test "$$?" = "0"; then \ - mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \ - fi; \ - cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE) - -@test "x$(HTML_IMAGES)" = "x" || \ - for file in $(HTML_IMAGES) ; do \ - if test -f $(abs_srcdir)/$$file ; then \ - cp $(abs_srcdir)/$$file $(abs_builddir)/html; \ - fi; \ - if test -f $(abs_builddir)/$$file ; then \ - cp $(abs_builddir)/$$file $(abs_builddir)/html; \ - fi; \ - test -f $$file && cp $$file $(abs_builddir)/html; \ - done; - $(GTK_DOC_V_XREF)gtkdoc-fixxref --module=$(DOC_MODULE) --module-dir=html --html-dir=$(HTML_DIR) $(FIXXREF_OPTIONS) - $(AM_V_at)touch html-build.stamp - -#### pdf #### - -GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_$(V)) -GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_$(AM_DEFAULT_VERBOSITY)) -GTK_DOC_V_PDF_0=@echo " DOC Building PDF"; - -pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files) - $(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \ - mkpdf_options=""; \ - gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \ - if test "$$?" = "0"; then \ - if test "x$(V)" = "x1"; then \ - mkpdf_options="$$mkpdf_options --verbose"; \ - fi; \ - fi; \ - if test "x$(HTML_IMAGES)" != "x"; then \ - for img in $(HTML_IMAGES); do \ - part=`dirname $$img`; \ - echo $$mkpdf_options | grep >/dev/null "\-\-imgdir=$$part "; \ - if test $$? != 0; then \ - mkpdf_options="$$mkpdf_options --imgdir=$$part"; \ - fi; \ - done; \ - fi; \ - gtkdoc-mkpdf --path="$(abs_srcdir)" $$mkpdf_options $(DOC_MODULE) $(DOC_MAIN_SGML_FILE) $(MKPDF_OPTIONS) - $(AM_V_at)touch pdf-build.stamp - -############## - -clean-local: - @rm -f *~ *.bak - @rm -rf .libs - @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \ - rm -f $(DOC_MODULE).types; \ - fi - @if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \ - rm -f $(DOC_MODULE)-sections.txt; \ - fi - -distclean-local: - @rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \ - $(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt - @if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \ - rm -f $(SETUP_FILES) $(DOC_MODULE).types; \ - fi - -maintainer-clean-local: - @rm -rf xml html - -install-data-local: - @installfiles=`echo $(builddir)/html/*`; \ - if test "$$installfiles" = '$(builddir)/html/*'; \ - then echo 1>&2 'Nothing to install' ; \ - else \ - if test -n "$(DOC_MODULE_VERSION)"; then \ - installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ - else \ - installdir="$(DESTDIR)$(TARGET_DIR)"; \ - fi; \ - $(mkinstalldirs) $${installdir} ; \ - for i in $$installfiles; do \ - echo ' $(INSTALL_DATA) '$$i ; \ - $(INSTALL_DATA) $$i $${installdir}; \ - done; \ - if test -n "$(DOC_MODULE_VERSION)"; then \ - mv -f $${installdir}/$(DOC_MODULE).devhelp2 \ - $${installdir}/$(DOC_MODULE)-$(DOC_MODULE_VERSION).devhelp2; \ - fi; \ - $(GTKDOC_REBASE) --relative --dest-dir=$(DESTDIR) --html-dir=$${installdir}; \ - fi - -uninstall-local: - @if test -n "$(DOC_MODULE_VERSION)"; then \ - installdir="$(DESTDIR)$(TARGET_DIR)-$(DOC_MODULE_VERSION)"; \ - else \ - installdir="$(DESTDIR)$(TARGET_DIR)"; \ - fi; \ - rm -rf $${installdir} - -# -# Require gtk-doc when making dist -# -if HAVE_GTK_DOC -dist-check-gtkdoc: docs -else -dist-check-gtkdoc: - @echo "*** gtk-doc is needed to run 'make dist'. ***" - @echo "*** gtk-doc was not found when 'configure' ran. ***" - @echo "*** please install gtk-doc and rerun 'configure'. ***" - @false -endif - -dist-hook: dist-check-gtkdoc all-gtk-doc dist-hook-local - @mkdir $(distdir)/html - @cp ./html/* $(distdir)/html - @-cp ./$(DOC_MODULE).pdf $(distdir)/ - @-cp ./$(DOC_MODULE).types $(distdir)/ - @-cp ./$(DOC_MODULE)-sections.txt $(distdir)/ - @cd $(distdir) && rm -f $(DISTCLEANFILES) - @$(GTKDOC_REBASE) --online --relative --html-dir=$(distdir)/html - -.PHONY : dist-hook-local docs diff --git a/source/libs/poppler/poppler-src/poppler-cairo-uninstalled.pc.in b/source/libs/poppler/poppler-src/poppler-cairo-uninstalled.pc.in deleted file mode 100644 index 2458eb20df834958a4b4e92cf224616775f4bb3d..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-cairo-uninstalled.pc.in +++ /dev/null @@ -1,6 +0,0 @@ -Name: poppler-cairo -Description: Cairo backend for Poppler PDF rendering library - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ cairo >= @CAIRO_VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/poppler/libpoppler-cairo.la diff --git a/source/libs/poppler/poppler-src/poppler-cairo.pc.cmake b/source/libs/poppler/poppler-src/poppler-cairo.pc.cmake deleted file mode 100644 index b32f118314b81d500d40415185c618af226d81f2..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-cairo.pc.cmake +++ /dev/null @@ -1,9 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler-cairo -Description: Cairo backend for Poppler PDF rendering library -Version: @POPPLER_VERSION@ -Requires: poppler = @POPPLER_VERSION@ cairo >= @CAIRO_VERSION@ diff --git a/source/libs/poppler/poppler-src/poppler-cairo.pc.in b/source/libs/poppler/poppler-src/poppler-cairo.pc.in deleted file mode 100644 index 367a5b690bfb3c15146f7977f60d9dfdcffefbe1..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-cairo.pc.in +++ /dev/null @@ -1,9 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-cairo -Description: Cairo backend for Poppler PDF rendering library -Version: @VERSION@ -Requires: poppler = @VERSION@ cairo >= @CAIRO_VERSION@ diff --git a/source/libs/poppler/poppler-src/poppler-cpp-uninstalled.pc.in b/source/libs/poppler/poppler-src/poppler-cpp-uninstalled.pc.in deleted file mode 100644 index af3640eb2c1dea9ac6e25dc6a501fd58403d140d..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-cpp-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-cpp -Description: cpp backend for Poppler PDF rendering library - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/cpp/libpoppler-cpp.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/cpp diff --git a/source/libs/poppler/poppler-src/poppler-cpp.pc.cmake b/source/libs/poppler/poppler-src/poppler-cpp.pc.cmake deleted file mode 100644 index 3f56b3d9d903210996f4a07aac551fd97748ea1d..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-cpp.pc.cmake +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler-cpp -Description: cpp backend for Poppler PDF rendering library -Version: @POPPLER_VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-cpp -Cflags: -I${includedir}/poppler/cpp diff --git a/source/libs/poppler/poppler-src/poppler-cpp.pc.in b/source/libs/poppler/poppler-src/poppler-cpp.pc.in deleted file mode 100644 index a7e97c25dfe9954d6624e5c486c623985254abe0..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-cpp.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-cpp -Description: cpp backend for Poppler PDF rendering library -Version: @VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-cpp -Cflags: -I${includedir}/poppler/cpp diff --git a/source/libs/poppler/poppler-src/poppler-glib-uninstalled.pc.in b/source/libs/poppler/poppler-src/poppler-glib-uninstalled.pc.in deleted file mode 100644 index 5506c4e53ac6d7892221ac383f19f86e7e7ed471..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-glib-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-glib -Description: GLib wrapper for poppler - uninstalled -Version: @VERSION@ -Requires: glib-2.0 >= @GLIB_REQUIRED@ gobject-2.0 >= @GLIB_REQUIRED@ gio-2.0 >= @GLIB_REQUIRED@ cairo >= @CAIRO_VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/glib/libpoppler-glib.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/glib diff --git a/source/libs/poppler/poppler-src/poppler-glib.pc.cmake b/source/libs/poppler/poppler-src/poppler-glib.pc.cmake deleted file mode 100644 index e15e6699a433321334f3af77449895c050c3b92f..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-glib.pc.cmake +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler-glib -Description: GLib wrapper for poppler -Version: @POPPLER_VERSION@ -Requires: glib-2.0 >= @GLIB_REQUIRED@ gobject-2.0 >= @GLIB_REQUIRED@ cairo >= @CAIRO_VERSION@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-glib -Cflags: -I${includedir}/poppler/glib diff --git a/source/libs/poppler/poppler-src/poppler-glib.pc.in b/source/libs/poppler/poppler-src/poppler-glib.pc.in deleted file mode 100644 index cd30feb728f26e16e169b1544f4c01758a2886dd..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-glib.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-glib -Description: GLib wrapper for poppler -Version: @VERSION@ -Requires: glib-2.0 >= @GLIB_REQUIRED@ gobject-2.0 >= @GLIB_REQUIRED@ gio-2.0 >= @GLIB_REQUIRED@ cairo >= @CAIRO_VERSION@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-glib -Cflags: -I${includedir}/poppler/glib diff --git a/source/libs/poppler/poppler-src/poppler-qt4-uninstalled.pc.in b/source/libs/poppler/poppler-src/poppler-qt4-uninstalled.pc.in deleted file mode 100644 index 3a336c6c294195652e50e23ecf8d05053e3f6582..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-qt4-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-qt4 -Description: Qt4 bindings for poppler - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/qt4/src/libpoppler-qt4.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/qt4/src diff --git a/source/libs/poppler/poppler-src/poppler-qt4.pc.cmake b/source/libs/poppler/poppler-src/poppler-qt4.pc.cmake deleted file mode 100644 index b17fd5d84533ecee2b047235a66acd6ab433110d..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-qt4.pc.cmake +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler-qt4 -Description: Qt4 bindings for poppler -Version: @POPPLER_VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-qt4 -Cflags: -I${includedir}/poppler/qt4 diff --git a/source/libs/poppler/poppler-src/poppler-qt4.pc.in b/source/libs/poppler/poppler-src/poppler-qt4.pc.in deleted file mode 100644 index 306ae46e0b024643c3167204b03b25b84021f2b6..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-qt4.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-qt4 -Description: Qt4 bindings for poppler -Version: @VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-qt4 -Cflags: -I${includedir}/poppler/qt4 diff --git a/source/libs/poppler/poppler-src/poppler-qt5-uninstalled.pc.in b/source/libs/poppler/poppler-src/poppler-qt5-uninstalled.pc.in deleted file mode 100644 index a91e1d5a3bdeb79aa0e382a9879bcc1744bc899b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-qt5-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-qt5 -Description: Qt5 bindings for poppler - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/qt5/src/libpoppler-qt5.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/qt5/src diff --git a/source/libs/poppler/poppler-src/poppler-qt5.pc.cmake b/source/libs/poppler/poppler-src/poppler-qt5.pc.cmake deleted file mode 100644 index b4d87b76675db1ee7ff4502ff1c14e5bf37d7200..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-qt5.pc.cmake +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler-qt5 -Description: Qt5 bindings for poppler -Version: @POPPLER_VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-qt5 -Cflags: -I${includedir}/poppler/qt5 diff --git a/source/libs/poppler/poppler-src/poppler-qt5.pc.in b/source/libs/poppler/poppler-src/poppler-qt5.pc.in deleted file mode 100644 index cda4c6f80fe93aa9f5e3db61b72aa4636dd79cba..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-qt5.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-qt5 -Description: Qt5 bindings for poppler -Version: @VERSION@ -Requires: @PC_REQUIRES@ -@PC_REQUIRES_PRIVATE@ - -Libs: -L${libdir} -lpoppler-qt5 -Cflags: -I${includedir}/poppler/qt5 diff --git a/source/libs/poppler/poppler-src/poppler-splash-uninstalled.pc.in b/source/libs/poppler/poppler-src/poppler-splash-uninstalled.pc.in deleted file mode 100644 index 436ecdb8f1bf4abb77dbb8051f9365316b2f5fa4..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-splash-uninstalled.pc.in +++ /dev/null @@ -1,7 +0,0 @@ -Name: poppler-splash -Description: Splash backend for Poppler PDF rendering library - uninstalled -Version: @VERSION@ -Requires: poppler = @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/splash/libsplash.la - diff --git a/source/libs/poppler/poppler-src/poppler-splash.pc.cmake b/source/libs/poppler/poppler-src/poppler-splash.pc.cmake deleted file mode 100644 index cb95b3d2d27da4bfb4449b6c4c1a6def21f0dfe2..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-splash.pc.cmake +++ /dev/null @@ -1,9 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler-splash -Description: Splash backend for Poppler PDF rendering library -Version: @POPPLER_VERSION@ -Requires: poppler = @POPPLER_VERSION@ diff --git a/source/libs/poppler/poppler-src/poppler-splash.pc.in b/source/libs/poppler/poppler-src/poppler-splash.pc.in deleted file mode 100644 index cf3491fc7cf492536e1d28636fdb24359fac1ff2..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-splash.pc.in +++ /dev/null @@ -1,9 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler-splash -Description: Splash backend for Poppler PDF rendering library -Version: @VERSION@ -Requires: poppler = @VERSION@ diff --git a/source/libs/poppler/poppler-src/poppler-uninstalled.pc.in b/source/libs/poppler/poppler-src/poppler-uninstalled.pc.in deleted file mode 100644 index 6076e80c5b351b4ccfe3e3f9c5d17fabaf4aee0c..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler-uninstalled.pc.in +++ /dev/null @@ -1,6 +0,0 @@ -Name: poppler -Description: PDF rendering library - uninstalled -Version: @VERSION@ - -Libs: ${pc_top_builddir}/${pcfiledir}/poppler/libpoppler.la -Cflags: -I${pc_top_builddir}/${pcfiledir}/poppler diff --git a/source/libs/poppler/poppler-src/poppler.pc.cmake b/source/libs/poppler/poppler-src/poppler.pc.cmake deleted file mode 100644 index f1aebedbefdeaeb9627f5751680f31a04d6a86ed..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler.pc.cmake +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=${prefix} -libdir=${exec_prefix}/lib@LIB_SUFFIX@ -includedir=${prefix}/include - -Name: poppler -Description: PDF rendering library -Version: @POPPLER_VERSION@ - -Libs: -L${libdir} -lpoppler -Cflags: -I${includedir}/poppler diff --git a/source/libs/poppler/poppler-src/poppler.pc.in b/source/libs/poppler/poppler-src/poppler.pc.in deleted file mode 100644 index 8605b28673b2c8bad1387b129054f552083e8612..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: poppler -Description: PDF rendering library -Version: @VERSION@ - -Libs: -L${libdir} -lpoppler -Cflags: -I${includedir}/poppler diff --git a/source/libs/poppler/poppler-src/poppler/Annot.cc b/source/libs/poppler/poppler-src/poppler/Annot.cc index bda5a9059ef5a362dec778ad49127b639fd3769c..1474c2cfe992fc71f743449fff9553375cd0f12f 100644 --- a/source/libs/poppler/poppler-src/poppler/Annot.cc +++ b/source/libs/poppler/poppler-src/poppler/Annot.cc @@ -35,6 +35,7 @@ // Copyright (C) 2015 Petr Gajdos <pgajdos@suse.cz> // Copyright (C) 2015 Philipp Reinkemeier <philipp.reinkemeier@offis.de> // Copyright (C) 2015 Tamas Szekeres <szekerest@gmail.com> +// Copyright (C) 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> // // 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 @@ -112,7 +113,7 @@ // = (4 * (sqrt(2) - 1) / 3) * r #define bezierCircle 0.55228475 -AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { +static AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { if (string != NULL) { if (!string->cmp("Square")) { return annotLineEndingSquare; @@ -140,7 +141,7 @@ AnnotLineEndingStyle parseAnnotLineEndingStyle(GooString *string) { } } -const char* convertAnnotLineEndingStyle(AnnotLineEndingStyle style) { +static const char* convertAnnotLineEndingStyle(AnnotLineEndingStyle style) { switch (style) { case annotLineEndingSquare: return "Square"; @@ -184,7 +185,7 @@ static AnnotExternalDataType parseAnnotExternalData(Dict* dict) { return type; } -PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) { +static PDFRectangle *parseDiffRectangle(Array *array, PDFRectangle *rect) { PDFRectangle *newRect = NULL; if (array->getLength() == 4) { // deltas @@ -1397,8 +1398,7 @@ void Annot::setContents(GooString *new_content) { contents = new GooString(new_content); //append the unicode marker <FE FF> if needed if (!contents->hasUnicodeMarker()) { - contents->insert(0, 0xff); - contents->insert(0, 0xfe); + contents->prependUnicodeMarker(); } } else { contents = new GooString(); @@ -1986,8 +1986,7 @@ void AnnotMarkup::setLabel(GooString *new_label) { label = new GooString(new_label); //append the unicode marker <FE FF> if needed if (!label->hasUnicodeMarker()) { - label->insert(0, 0xff); - label->insert(0, 0xfe); + label->prependUnicodeMarker(); } } else { label = new GooString(); @@ -2763,8 +2762,7 @@ void AnnotFreeText::setStyleString(GooString *new_string) { styleString = new GooString(new_string); //append the unicode marker <FE FF> if needed if (!styleString->hasUnicodeMarker()) { - styleString->insert(0, 0xff); - styleString->insert(0, 0xfe); + styleString->prependUnicodeMarker(); } } else { styleString = new GooString(); @@ -2839,29 +2837,14 @@ void AnnotFreeText::parseAppearanceString(GooString *da, double &fontsize, Annot fontcolor = NULL; if (da) { GooList * daToks = new GooList(); - int j, i = 0; + int i = FormFieldText::tokenizeDA(da, daToks, "Tf"); - // Tokenize - while (i < da->getLength()) { - while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { - ++i; - } - if (i < da->getLength()) { - for (j = i + 1; j < da->getLength() && !Lexer::isSpace(da->getChar(j)); ++j) { - } - daToks->append(new GooString(da, i, j - i)); - i = j; - } + if (i >= 1) { + fontsize = gatof(( (GooString *)daToks->get(i-1) )->getCString()); + // TODO: Font name } - // Scan backwards: we are looking for the last set value for (i = daToks->getLength()-1; i >= 0; --i) { - if (fontsize == -1) { - if (!((GooString *)daToks->get(i))->cmp("Tf") && i >= 2) { - // TODO: Font name - fontsize = gatof(( (GooString *)daToks->get(i-1) )->getCString()); - } - } if (fontcolor == NULL) { if (!((GooString *)daToks->get(i))->cmp("g") && i >= 1) { fontcolor = new AnnotColor(gatof(( (GooString *)daToks->get(i-1) )->getCString())); @@ -4698,7 +4681,7 @@ void AnnotWidget::drawBorder() { appearBuf->appendf(" {0:.2f}", dash[i]); } appearBuf->append("] 0 d\n"); - // fall through to the solid case + // fallthrough case AnnotBorder::borderSolid: case AnnotBorder::borderUnderlined: appearBuf->appendf("{0:.2f} w\n", w); @@ -4730,7 +4713,7 @@ void AnnotWidget::drawBorder() { appearBuf->appendf(" {0:.2f}", dash[i]); } appearBuf->append("] 0 d\n"); - // fall through to the solid case + // fallthrough case AnnotBorder::borderSolid: appearBuf->appendf("{0:.2f} w\n", w); setColor(aColor, gFalse); @@ -6573,11 +6556,11 @@ AnnotRichMedia::Content::Content(Dict *dict) { assets = (Asset **)gmallocn(nAssets, sizeof(Asset *)); int counter = 0; - for (int i = 0; i < obj2.arrayGetLength(); i += 2) { + for (int i = 0; i < nAssets; ++i) { assets[counter] = new AnnotRichMedia::Asset; - Object objKey = obj2.arrayGet(i); - assets[counter]->fileSpec = obj2.arrayGet(i + 1); + Object objKey = obj2.arrayGet(i * 2); + assets[counter]->fileSpec = obj2.arrayGet(i * 2 + 1); assets[counter]->name = new GooString( objKey.getString() ); ++counter; @@ -6681,26 +6664,30 @@ AnnotRichMedia::Configuration::Configuration(Dict *dict) } else if (!strcmp(name, "Video")) { type = typeVideo; } else { - // determine from first instance + // determine from first non null instance + type = typeFlash; // default in case all instances are null if (instances && nInstances > 0) { - AnnotRichMedia::Instance *instance = instances[0]; - switch (instance->getType()) { - case AnnotRichMedia::Instance::type3D: - type = type3D; - break; - case AnnotRichMedia::Instance::typeFlash: - type = typeFlash; - break; - case AnnotRichMedia::Instance::typeSound: - type = typeSound; - break; - case AnnotRichMedia::Instance::typeVideo: - type = typeVideo; - break; - default: - type = typeFlash; - break; - } + for (int i = 0; i < nInstances; ++i) { + AnnotRichMedia::Instance *instance = instances[i]; + if (instance) { + switch (instance->getType()) { + case AnnotRichMedia::Instance::type3D: + type = type3D; + break; + case AnnotRichMedia::Instance::typeFlash: + type = typeFlash; + break; + case AnnotRichMedia::Instance::typeSound: + type = typeSound; + break; + case AnnotRichMedia::Instance::typeVideo: + type = typeVideo; + break; + } + // break the loop since we found the first non null instance + break; + } + } } } } diff --git a/source/libs/poppler/poppler-src/poppler/Array.cc b/source/libs/poppler/poppler-src/poppler/Array.cc index c2c4040d91b9c5aa27d1c2fff35809241dee3403..94b8d66affcdc9b583f1a716259f4f05b51c324e 100644 --- a/source/libs/poppler/poppler-src/poppler/Array.cc +++ b/source/libs/poppler/poppler-src/poppler/Array.cc @@ -65,7 +65,7 @@ Array::~Array() { #endif } -Object Array::copy(XRef *xrefA) { +Object Array::copy(XRef *xrefA) const { arrayLocker(); Array *a = new Array(xrefA); for (int i = 0; i < length; ++i) { @@ -114,7 +114,7 @@ void Array::remove(int i) { memmove( elems + i, elems + i + 1, sizeof(elems[0]) * (length - i) ); } -Object Array::get(int i, int recursion) { +Object Array::get(int i, int recursion) const { if (i < 0 || i >= length) { #ifdef DEBUG_MEM abort(); @@ -125,7 +125,7 @@ Object Array::get(int i, int recursion) { return elems[i].fetch(xref, recursion); } -Object Array::getNF(int i) { +Object Array::getNF(int i) const { if (i < 0 || i >= length) { #ifdef DEBUG_MEM abort(); @@ -136,7 +136,7 @@ Object Array::getNF(int i) { return elems[i].copy(); } -GBool Array::getString(int i, GooString *string) +GBool Array::getString(int i, GooString *string) const { Object obj = getNF(i); if (obj.isString()) { diff --git a/source/libs/poppler/poppler-src/poppler/Array.h b/source/libs/poppler/poppler-src/poppler/Array.h index 8043c830b1bedcba189d85c4d3f10bb533a7d6cb..d2cdf65ff52141ad8e4feda0bc6981589bc4ce54 100644 --- a/source/libs/poppler/poppler-src/poppler/Array.h +++ b/source/libs/poppler/poppler-src/poppler/Array.h @@ -50,10 +50,10 @@ public: ~Array(); // Get number of elements. - int getLength() { return length; } + int getLength() const { return length; } // Copy array with new xref - Object copy(XRef *xrefA); + Object copy(XRef *xrefA) const; // Add an element // elem becomes a dead object after this call @@ -63,9 +63,9 @@ public: void remove(int i); // Accessors. - Object get(int i, int resursion = 0); - Object getNF(int i); - GBool getString(int i, GooString *string); + Object get(int i, int resursion = 0) const; + Object getNF(int i) const; + GBool getString(int i, GooString *string) const; private: friend class Object; // for incRef/decRef @@ -80,7 +80,7 @@ private: int length; // number of elements in array int ref; // reference count #if MULTITHREADED - GooMutex mutex; + mutable GooMutex mutex; #endif }; diff --git a/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc b/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc index 24b9e65e6984c1b420ff824082648fe71e4efe25..ffd39ef772c2f6375b7d70dfa1d99dbe4cb95955 100644 --- a/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc +++ b/source/libs/poppler/poppler-src/poppler/CairoOutputDev.cc @@ -18,7 +18,7 @@ // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> // Copyright (C) 2005, 2009, 2012, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> -// Copyright (C) 2006-2011, 2013, 2014 Carlos Garcia Campos <carlosgc@gnome.org> +// Copyright (C) 2006-2011, 2013, 2014, 2017 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2008 Carl Worth <cworth@cworth.org> // Copyright (C) 2008-2017 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu> @@ -2178,9 +2178,6 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream * cairo_pattern_set_filter (pattern, filter); - if (!printing) - cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); - cairo_matrix_init_translate (&matrix, 0, height); cairo_matrix_scale (&matrix, width, -height); cairo_pattern_set_matrix (pattern, &matrix); @@ -2196,6 +2193,11 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream * cairo_save (cairo); cairo_rectangle (cairo, 0., 0., 1., 1.); cairo_clip (cairo); + if (strokePathClip) { + cairo_push_group (cairo); + fillToStrokePathClip (state); + cairo_pop_group_to_source (cairo); + } cairo_mask (cairo, pattern); cairo_restore (cairo); } else { @@ -3075,7 +3077,13 @@ public: } } - if (printing || scaledWidth >= width || scaledHeight >= height) { +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0) + bool needsCustomDownscaling = false; +#else + bool needsCustomDownscaling = true; +#endif + + if (!needsCustomDownscaling || printing || scaledWidth >= width || scaledHeight >= height) { // No downscaling. Create cairo image containing the source image data. unsigned char *buffer; int stride; @@ -3189,7 +3197,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, cairo_matrix_t matrix; int width, height; int scaledWidth, scaledHeight; - cairo_filter_t filter = CAIRO_FILTER_BILINEAR; + cairo_filter_t filter = CAIRO_FILTER_BEST; RescaleDrawImage rescale; LOG (printf ("drawImage %dx%d\n", widthA, heightA)); diff --git a/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc b/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc index 91d4c307045e0d6651253ee163feb9a2c95e7cb5..4dae58e7e3dc91c2121e55ed7d29e5de07cc94e7 100644 --- a/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc +++ b/source/libs/poppler/poppler-src/poppler/CurlPDFDocBuilder.cc @@ -5,7 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright 2010 Hib Eris <hib@hiberis.nl> -// Copyright 2010 Albert Astals Cid <aacid@kde.org> +// Copyright 2010, 2017 Albert Astals Cid <aacid@kde.org> // //======================================================================== @@ -15,6 +15,7 @@ #include "CachedFile.h" #include "CurlCachedFile.h" +#include "ErrorCodes.h" //------------------------------------------------------------------------ // CurlPDFDocBuilder @@ -27,6 +28,11 @@ CurlPDFDocBuilder::buildPDFDoc(const GooString &uri, CachedFile *cachedFile = new CachedFile( new CurlCachedFileLoader(), uri.copy()); + if (cachedFile->getLength() == ((Guint) -1)) { + cachedFile->decRefCnt(); + return PDFDoc::ErrorPDFDoc(errOpenFile, uri.copy()); + } + BaseStream *str = new CachedFileStream( cachedFile, 0, gFalse, cachedFile->getLength(), Object(objNull)); diff --git a/source/libs/poppler/poppler-src/poppler/Decrypt.cc b/source/libs/poppler/poppler-src/poppler/Decrypt.cc index c8246fab76d5872ac7b3be0be2fcf4403e0ff29b..5d24d0a90e57cb8b08bd3157ce36c6fe25d032fc 100644 --- a/source/libs/poppler/poppler-src/poppler/Decrypt.cc +++ b/source/libs/poppler/poppler-src/poppler/Decrypt.cc @@ -14,7 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net> -// Copyright (C) 2008, 2010, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008, 2010, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2009 Matthias Franz <matthias@ktug.or.kr> // Copyright (C) 2009 David Benjamin <davidben@mit.edu> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> @@ -1345,7 +1345,7 @@ static inline Guint sha256sigma1(Guint x) { return rotr(x, 17) ^ rotr(x, 19) ^ (x >> 10); } -void sha256HashBlock(Guchar *blk, Guint *H) { +static void sha256HashBlock(Guchar *blk, Guint *H) { Guint W[64]; Guint a, b, c, d, e, f, g, h; Guint T1, T2; diff --git a/source/libs/poppler/poppler-src/poppler/Dict.cc b/source/libs/poppler/poppler-src/poppler/Dict.cc index 5c231d14fe6ea8b280528c85618f1dc3b48f3c30..2bd86abf45f86ebd9a712dbd490c21742ab4bd63 100644 --- a/source/libs/poppler/poppler-src/poppler/Dict.cc +++ b/source/libs/poppler/poppler-src/poppler/Dict.cc @@ -163,7 +163,7 @@ void Dict::add(char *key, Object &&val) { ++length; } -inline DictEntry *Dict::find(const char *key) { +inline DictEntry *Dict::find(const char *key) const { if (!sorted && length >= SORT_LENGTH_LOWER_LIMIT) { dictLocker(); @@ -187,7 +187,7 @@ inline DictEntry *Dict::find(const char *key) { return NULL; } -GBool Dict::hasKey(const char *key) { +GBool Dict::hasKey(const char *key) const { return find(key) != NULL; } @@ -247,25 +247,25 @@ void Dict::set(const char *key, Object &&val) { } -GBool Dict::is(const char *type) { +GBool Dict::is(const char *type) const { DictEntry *e; return (e = find("Type")) && e->val.isName(type); } -Object Dict::lookup(const char *key, int recursion) { +Object Dict::lookup(const char *key, int recursion) const { DictEntry *e; return (e = find(key)) ? e->val.fetch(xref, recursion) : Object(objNull); } -Object Dict::lookupNF(const char *key) { +Object Dict::lookupNF(const char *key) const { DictEntry *e; return (e = find(key)) ? e->val.copy() : Object(objNull); } -GBool Dict::lookupInt(const char *key, const char *alt_key, int *value) +GBool Dict::lookupInt(const char *key, const char *alt_key, int *value) const { GBool success = gFalse; Object obj1 = lookup ((char *) key); @@ -283,14 +283,14 @@ GBool Dict::lookupInt(const char *key, const char *alt_key, int *value) return success; } -char *Dict::getKey(int i) { +char *Dict::getKey(int i) const { return entries[i].key; } -Object Dict::getVal(int i) { +Object Dict::getVal(int i) const { return entries[i].val.fetch(xref); } -Object Dict::getValNF(int i) { +Object Dict::getValNF(int i) const { return entries[i].val.copy(); } diff --git a/source/libs/poppler/poppler-src/poppler/Dict.h b/source/libs/poppler/poppler-src/poppler/Dict.h index b775a574d9909d9dac6d007acc2535defb7cf779..1b922b0e84ba07f112edf35d39e1fecffc6154e6 100644 --- a/source/libs/poppler/poppler-src/poppler/Dict.h +++ b/source/libs/poppler/poppler-src/poppler/Dict.h @@ -57,7 +57,7 @@ public: ~Dict(); // Get number of entries. - int getLength() { return length; } + int getLength() const { return length; } // Add an entry. NB: does not copy key. // val becomes a dead object after the call @@ -70,27 +70,27 @@ public: void remove(const char *key); // Check if dictionary is of specified type. - GBool is(const char *type); + GBool is(const char *type) const; // Look up an entry and return the value. Returns a null object // if <key> is not in the dictionary. - Object lookup(const char *key, int recursion = 0); - Object lookupNF(const char *key); - GBool lookupInt(const char *key, const char *alt_key, int *value); + Object lookup(const char *key, int recursion = 0) const; + Object lookupNF(const char *key) const; + GBool lookupInt(const char *key, const char *alt_key, int *value) const; // Iterative accessors. - char *getKey(int i); - Object getVal(int i); - Object getValNF(int i); + char *getKey(int i) const; + Object getVal(int i) const; + Object getValNF(int i) const; // Set the xref pointer. This is only used in one special case: the // trailer dictionary, which is read before the xref table is // parsed. void setXRef(XRef *xrefA) { xref = xrefA; } - XRef *getXRef() { return xref; } + XRef *getXRef() const { return xref; } - GBool hasKey(const char *key); + GBool hasKey(const char *key) const; private: friend class Object; // for incRef/decRef @@ -99,17 +99,17 @@ private: int incRef(); int decRef(); - GBool sorted; + mutable GBool sorted; XRef *xref; // the xref table for this PDF file DictEntry *entries; // array of entries int size; // size of <entries> array int length; // number of entries in dictionary int ref; // reference count #if MULTITHREADED - GooMutex mutex; + mutable GooMutex mutex; #endif - DictEntry *find(const char *key); + DictEntry *find(const char *key) const; }; #endif diff --git a/source/libs/poppler/poppler-src/poppler/Form.cc b/source/libs/poppler/poppler-src/poppler/Form.cc index 0f4718ed0da5be44e144db6bf105ea8a48fe4659..62bba1032ddf15a5e2a79f3b9ebd8be2448e6d13 100644 --- a/source/libs/poppler/poppler-src/poppler/Form.cc +++ b/source/libs/poppler/poppler-src/poppler/Form.cc @@ -18,6 +18,7 @@ // Copyright 2015 André Guerreiro <aguerreiro1985@gmail.com> // Copyright 2015 André Esser <bepandre@hotmail.com> // Copyright 2017 Hans-Ulrich Jüttner <huj@froreich-bioscientia.de> +// Copyright 2017 Bernd Kuhls <berndkuhls@hotmail.com> // //======================================================================== @@ -30,7 +31,9 @@ #include <set> #include <limits> #include <stddef.h> +#include <stdlib.h> #include <string.h> +#include <ctype.h> #include "goo/gmem.h" #include "goo/GooString.h" #include "Error.h" @@ -49,6 +52,7 @@ #include "PDFDocEncoding.h" #include "Annot.h" #include "Link.h" +#include "Lexer.h" //return a newly allocated char* containing an UTF16BE string of size length char* pdfDocEncodingToUTF16 (GooString* orig, int* length) @@ -58,8 +62,8 @@ char* pdfDocEncodingToUTF16 (GooString* orig, int* length) char *result = new char[(*length)]; char *cstring = orig->getCString(); //unicode marker - result[0] = 0xfe; - result[1] = 0xff; + result[0] = (char)0xfe; + result[1] = (char)0xff; //convert to utf16 for(int i=2,j=0; i<(*length); i+=2,j++) { Unicode u = pdfDocEncoding[(unsigned int)((unsigned char)cstring[j])]&0xffff; @@ -312,6 +316,16 @@ int FormWidgetText::getMaxLen () const return parent()->getMaxLen (); } +double FormWidgetText::getTextFontSize() +{ + return parent()->getTextFontSize(); +} + +void FormWidgetText::setTextFontSize(int fontSize) +{ + parent()->setTextFontSize(fontSize); +} + void FormWidgetText::setContent(GooString* new_content) { parent()->setContentCopy(new_content); @@ -906,8 +920,7 @@ GooString* FormField::getFullyQualifiedName() { } if (unicode_encoded) { - full_name->insert(0, 0xff); - full_name->insert(0, 0xfe); + full_name->prependUnicodeMarker(); } fullyQualifiedName = full_name; @@ -1170,8 +1183,7 @@ void FormFieldText::setContentCopy (GooString* new_content) //append the unicode marker <FE FF> if needed if (!content->hasUnicodeMarker()) { - content->insert(0, 0xff); - content->insert(0, 0xfe); + content->prependUnicodeMarker(); } } @@ -1185,6 +1197,86 @@ FormFieldText::~FormFieldText() delete content; } +double FormFieldText::getTextFontSize() +{ + GooList* daToks = new GooList(); + int idx = parseDA(daToks); + double fontSize = -1; + if (idx >= 0) { + char* p = nullptr; + fontSize = strtod(static_cast<GooString*>(daToks->get(idx))->getCString(), &p); + if (!p || *p) + fontSize = -1; + } + deleteGooList(daToks, GooString); + return fontSize; +} + +void FormFieldText::setTextFontSize(int fontSize) +{ + if (fontSize > 0 && obj.isDict()) { + GooList* daToks = new GooList(); + int idx = parseDA(daToks); + if (idx == -1) { + error(errSyntaxError, -1, "FormFieldText:: invalid DA object\n"); + return; + } + if (defaultAppearance) + delete defaultAppearance; + defaultAppearance = new GooString; + for (int i = 0; i < daToks->getLength(); ++i) { + if (i > 0) + defaultAppearance->append(' '); + if (i == idx) { + defaultAppearance->appendf("{0:d}", fontSize); + } else { + defaultAppearance->append(static_cast<GooString*>(daToks->get(i))); + } + } + deleteGooList(daToks, GooString); + obj.dictSet("DA", Object(defaultAppearance->copy())); + xref->setModifiedObject(&obj, ref); + updateChildrenAppearance(); + } +} + +int FormFieldText::tokenizeDA(GooString* da, GooList* daToks, const char* searchTok) +{ + int idx = -1; + if(da && daToks) { + int i = 0; + int j = 0; + while (i < da->getLength()) { + while (i < da->getLength() && Lexer::isSpace(da->getChar(i))) { + ++i; + } + if (i < da->getLength()) { + for (j = i + 1; j < da->getLength() && !Lexer::isSpace(da->getChar(j)); ++j) { + } + GooString* tok = new GooString(da, i, j - i); + if (searchTok && !tok->cmp(searchTok)) + idx = daToks->getLength(); + daToks->append(tok); + i = j; + } + } + } + return idx; +} + +int FormFieldText::parseDA(GooList* daToks) +{ + int idx = -1; + if (obj.isDict()) { + Object objDA(obj.dictLookup("DA")); + if (objDA.isString()) { + GooString* da = objDA.getString(); + idx = tokenizeDA(da, daToks, "Tf") - 1; + } + } + return idx; +} + //------------------------------------------------------------------------ // FormFieldChoice @@ -1447,8 +1539,7 @@ void FormFieldChoice::setEditChoice (GooString* new_content) //append the unicode marker <FE FF> if needed if (!editedChoice->hasUnicodeMarker()) { - editedChoice->insert(0, 0xff); - editedChoice->insert(0, 0xfe); + editedChoice->prependUnicodeMarker(); } } updateSelection(); diff --git a/source/libs/poppler/poppler-src/poppler/Form.h b/source/libs/poppler/poppler-src/poppler/Form.h index 8498752e6d9eba4dba896f11c682ba8dde7c9f29..8e72334d0589d783330ac64c69f5f342bae96c5e 100644 --- a/source/libs/poppler/poppler-src/poppler/Form.h +++ b/source/libs/poppler/poppler-src/poppler/Form.h @@ -25,6 +25,7 @@ #pragma interface #endif +#include "goo/GooList.h" #include "Object.h" #include "Annot.h" @@ -206,6 +207,11 @@ public: bool isComb () const; bool isRichText () const; int getMaxLen () const; + //return the font size of the field's text + double getTextFontSize(); + //set the font size of the field's text (currently only integer values) + void setTextFontSize(int fontSize); + protected: FormFieldText *parent() const; }; @@ -421,10 +427,20 @@ public: int getMaxLen () const { return maxLen; } + //return the font size of the field's text + double getTextFontSize(); + //set the font size of the field's text (currently only integer values) + void setTextFontSize(int fontSize); + #ifdef DEBUG_FORMS void print(int indent = 0); #endif + + static int tokenizeDA(GooString* daString, GooList* daToks, const char* searchTok); + protected: + int parseDA(GooList* daToks); + GooString* content; bool multiline; bool password; diff --git a/source/libs/poppler/poppler-src/poppler/Gfx.cc b/source/libs/poppler/poppler-src/poppler/Gfx.cc index 6ffb7bcf2ca3fa6b051a768721644cc4ad4c7f2e..eaef798f3ef9f321ac2edd99254d4cab6d142c81 100644 --- a/source/libs/poppler/poppler-src/poppler/Gfx.cc +++ b/source/libs/poppler/poppler-src/poppler/Gfx.cc @@ -458,9 +458,15 @@ GfxPattern *GfxResources::lookupPattern(char *name, OutputDev *out, GfxState *st for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->patternDict.isDict()) { - Object obj = resPtr->patternDict.dictLookup(name); + Object obj = resPtr->patternDict.dictLookupNF(name); if (!obj.isNull()) { - pattern = GfxPattern::parse(resPtr, &obj, out, state); + Ref patternRef = { -1, -1 }; + if (obj.isRef()) { + patternRef = obj.getRef(); + obj = obj.fetch(resPtr->patternDict.getDict()->getXRef()); + } + + pattern = GfxPattern::parse(resPtr, &obj, out, state, patternRef.num); return pattern; } } @@ -2224,18 +2230,34 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat, xi0, yi0, xi1, yi1, xstep, ystep)) { goto restore; } else { - out->updatePatternOpacity(state); - for (yi = yi0; yi < yi1; ++yi) { - for (xi = xi0; xi < xi1; ++xi) { - x = xi * xstep; - y = yi * ystep; - m1[4] = x * m[0] + y * m[2] + m[4]; - m1[5] = x * m[1] + y * m[3] + m[5]; - drawForm(tPat->getContentStream(), tPat->getResDict(), - m1, tPat->getBBox()); + bool shouldDrawForm = gTrue; + std::set<int>::iterator patternRefIt; + const int patternRefNum = tPat->getPatternRefNum(); + if (patternRefNum != -1) { + if (formsDrawing.find(patternRefNum) == formsDrawing.end()) { + patternRefIt = formsDrawing.insert(patternRefNum).first; + } else { + shouldDrawForm = gFalse; + } + } + + if (shouldDrawForm) { + out->updatePatternOpacity(state); + for (yi = yi0; yi < yi1; ++yi) { + for (xi = xi0; xi < xi1; ++xi) { + x = xi * xstep; + y = yi * ystep; + m1[4] = x * m[0] + y * m[2] + m[4]; + m1[5] = x * m[1] + y * m[3] + m[5]; + drawForm(tPat->getContentStream(), tPat->getResDict(), + m1, tPat->getBBox()); + } + } + out->clearPatternOpacity(state); + if (patternRefNum != -1) { + formsDrawing.erase(patternRefIt); } } - out->clearPatternOpacity(state); } // restore graphics state @@ -3953,12 +3975,33 @@ void Gfx::doShowText(GooString *s) { state->transformDelta(dx, dy, &ddx, &ddy); if (!out->beginType3Char(state, curX + riseX, curY + riseY, ddx, ddy, code, u, uLen)) { - Object charProc = ((Gfx8BitFont *)font)->getCharProc(code); + Object charProc = ((Gfx8BitFont *)font)->getCharProcNF(code); + int refNum = -1; + if (charProc.isRef()) { + refNum = charProc.getRef().num; + charProc = charProc.fetch(((Gfx8BitFont *)font)->getCharProcs()->getXRef()); + } if ((resDict = ((Gfx8BitFont *)font)->getResources())) { pushResources(resDict); } if (charProc.isStream()) { - display(&charProc, gFalse); + std::set<int>::iterator charProcDrawingIt; + bool displayCharProc = true; + if (refNum != -1) { + if (charProcDrawing.find(refNum) == charProcDrawing.end()) { + charProcDrawingIt = charProcDrawing.insert(refNum).first; + } else { + displayCharProc = false; + error(errSyntaxError, -1, "CharProc wants to draw a CharProc that is already beign drawn"); + } + } + if (displayCharProc) { + display(&charProc, gFalse); + + if (refNum != -1) { + charProcDrawing.erase(charProcDrawingIt); + } + } } else { error(errSyntaxError, getPos(), "Missing or bad Type3 CharProc entry"); } diff --git a/source/libs/poppler/poppler-src/poppler/Gfx.h b/source/libs/poppler/poppler-src/poppler/Gfx.h index 00eaec4946346805c2eb8e8540e053bb52d1ab19..293f4551eaa252db5bb9f72c7b608fa8b072fccb 100644 --- a/source/libs/poppler/poppler-src/poppler/Gfx.h +++ b/source/libs/poppler/poppler-src/poppler/Gfx.h @@ -228,6 +228,7 @@ private: Parser *parser; // parser for page content stream(s) std::set<int> formsDrawing; // the forms that are being drawn + std::set<int> charProcDrawing; // the charProc that are being drawn GBool // callback to check for an abort (*abortCheckCbk)(void *data); diff --git a/source/libs/poppler/poppler-src/poppler/GfxFont.cc b/source/libs/poppler/poppler-src/poppler/GfxFont.cc index d95f8f7c1a9f3c573a70163d50e84e47266af308..04431b3c4096c6de1e8958fea4c5d9f59cc30b12 100644 --- a/source/libs/poppler/poppler-src/poppler/GfxFont.cc +++ b/source/libs/poppler/poppler-src/poppler/GfxFont.cc @@ -594,7 +594,6 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { GfxFontLoc *fontLoc; SysFontType sysFontType; GooString *path, *base14Name, *substName; - PSFontParam16 *psFont16; int substIdx, fontNum; GBool embed; @@ -715,17 +714,6 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { if (!isCIDFont()) { - //----- 8-bit PS resident font - if (name && ps) { - if ((path = globalParams->getPSResidentFont(name))) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontType1; - fontLoc->path = path; - return fontLoc; - } - } - //----- 8-bit font substitution if (flags & fontFixedWidth) { substIdx = 0; @@ -768,42 +756,6 @@ GfxFontLoc *GfxFont::locateFont(XRef *xref, PSOutputDev *ps) { return NULL; } - //----- 16-bit PS resident font - if (ps && ((psFont16 = globalParams->getPSResidentFont16( - name, - ((GfxCIDFont *)this)->getWMode())))) { - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontCIDType0; // this is not used - fontLoc->path = psFont16->psFontName->copy(); - fontLoc->encoding = psFont16->encoding->copy(); - fontLoc->wMode = psFont16->wMode; - return fontLoc; - } - if (ps && ((psFont16 = globalParams->getPSResidentFontCC( - ((GfxCIDFont *)this)->getCollection(), - ((GfxCIDFont *)this)->getWMode())))) { - error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", - psFont16->psFontName, name); - fontLoc = new GfxFontLoc(); - fontLoc->locType = gfxFontLocResident; - fontLoc->fontType = fontCIDType0; // this is not used - fontLoc->path = psFont16->psFontName->copy(); - fontLoc->encoding = psFont16->encoding->copy(); - fontLoc->wMode = psFont16->wMode; - return fontLoc; - } - - //----- CID font substitution - if ((path = globalParams->findCCFontFile( - ((GfxCIDFont *)this)->getCollection()))) { - if ((fontLoc = getExternalFont(path, gTrue))) { - error(errSyntaxWarning, -1, "Substituting font '{0:t}' for '{1:t}'", - fontLoc->path, name); - return fontLoc; - } - } - // failed to find a substitute font return NULL; } @@ -1759,6 +1711,14 @@ Object Gfx8BitFont::getCharProc(int code) { } } +Object Gfx8BitFont::getCharProcNF(int code) { + if (enc[code] && charProcs.isDict()) { + return charProcs.dictLookupNF(enc[code]); + } else { + return Object(objNull); + } +} + Dict *Gfx8BitFont::getResources() { return resources.isDict() ? resources.getDict() : (Dict *)NULL; } diff --git a/source/libs/poppler/poppler-src/poppler/GfxFont.h b/source/libs/poppler/poppler-src/poppler/GfxFont.h index 06c1df6d6ffc2a08d74259b1cc4a3dc0020fbf26..5985912a8c2a5dafb53af3799b12f0261acb4a90 100644 --- a/source/libs/poppler/poppler-src/poppler/GfxFont.h +++ b/source/libs/poppler/poppler-src/poppler/GfxFont.h @@ -353,6 +353,7 @@ public: // Return the Type 3 CharProc for the character associated with <code>. Object getCharProc(int code); + Object getCharProcNF(int code); // Return the Type 3 Resources dictionary, or NULL if none. Dict *getResources(); diff --git a/source/libs/poppler/poppler-src/poppler/GfxState.cc b/source/libs/poppler/poppler-src/poppler/GfxState.cc index b2971ec056ca6cbadf4e683b884468eb0cbb0a41..3e30edf0213a60eaf9e679eeae9c619d551c50e3 100644 --- a/source/libs/poppler/poppler-src/poppler/GfxState.cc +++ b/source/libs/poppler/poppler-src/poppler/GfxState.cc @@ -3351,14 +3351,17 @@ void GfxPatternColorSpace::getDefaultColor(GfxColor *color) { // Pattern //------------------------------------------------------------------------ -GfxPattern::GfxPattern(int typeA) { - type = typeA; +GfxPattern::GfxPattern(int typeA, int patternRefNumA) + : type(typeA) + , patternRefNum(patternRefNumA) +{ + } GfxPattern::~GfxPattern() { } -GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state) { +GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum) { GfxPattern *pattern; Object obj1; @@ -3371,9 +3374,9 @@ GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, Gf } pattern = NULL; if (obj1.isInt() && obj1.getInt() == 1) { - pattern = GfxTilingPattern::parse(obj); + pattern = GfxTilingPattern::parse(obj, patternRefNum); } else if (obj1.isInt() && obj1.getInt() == 2) { - pattern = GfxShadingPattern::parse(res, obj, out, state); + pattern = GfxShadingPattern::parse(res, obj, out, state, patternRefNum); } return pattern; } @@ -3382,7 +3385,7 @@ GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, Gf // GfxTilingPattern //------------------------------------------------------------------------ -GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) { +GfxTilingPattern *GfxTilingPattern::parse(Object *patObj, int patternRefNum) { Dict *dict; int paintTypeA, tilingTypeA; double bboxA[4], matrixA[6]; @@ -3455,14 +3458,14 @@ GfxTilingPattern *GfxTilingPattern::parse(Object *patObj) { } return new GfxTilingPattern(paintTypeA, tilingTypeA, bboxA, xStepA, yStepA, - &resDictA, matrixA, patObj); + &resDictA, matrixA, patObj, patternRefNum); } GfxTilingPattern::GfxTilingPattern(int paintTypeA, int tilingTypeA, double *bboxA, double xStepA, double yStepA, Object *resDictA, double *matrixA, - Object *contentStreamA): - GfxPattern(1) + Object *contentStreamA, int patternRefNumA) : + GfxPattern(1, patternRefNumA) { int i; @@ -3485,14 +3488,14 @@ GfxTilingPattern::~GfxTilingPattern() { GfxPattern *GfxTilingPattern::copy() { return new GfxTilingPattern(paintType, tilingType, bbox, xStep, yStep, - &resDict, matrix, &contentStream); + &resDict, matrix, &contentStream, getPatternRefNum()); } //------------------------------------------------------------------------ // GfxShadingPattern //------------------------------------------------------------------------ -GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state) { +GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum) { Dict *dict; GfxShading *shadingA; double matrixA[6]; @@ -3523,11 +3526,11 @@ GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, O } } - return new GfxShadingPattern(shadingA, matrixA); + return new GfxShadingPattern(shadingA, matrixA, patternRefNum); } -GfxShadingPattern::GfxShadingPattern(GfxShading *shadingA, double *matrixA): - GfxPattern(2) +GfxShadingPattern::GfxShadingPattern(GfxShading *shadingA, double *matrixA, int patternRefNumA): + GfxPattern(2, patternRefNumA) { int i; @@ -3542,7 +3545,7 @@ GfxShadingPattern::~GfxShadingPattern() { } GfxPattern *GfxShadingPattern::copy() { - return new GfxShadingPattern(shading->copy(), matrix); + return new GfxShadingPattern(shading->copy(), matrix, getPatternRefNum()); } //------------------------------------------------------------------------ diff --git a/source/libs/poppler/poppler-src/poppler/GfxState.h b/source/libs/poppler/poppler-src/poppler/GfxState.h index 7bcedf2a84009ab1995baba37d52f241acfb12a8..57f3725274ee3ccff85a29e05074848e6e66d90c 100644 --- a/source/libs/poppler/poppler-src/poppler/GfxState.h +++ b/source/libs/poppler/poppler-src/poppler/GfxState.h @@ -17,7 +17,7 @@ // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2006 Carlos Garcia Campos <carlosgc@gnome.org> // Copyright (C) 2009 Koji Otani <sho@bbr.jp> -// Copyright (C) 2009-2011, 2013, 2016 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009-2011, 2013, 2016, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com> // Copyright (C) 2011-2014, 2016 Thomas Freitag <Thomas.Freitag@alfa.de> @@ -762,18 +762,21 @@ private: class GfxPattern { public: - GfxPattern(int typeA); + GfxPattern(int typeA, int patternRefNumA); virtual ~GfxPattern(); - static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state); + static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state, int patternRefNum); virtual GfxPattern *copy() = 0; int getType() { return type; } + int getPatternRefNum() const { return patternRefNum; } + private: int type; + int patternRefNum; }; //------------------------------------------------------------------------ @@ -783,7 +786,7 @@ private: class GfxTilingPattern: public GfxPattern { public: - static GfxTilingPattern *parse(Object *patObj); + static GfxTilingPattern *parse(Object *patObj, int patternRefNum); ~GfxTilingPattern(); GfxPattern *copy() override; @@ -803,7 +806,7 @@ private: GfxTilingPattern(int paintTypeA, int tilingTypeA, double *bboxA, double xStepA, double yStepA, Object *resDictA, double *matrixA, - Object *contentStreamA); + Object *contentStreamA, int patternRefNumA); int paintType; int tilingType; @@ -821,7 +824,7 @@ private: class GfxShadingPattern: public GfxPattern { public: - static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state); + static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state, int patternRefNum); ~GfxShadingPattern(); GfxPattern *copy() override; @@ -831,7 +834,7 @@ public: private: - GfxShadingPattern(GfxShading *shadingA, double *matrixA); + GfxShadingPattern(GfxShading *shadingA, double *matrixA, int patternRefNumA); GfxShading *shading; double matrix[6]; diff --git a/source/libs/poppler/poppler-src/poppler/GlobalParams.cc b/source/libs/poppler/poppler-src/poppler/GlobalParams.cc index 10830944bf0276e0ae8857a5b2087f75566f6cbe..93c42d2a711f8ff55207736a9dab25bb6736e7cf 100644 --- a/source/libs/poppler/poppler-src/poppler/GlobalParams.cc +++ b/source/libs/poppler/poppler-src/poppler/GlobalParams.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> -// Copyright (C) 2005, 2007-2010, 2012, 2015 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005, 2007-2010, 2012, 2015, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Jonathan Blandford <jrb@redhat.com> // Copyright (C) 2006, 2007 Jeff Muizelaar <jeff@infidigm.net> // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> @@ -127,24 +127,6 @@ extern XpdfPluginVecTable xpdfPluginVecTable; GlobalParams *globalParams = NULL; -//------------------------------------------------------------------------ -// PSFontParam16 -//------------------------------------------------------------------------ - -PSFontParam16::PSFontParam16(GooString *nameA, int wModeA, - GooString *psFontNameA, GooString *encodingA) { - name = nameA; - wMode = wModeA; - psFontName = psFontNameA; - encoding = encodingA; -} - -PSFontParam16::~PSFontParam16() { - delete name; - delete psFontName; - delete encoding; -} - #if ENABLE_RELOCATABLE && defined(_WIN32) /* search for data relative to where we are installed */ @@ -587,17 +569,11 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir) cMapDirs = new GooHash(gTrue); toUnicodeDirs = new GooList(); fontFiles = new GooHash(gTrue); - fontDirs = new GooList(); - ccFontFiles = new GooHash(gTrue); sysFonts = new SysFontList(); psExpandSmaller = gFalse; psShrinkLarger = gTrue; psCenter = gTrue; psLevel = psLevel2; - psFile = NULL; - psResidentFonts = new GooHash(gTrue); - psResidentFonts16 = new GooList(); - psResidentFontsCC = new GooList(); textEncoding = new GooString("UTF-8"); #if defined(_WIN32) textEOL = eolDOS; @@ -796,18 +772,10 @@ GlobalParams::~GlobalParams() { deleteGooHash(unicodeMaps, GooString); deleteGooList(toUnicodeDirs, GooString); deleteGooHash(fontFiles, GooString); - deleteGooList(fontDirs, GooString); - deleteGooHash(ccFontFiles, GooString); #ifdef _WIN32 deleteGooHash(substFiles, GooString); #endif delete sysFonts; - if (psFile) { - delete psFile; - } - deleteGooHash(psResidentFonts, GooString); - deleteGooList(psResidentFonts16, PSFontParam16); - deleteGooList(psResidentFontsCC, PSFontParam16); delete textEncoding; GooHashIter *iter; @@ -1105,14 +1073,7 @@ static FcPattern *buildFcPattern(GfxFont *font, GooString *base14Name) #endif GooString *GlobalParams::findFontFile(GooString *fontName) { - static const char *exts[] = { ".pfa", ".pfb", ".ttf", ".ttc", ".otf" }; - GooString *path, *dir; -#ifdef WIN32 - GooString *fontNameU; -#endif - const char *ext; - FILE *f; - int i, j; + GooString *path; setupBaseFonts(NULL); lockGlobalParams; @@ -1121,26 +1082,6 @@ GooString *GlobalParams::findFontFile(GooString *fontName) { unlockGlobalParams; return path; } - for (i = 0; i < fontDirs->getLength(); ++i) { - dir = (GooString *)fontDirs->get(i); - for (j = 0; j < (int)(sizeof(exts) / sizeof(exts[0])); ++j) { - ext = exts[j]; -#ifdef WIN32 - fontNameU = fileNameToUTF8(fontName->getCString()); - path = appendToPath(dir->copy(), fontNameU->getCString()); - delete fontNameU; -#else - path = appendToPath(dir->copy(), fontName->getCString()); -#endif - path->append(ext); - if ((f = openFile(path->getCString(), "rb"))) { - fclose(f); - unlockGlobalParams; - return path; - } - delete path; - } - } unlockGlobalParams; return NULL; } @@ -1425,18 +1366,6 @@ GooString *GlobalParams::findSystemFontFile(GfxFont *font, } #endif -GooString *GlobalParams::findCCFontFile(GooString *collection) { - GooString *path; - - lockGlobalParams; - if ((path = (GooString *)ccFontFiles->lookup(collection))) { - path = path->copy(); - } - unlockGlobalParams; - return path; -} - - GBool GlobalParams::getPSExpandSmaller() { GBool f; @@ -1473,67 +1402,6 @@ PSLevel GlobalParams::getPSLevel() { return level; } -GooString *GlobalParams::getPSResidentFont(GooString *fontName) { - GooString *psName; - - lockGlobalParams; - psName = (GooString *)psResidentFonts->lookup(fontName); - unlockGlobalParams; - return psName; -} - -GooList *GlobalParams::getPSResidentFonts() { - GooList *names; - GooHashIter *iter; - GooString *name; - GooString *psName; - - names = new GooList(); - lockGlobalParams; - psResidentFonts->startIter(&iter); - while (psResidentFonts->getNext(&iter, &name, (void **)&psName)) { - names->append(psName->copy()); - } - unlockGlobalParams; - return names; -} - -PSFontParam16 *GlobalParams::getPSResidentFont16(GooString *fontName, - int wMode) { - PSFontParam16 *p; - int i; - - lockGlobalParams; - p = NULL; - for (i = 0; i < psResidentFonts16->getLength(); ++i) { - p = (PSFontParam16 *)psResidentFonts16->get(i); - if (!(p->name->cmp(fontName)) && p->wMode == wMode) { - break; - } - p = NULL; - } - unlockGlobalParams; - return p; -} - -PSFontParam16 *GlobalParams::getPSResidentFontCC(GooString *collection, - int wMode) { - PSFontParam16 *p; - int i; - - lockGlobalParams; - p = NULL; - for (i = 0; i < psResidentFontsCC->getLength(); ++i) { - p = (PSFontParam16 *)psResidentFontsCC->get(i); - if (!(p->name->cmp(collection)) && p->wMode == wMode) { - break; - } - p = NULL; - } - unlockGlobalParams; - return p; -} - GooString *GlobalParams::getTextEncodingName() { GooString *s; @@ -1791,15 +1659,6 @@ void GlobalParams::addFontFile(GooString *fontName, GooString *path) { unlockGlobalParams; } -void GlobalParams::setPSFile(char *file) { - lockGlobalParams; - if (psFile) { - delete psFile; - } - psFile = new GooString(file); - unlockGlobalParams; -} - void GlobalParams::setPSExpandSmaller(GBool expand) { lockGlobalParams; psExpandSmaller = expand; diff --git a/source/libs/poppler/poppler-src/poppler/GlobalParams.h b/source/libs/poppler/poppler-src/poppler/GlobalParams.h index 1a65085f8116712a0c108161c8f4de8dacf46db9..16dc7a4a0575728bbcb74ba4534ad2145388d011 100644 --- a/source/libs/poppler/poppler-src/poppler/GlobalParams.h +++ b/source/libs/poppler/poppler-src/poppler/GlobalParams.h @@ -81,22 +81,6 @@ enum SysFontType { //------------------------------------------------------------------------ -class PSFontParam16 { -public: - - GooString *name; // PDF font name for psResidentFont16; - // char collection name for psResidentFontCC - int wMode; // writing mode (0=horiz, 1=vert) - GooString *psFontName; // PostScript font name - GooString *encoding; // encoding - - PSFontParam16(GooString *nameA, int wModeA, - GooString *psFontNameA, GooString *encodingA); - ~PSFontParam16(); -}; - -//------------------------------------------------------------------------ - enum PSLevel { psLevel1, psLevel1Sep, @@ -156,15 +140,10 @@ public: GooString *findSystemFontFile(GfxFont *font, SysFontType *type, int *fontNum, GooString *substituteFontName = NULL, GooString *base14Name = NULL); - GooString *findCCFontFile(GooString *collection); GBool getPSExpandSmaller(); GBool getPSShrinkLarger(); GBool getPSCenter(); PSLevel getPSLevel(); - GooString *getPSResidentFont(GooString *fontName); - GooList *getPSResidentFonts(); - PSFontParam16 *getPSResidentFont16(GooString *fontName, int wMode); - PSFontParam16 *getPSResidentFontCC(GooString *collection, int wMode); GooString *getTextEncodingName(); EndOfLineKind getTextEOL(); GBool getTextPageBreaks(); @@ -198,7 +177,6 @@ public: //----- functions to set parameters void addFontFile(GooString *fontName, GooString *path); - void setPSFile(char *file); void setPSExpandSmaller(GBool expand); void setPSShrinkLarger(GBool shrink); void setPSCenter(GBool center); @@ -270,24 +248,11 @@ private: #endif GooHash *fontFiles; // font files: font name mapped to path // [GString] - GooList *fontDirs; // list of font dirs [GString] - GooHash *ccFontFiles; // character collection font files: - // collection name mapped to path [GString] SysFontList *sysFonts; // system fonts - GooString *psFile; // PostScript file or command (for xpdf) GBool psExpandSmaller; // expand smaller pages to fill paper GBool psShrinkLarger; // shrink larger pages to fit paper GBool psCenter; // center pages on the paper PSLevel psLevel; // PostScript level to generate - GooHash *psResidentFonts; // 8-bit fonts resident in printer: - // PDF font name mapped to PS font name - // [GString] - GooList *psResidentFonts16; // 16-bit fonts resident in printer: - // PDF font name mapped to font info - // [PSFontParam16] - GooList *psResidentFontsCC; // 16-bit character collection fonts - // resident in printer: collection name - // mapped to font info [PSFontParam16] GooString *textEncoding; // encoding (unicodeMap) to use for text // output EndOfLineKind textEOL; // type of EOL marker to use for text @@ -310,7 +275,6 @@ private: GBool printCommands; // print the drawing commands GBool profileCommands; // profile the drawing commands GBool errQuiet; // suppress error messages? - double splashResolution; // resolution when rasterizing images CharCodeToUnicodeCache *cidToUnicodeCache; CharCodeToUnicodeCache *unicodeToUnicodeCache; diff --git a/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc b/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc index 1dc3d4ab5e1d940214e62240d3b93c2e16017f79..eba72fa00d9e89eb3659424d7a06a2ea3b71ef5c 100644 --- a/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc +++ b/source/libs/poppler/poppler-src/poppler/GlobalParamsWin.cc @@ -78,7 +78,7 @@ description for all fonts available in Windows. That's how MuPDF works. #define DEFAULT_CID_FONT_AK1_MSWIN "Batang" /* Adobe-Korea1 */ #define DEFAULT_CID_FONT_MSWIN "ArialUnicode" /* Unknown */ -static struct { +static const struct { const char *name; const char *t1FileName; const char *ttFileName; diff --git a/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc b/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc index 50c6eee6fba4fd5e3716fface2d8d607ce80318f..bda7f42eb7c5ad613e6f8912bb1b1a9168b75423 100644 --- a/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc +++ b/source/libs/poppler/poppler-src/poppler/JBIG2Stream.cc @@ -2964,8 +2964,8 @@ JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h, mmrDecoder->reset(); if (w > INT_MAX - 2) { error(errSyntaxError, curStr->getPos(), "Bad width in JBIG2 generic bitmap"); - // force a call to gmalloc(-1), which will throw an exception - w = -3; + delete bitmap; + return NULL; } // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = w // ---> max codingLine size = w + 1 diff --git a/source/libs/poppler/poppler-src/poppler/Makefile.am b/source/libs/poppler/poppler-src/poppler/Makefile.am deleted file mode 100644 index 8cf7af8503a6857724938022db28ca3e61c0946f..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/poppler/Makefile.am +++ /dev/null @@ -1,348 +0,0 @@ -CFLAGS+=$(PTHREAD_CFLAGS) -CXXFLAGS+=$(PTHREAD_CFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/goo - -lib_LTLIBRARIES = libpoppler.la - -if BUILD_CAIRO_OUTPUT -noinst_LTLIBRARIES = libpoppler-cairo.la -endif - -if BUILD_SPLASH_OUTPUT - -splash_sources = \ - SplashOutputDev.cc - -splash_headers = \ - SplashOutputDev.h - -splash_includes = \ - $(SPLASH_CFLAGS) - -splash_libs = \ - $(SPLASH_LIBS) \ - $(top_builddir)/splash/libsplash.la - -endif - -if BUILD_LIBJPEG - -libjpeg_sources = \ - DCTStream.h \ - DCTStream.cc - -libjpeg_libs = \ - $(LIBJPEG_LIBS) -libjpeg_includes = \ - $(LIBJPEG_CFLAGS) - -endif - -if BUILD_LIBPNG - -libpng_libs = \ - $(LIBPNG_LIBS) -libpng_includes = \ - $(LIBPNG_CFLAGS) - -endif - -if BUILD_LIBTIFF - -libtiff_libs = \ - $(LIBTIFF_LIBS) -libtiff_includes = \ - $(LIBTIFF_CFLAGS) - -endif - -if BUILD_LIBOPENJPEG - -libjpeg2000_sources = \ - JPEG2000Stream.h \ - JPEG2000Stream.cc - -libjpeg2000_libs = \ - $(LIBOPENJPEG_LIBS) -libjpeg2000_includes = \ - $(LIBOPENJPEG_CFLAGS) - -else - -libjpeg2000_sources = \ - JPXStream.h \ - JPXStream.cc - -endif - -if BUILD_NSS - -nss_sources = \ - SignatureHandler.cc - -nss_libs = \ - $(NSS3_LIBS) - -nss_includes = \ - $(NSS3_CFLAGS) - -nss_headers = \ - SignatureHandler.h - -endif - - -if BUILD_ZLIB - -zlib_sources = \ - FlateEncoder.h \ - FlateEncoder.cc - -zlib_libs = \ - $(ZLIB_LIBS) - -endif - -if BUILD_ZLIB_UNCOMPRESS - -zlib_uncompress_sources = \ - FlateStream.h \ - FlateStream.cc - -endif - -if BUILD_LIBCURL - -libcurl_libs = \ - $(LIBCURL_LIBS) - -libcurl_includes = \ - $(LIBCURL_CFLAGS) - -curl_headers = \ - CurlCachedFile.h \ - CurlPDFDocBuilder.h - -curl_sources = \ - CurlCachedFile.cc \ - CurlPDFDocBuilder.cc - -endif - -if USE_CMS -cms_includes = $(LCMS_CFLAGS) -cms_libs = $(LCMS_LIBS) -endif - -if ENABLE_XPDF_HEADERS - -poppler_includedir = $(includedir)/poppler -poppler_include_HEADERS = \ - $(splash_headers) \ - $(curl_headers) \ - $(nss_headers) \ - Annot.h \ - Array.h \ - BuiltinFont.h \ - BuiltinFontTables.h \ - CachedFile.h \ - Catalog.h \ - CharCodeToUnicode.h \ - CMap.h \ - DateInfo.h \ - Decrypt.h \ - Dict.h \ - Error.h \ - FileSpec.h \ - FontEncodingTables.h \ - FontInfo.h \ - Form.h \ - Function.h \ - Gfx.h \ - GfxFont.h \ - GfxState.h \ - GfxState_helpers.h \ - GlobalParams.h \ - Hints.h \ - JArithmeticDecoder.h \ - JBIG2Stream.h \ - Lexer.h \ - Linearization.h \ - Link.h \ - LocalPDFDocBuilder.h \ - Movie.h \ - NameToCharCode.h \ - Object.h \ - OptionalContent.h \ - Outline.h \ - OutputDev.h \ - Page.h \ - PageTransition.h \ - Parser.h \ - PDFDoc.h \ - PDFDocBuilder.h \ - PDFDocEncoding.h \ - PDFDocFactory.h \ - PopplerCache.h \ - ProfileData.h \ - PreScanOutputDev.h \ - PSTokenizer.h \ - Rendition.h \ - SignatureInfo.h \ - StdinCachedFile.h \ - StdinPDFDocBuilder.h \ - Stream-CCITT.h \ - Stream.h \ - StructElement.h \ - StructTreeRoot.h \ - UnicodeMap.h \ - UnicodeMapTables.h \ - UnicodeTypeTable.h \ - UnicodeCClassTables.h \ - UnicodeCompTables.h \ - UnicodeDecompTables.h \ - ViewerPreferences.h \ - XRef.h \ - CharTypes.h \ - CompactFontTables.h \ - ErrorCodes.h \ - NameToUnicodeTable.h \ - PSOutputDev.h \ - TextOutputDev.h \ - MarkedContentOutputDev.h \ - SecurityHandler.h \ - UTF.h \ - UTF8.h \ - XpdfPluginAPI.h \ - Sound.h -nodist_poppler_include_HEADERS = poppler-config.h - -endif - -libpoppler_la_SOURCES = \ - $(splash_sources) \ - $(libjpeg_sources) \ - $(zlib_sources) \ - $(zlib_uncompress_sources) \ - $(nss_sources) \ - $(libjpeg2000_sources) \ - $(curl_sources) \ - Annot.cc \ - Array.cc \ - BuiltinFont.cc \ - BuiltinFontTables.cc \ - CachedFile.cc \ - Catalog.cc \ - CharCodeToUnicode.cc \ - CMap.cc \ - DateInfo.cc \ - Decrypt.cc \ - Dict.cc \ - Error.cc \ - FileSpec.cc \ - FontEncodingTables.cc \ - Form.cc \ - FontInfo.cc \ - Function.cc \ - Gfx.cc \ - GfxFont.cc \ - GfxState.cc \ - GlobalParams.cc \ - Hints.cc \ - JArithmeticDecoder.cc \ - JBIG2Stream.cc \ - Lexer.cc \ - Linearization.cc \ - Link.cc \ - LocalPDFDocBuilder.cc \ - Movie.cc \ - NameToCharCode.cc \ - Object.cc \ - OptionalContent.cc \ - Outline.cc \ - OutputDev.cc \ - Page.cc \ - PageTransition.cc \ - Parser.cc \ - PDFDoc.cc \ - PDFDocEncoding.cc \ - PDFDocFactory.cc \ - PopplerCache.cc \ - ProfileData.cc \ - PreScanOutputDev.cc \ - PSTokenizer.cc \ - Rendition.cc \ - SignatureInfo.cc \ - StdinCachedFile.cc \ - StdinPDFDocBuilder.cc \ - Stream.cc \ - StructTreeRoot.cc \ - StructElement.cc \ - strtok_r.cpp \ - UnicodeMap.cc \ - UnicodeTypeTable.cc \ - UTF.cc \ - ViewerPreferences.cc \ - XRef.cc \ - PSOutputDev.cc \ - TextOutputDev.cc \ - MarkedContentOutputDev.cc \ - PageLabelInfo.h \ - PageLabelInfo.cc \ - SecurityHandler.cc \ - Sound.cc \ - XpdfPluginAPI.cc - -libpoppler_la_CPPFLAGS = \ - $(cms_includes) \ - $(splash_includes) \ - $(libjpeg_includes) \ - $(libtiff_includes) \ - $(libjpeg2000_includes) \ - $(libpng_includes) \ - $(libcurl_includes) \ - $(nss_includes) \ - $(FREETYPE_CFLAGS) \ - $(FONTCONFIG_CFLAGS) \ - $(AM_CPPFLAGS) - -libpoppler_la_LIBADD = \ - $(top_builddir)/goo/libgoo.la \ - $(top_builddir)/fofi/libfofi.la \ - $(cms_libs) \ - $(splash_libs) \ - $(libtiff_libs) \ - $(libjpeg_libs) \ - $(libpng_libs) \ - $(zlib_libs) \ - $(libcurl_libs) \ - $(nss_libs) \ - $(libjpeg2000_libs) \ - $(FREETYPE_LIBS) \ - $(FONTCONFIG_LIBS) \ - $(PTHREAD_LIBS) \ - $(win32_libs) - -libpoppler_la_LDFLAGS = \ - -version-info 70:0:0 \ - @create_shared_lib@ \ - @auto_import_flags@ - -libpoppler_cairo_la_SOURCES = \ - CairoFontEngine.cc \ - CairoFontEngine.h \ - CairoOutputDev.cc \ - CairoOutputDev.h \ - CairoRescaleBox.cc \ - CairoRescaleBox.h - -libpoppler_cairo_la_CPPFLAGS = \ - $(CAIRO_CFLAGS) \ - $(AM_CPPFLAGS) - -EXTRA_DIST = gen-unicode-tables.py \ - GlobalParamsWin.cc \ - PageLabelInfo_p.h diff --git a/source/libs/poppler/poppler-src/poppler/Object.cc b/source/libs/poppler/poppler-src/poppler/Object.cc index 4fce012dc6c662e19b7f6a125b03f0f983a2fd76..d3adc4473ab88119b6f319beecd834c5638bd1f2 100644 --- a/source/libs/poppler/poppler-src/poppler/Object.cc +++ b/source/libs/poppler/poppler-src/poppler/Object.cc @@ -160,11 +160,11 @@ void Object::free() { type = objNone; } -const char *Object::getTypeName() { +const char *Object::getTypeName() const { return objTypeNames[type]; } -void Object::print(FILE *f) { +void Object::print(FILE *f) const { Object obj; int i; diff --git a/source/libs/poppler/poppler-src/poppler/Object.h b/source/libs/poppler/poppler-src/poppler/Object.h index 331854781aed9f961d58e5bca5f312bdeefe9130..50b2c1611929398c281ff98d4f4209d1c44005e8 100644 --- a/source/libs/poppler/poppler-src/poppler/Object.h +++ b/source/libs/poppler/poppler-src/poppler/Object.h @@ -184,100 +184,100 @@ public: Object fetch(XRef *xref, int recursion = 0) const; // Type checking. - ObjType getType() { CHECK_NOT_DEAD; return type; } - GBool isBool() { CHECK_NOT_DEAD; return type == objBool; } - GBool isInt() { CHECK_NOT_DEAD; return type == objInt; } - GBool isReal() { CHECK_NOT_DEAD; return type == objReal; } - GBool isNum() { CHECK_NOT_DEAD; return type == objInt || type == objReal || type == objInt64; } - GBool isString() { CHECK_NOT_DEAD; return type == objString; } - GBool isName() { CHECK_NOT_DEAD; return type == objName; } - GBool isNull() { CHECK_NOT_DEAD; return type == objNull; } - GBool isArray() { CHECK_NOT_DEAD; return type == objArray; } - GBool isDict() { CHECK_NOT_DEAD; return type == objDict; } - GBool isStream() { CHECK_NOT_DEAD; return type == objStream; } - GBool isRef() { CHECK_NOT_DEAD; return type == objRef; } - GBool isCmd() { CHECK_NOT_DEAD; return type == objCmd; } - GBool isError() { CHECK_NOT_DEAD; return type == objError; } - GBool isEOF() { CHECK_NOT_DEAD; return type == objEOF; } - GBool isNone() { CHECK_NOT_DEAD; return type == objNone; } - GBool isInt64() { CHECK_NOT_DEAD; return type == objInt64; } - GBool isIntOrInt64() { CHECK_NOT_DEAD; return type == objInt || type == objInt64; } + ObjType getType() const { CHECK_NOT_DEAD; return type; } + GBool isBool() const { CHECK_NOT_DEAD; return type == objBool; } + GBool isInt() const { CHECK_NOT_DEAD; return type == objInt; } + GBool isReal() const { CHECK_NOT_DEAD; return type == objReal; } + GBool isNum() const { CHECK_NOT_DEAD; return type == objInt || type == objReal || type == objInt64; } + GBool isString() const { CHECK_NOT_DEAD; return type == objString; } + GBool isName() const { CHECK_NOT_DEAD; return type == objName; } + GBool isNull() const { CHECK_NOT_DEAD; return type == objNull; } + GBool isArray() const { CHECK_NOT_DEAD; return type == objArray; } + GBool isDict() const { CHECK_NOT_DEAD; return type == objDict; } + GBool isStream() const { CHECK_NOT_DEAD; return type == objStream; } + GBool isRef() const { CHECK_NOT_DEAD; return type == objRef; } + GBool isCmd() const { CHECK_NOT_DEAD; return type == objCmd; } + GBool isError() const { CHECK_NOT_DEAD; return type == objError; } + GBool isEOF() const { CHECK_NOT_DEAD; return type == objEOF; } + GBool isNone() const { CHECK_NOT_DEAD; return type == objNone; } + GBool isInt64() const { CHECK_NOT_DEAD; return type == objInt64; } + GBool isIntOrInt64() const { CHECK_NOT_DEAD; return type == objInt || type == objInt64; } // Special type checking. - GBool isName(const char *nameA) + GBool isName(const char *nameA) const { return type == objName && !strcmp(cString, nameA); } - GBool isDict(const char *dictType); - GBool isStream(const char *dictType); - GBool isCmd(const char *cmdA) + GBool isDict(const char *dictType) const; + GBool isStream(const char *dictType) const; + GBool isCmd(const char *cmdA) const { return type == objCmd && !strcmp(cString, cmdA); } // Accessors. - GBool getBool() { OBJECT_TYPE_CHECK(objBool); return booln; } - int getInt() { OBJECT_TYPE_CHECK(objInt); return intg; } - double getReal() { OBJECT_TYPE_CHECK(objReal); return real; } + GBool getBool() const { OBJECT_TYPE_CHECK(objBool); return booln; } + int getInt() const { OBJECT_TYPE_CHECK(objInt); return intg; } + double getReal() const { OBJECT_TYPE_CHECK(objReal); return real; } // Note: integers larger than 2^53 can not be exactly represented by a double. // Where the exact value of integers up to 2^63 is required, use isInt64()/getInt64(). - double getNum() { OBJECT_3TYPES_CHECK(objInt, objInt64, objReal); + double getNum() const { OBJECT_3TYPES_CHECK(objInt, objInt64, objReal); return type == objInt ? (double)intg : type == objInt64 ? (double)int64g : real; } - double getNum(bool *ok) { + double getNum(bool *ok) const { if (unlikely(type != objInt && type != objInt64 && type != objReal)) { *ok = false; return 0.; } return type == objInt ? (double)intg : type == objInt64 ? (double)int64g : real; } - GooString *getString() { OBJECT_TYPE_CHECK(objString); return string; } + GooString *getString() const { OBJECT_TYPE_CHECK(objString); return string; } // After takeString() the only method that should be called for the object is free() // because the object it's not expected to have a NULL string. GooString *takeString() { OBJECT_TYPE_CHECK(objString); GooString *s = string; string = NULL; return s; } - char *getName() { OBJECT_TYPE_CHECK(objName); return cString; } - Array *getArray() { OBJECT_TYPE_CHECK(objArray); return array; } - Dict *getDict() { OBJECT_TYPE_CHECK(objDict); return dict; } - Stream *getStream() { OBJECT_TYPE_CHECK(objStream); return stream; } - Ref getRef() { OBJECT_TYPE_CHECK(objRef); return ref; } - int getRefNum() { OBJECT_TYPE_CHECK(objRef); return ref.num; } - int getRefGen() { OBJECT_TYPE_CHECK(objRef); return ref.gen; } - char *getCmd() { OBJECT_TYPE_CHECK(objCmd); return cString; } - long long getInt64() { OBJECT_TYPE_CHECK(objInt64); return int64g; } - long long getIntOrInt64() { OBJECT_2TYPES_CHECK(objInt, objInt64); + char *getName() const { OBJECT_TYPE_CHECK(objName); return cString; } + Array *getArray() const { OBJECT_TYPE_CHECK(objArray); return array; } + Dict *getDict() const { OBJECT_TYPE_CHECK(objDict); return dict; } + Stream *getStream() const { OBJECT_TYPE_CHECK(objStream); return stream; } + Ref getRef() const { OBJECT_TYPE_CHECK(objRef); return ref; } + int getRefNum() const { OBJECT_TYPE_CHECK(objRef); return ref.num; } + int getRefGen() const { OBJECT_TYPE_CHECK(objRef); return ref.gen; } + char *getCmd() const { OBJECT_TYPE_CHECK(objCmd); return cString; } + long long getInt64() const { OBJECT_TYPE_CHECK(objInt64); return int64g; } + long long getIntOrInt64() const { OBJECT_2TYPES_CHECK(objInt, objInt64); return type == objInt ? intg : int64g; } // Array accessors. - int arrayGetLength(); + int arrayGetLength() const; void arrayAdd(Object &&elem); void arrayRemove(int i); - Object arrayGet(int i, int recursion); - Object arrayGetNF(int i); + Object arrayGet(int i, int recursion) const; + Object arrayGetNF(int i) const; // Dict accessors. - int dictGetLength(); + int dictGetLength() const; void dictAdd(char *key, Object &&val); void dictSet(const char *key, Object &&val); void dictRemove(const char *key); - GBool dictIs(const char *dictType); - Object dictLookup(const char *key, int recursion = 0); - Object dictLookupNF(const char *key); - char *dictGetKey(int i); - Object dictGetVal(int i); - Object dictGetValNF(int i); + GBool dictIs(const char *dictType) const; + Object dictLookup(const char *key, int recursion = 0) const; + Object dictLookupNF(const char *key) const; + char *dictGetKey(int i) const; + Object dictGetVal(int i) const; + Object dictGetValNF(int i) const; // Stream accessors. - GBool streamIs(const char *dictType); + GBool streamIs(const char *dictType) const; void streamReset(); void streamClose(); - int streamGetChar(); - int streamGetChars(int nChars, Guchar *buffer); - int streamLookChar(); - char *streamGetLine(char *buf, int size); - Goffset streamGetPos(); + int streamGetChar() const; + int streamGetChars(int nChars, Guchar *buffer) const; + int streamLookChar() const; + char *streamGetLine(char *buf, int size) const; + Goffset streamGetPos() const; void streamSetPos(Goffset pos, int dir = 0); - Dict *streamGetDict(); + Dict *streamGetDict() const; // Output. - const char *getTypeName(); - void print(FILE *f = stdout); + const char *getTypeName() const; + void print(FILE *f = stdout) const; // Memory testing. static void memCheck(FILE *f); @@ -319,7 +319,7 @@ private: #include "Array.h" -inline int Object::arrayGetLength() +inline int Object::arrayGetLength() const { OBJECT_TYPE_CHECK(objArray); return array->getLength(); } inline void Object::arrayAdd(Object &&elem) @@ -328,10 +328,10 @@ inline void Object::arrayAdd(Object &&elem) inline void Object::arrayRemove(int i) { OBJECT_TYPE_CHECK(objArray); array->remove(i); } -inline Object Object::arrayGet(int i, int recursion = 0) +inline Object Object::arrayGet(int i, int recursion = 0) const { OBJECT_TYPE_CHECK(objArray); return array->get(i, recursion); } -inline Object Object::arrayGetNF(int i) +inline Object Object::arrayGetNF(int i) const { OBJECT_TYPE_CHECK(objArray); return array->getNF(i); } //------------------------------------------------------------------------ @@ -340,7 +340,7 @@ inline Object Object::arrayGetNF(int i) #include "Dict.h" -inline int Object::dictGetLength() +inline int Object::dictGetLength() const { OBJECT_TYPE_CHECK(objDict); return dict->getLength(); } inline void Object::dictAdd(char *key, Object &&val) @@ -352,25 +352,25 @@ inline void Object::dictSet(const char *key, Object &&val) inline void Object::dictRemove(const char *key) { OBJECT_TYPE_CHECK(objDict); dict->remove(key); } -inline GBool Object::dictIs(const char *dictType) +inline GBool Object::dictIs(const char *dictType) const { OBJECT_TYPE_CHECK(objDict); return dict->is(dictType); } -inline GBool Object::isDict(const char *dictType) +inline GBool Object::isDict(const char *dictType) const { return type == objDict && dictIs(dictType); } -inline Object Object::dictLookup(const char *key, int recursion) +inline Object Object::dictLookup(const char *key, int recursion) const { OBJECT_TYPE_CHECK(objDict); return dict->lookup(key, recursion); } -inline Object Object::dictLookupNF(const char *key) +inline Object Object::dictLookupNF(const char *key) const { OBJECT_TYPE_CHECK(objDict); return dict->lookupNF(key); } -inline char *Object::dictGetKey(int i) +inline char *Object::dictGetKey(int i) const { OBJECT_TYPE_CHECK(objDict); return dict->getKey(i); } -inline Object Object::dictGetVal(int i) +inline Object Object::dictGetVal(int i) const { OBJECT_TYPE_CHECK(objDict); return dict->getVal(i); } -inline Object Object::dictGetValNF(int i) +inline Object Object::dictGetValNF(int i) const { OBJECT_TYPE_CHECK(objDict); return dict->getValNF(i); } //------------------------------------------------------------------------ @@ -379,10 +379,10 @@ inline Object Object::dictGetValNF(int i) #include "Stream.h" -inline GBool Object::streamIs(const char *dictType) +inline GBool Object::streamIs(const char *dictType) const { OBJECT_TYPE_CHECK(objStream); return stream->getDict()->is(dictType); } -inline GBool Object::isStream(const char *dictType) +inline GBool Object::isStream(const char *dictType) const { return type == objStream && streamIs(dictType); } inline void Object::streamReset() @@ -391,25 +391,25 @@ inline void Object::streamReset() inline void Object::streamClose() { OBJECT_TYPE_CHECK(objStream); stream->close(); } -inline int Object::streamGetChar() +inline int Object::streamGetChar() const { OBJECT_TYPE_CHECK(objStream); return stream->getChar(); } -inline int Object::streamGetChars(int nChars, Guchar *buffer) +inline int Object::streamGetChars(int nChars, Guchar *buffer) const { OBJECT_TYPE_CHECK(objStream); return stream->doGetChars(nChars, buffer); } -inline int Object::streamLookChar() +inline int Object::streamLookChar() const { OBJECT_TYPE_CHECK(objStream); return stream->lookChar(); } -inline char *Object::streamGetLine(char *buf, int size) +inline char *Object::streamGetLine(char *buf, int size) const { OBJECT_TYPE_CHECK(objStream); return stream->getLine(buf, size); } -inline Goffset Object::streamGetPos() +inline Goffset Object::streamGetPos() const { OBJECT_TYPE_CHECK(objStream); return stream->getPos(); } inline void Object::streamSetPos(Goffset pos, int dir) { OBJECT_TYPE_CHECK(objStream); stream->setPos(pos, dir); } -inline Dict *Object::streamGetDict() +inline Dict *Object::streamGetDict() const { OBJECT_TYPE_CHECK(objStream); return stream->getDict(); } #endif diff --git a/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc b/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc index b2d6d3a94bd16f95582c9dbf05bcf80e65b10c01..5e4226f429ae1e8b976d2f087a903ed1ef277f1b 100644 --- a/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc +++ b/source/libs/poppler/poppler-src/poppler/PSOutputDev.cc @@ -23,7 +23,7 @@ // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009, 2011, 2012, 2014-2016 William Bader <williambader@hotmail.com> +// Copyright (C) 2009, 2011, 2012, 2014-2017 William Bader <williambader@hotmail.com> // Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> // Copyright (C) 2009-2011, 2013-2015 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012, 2014 Fabio D'Urso <fabiodurso@hotmail.it> @@ -1311,7 +1311,6 @@ void PSOutputDev::postInit() Catalog *catalog; PDFRectangle *box; PSOutPaperSize *size; - GooList *names; int w, h, i; if (postInitDone || !ok) { @@ -1405,11 +1404,6 @@ void PSOutputDev::postInit() for (i = 0; i < 14; ++i) { fontNames->add(new GooString(psBase14SubstFonts[i].psName), 1); } - names = globalParams->getPSResidentFonts(); - for (i = 0; i < names->getLength(); ++i) { - fontNames->add((GooString *)names->get(i), 1); - } - delete names; t1FontNameSize = 64; t1FontNameLen = 0; t1FontNames = (PST1FontName *)gmallocn(t1FontNameSize, sizeof(PST1FontName)); @@ -2544,6 +2538,14 @@ void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, GooString *fileName, writePS("%%EndResource\n"); } +void PSOutputDev::updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph) { + if (maxValidGlyph >= 0 && font->getName()) { + if (maxValidGlyph > fontMaxValidGlyph->lookupInt(font->getName())) { + fontMaxValidGlyph->replace(font->getName()->copy(), maxValidGlyph); + } + } +} + void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *fileName, GooString *psName, @@ -2594,9 +2596,7 @@ void PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, needVerticalMetrics, &maxValidGlyph, outputFunc, outputStream); - if (maxValidGlyph >= 0 && font->getName()) { - fontMaxValidGlyph->replace(font->getName()->copy(), maxValidGlyph); - } + updateFontMaxValidGlyph(font, maxValidGlyph); } gfree(codeToGID); } else { @@ -2696,9 +2696,7 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, needVerticalMetrics, &maxValidGlyph, outputFunc, outputStream); - if (maxValidGlyph > 0 && font->getName()) { - fontMaxValidGlyph->replace(font->getName()->copy(), maxValidGlyph); - } + updateFontMaxValidGlyph(font, maxValidGlyph); } delete ffTT; } diff --git a/source/libs/poppler/poppler-src/poppler/PSOutputDev.h b/source/libs/poppler/poppler-src/poppler/PSOutputDev.h index 833f686eaf54f0204b1027e141c791a94724f217..8dd1c950406a6cb5e4bdf9944642ea6c5e8ce618 100644 --- a/source/libs/poppler/poppler-src/poppler/PSOutputDev.h +++ b/source/libs/poppler/poppler-src/poppler/PSOutputDev.h @@ -20,7 +20,7 @@ // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com> // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org> -// Copyright (C) 2009, 2011, 2015-2016 William Bader <williambader@hotmail.com> +// Copyright (C) 2009, 2011, 2015-2017 William Bader <williambader@hotmail.com> // Copyright (C) 2010 Hib Eris <hib@hiberis.nl> // Copyright (C) 2011, 2014 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> @@ -355,6 +355,7 @@ private: void setupFonts(Dict *resDict); void setupFont(GfxFont *font, Dict *parentResDict); void setupEmbeddedType1Font(Ref *id, GooString *psName); + void updateFontMaxValidGlyph(GfxFont *font, int maxValidGlyph); void setupExternalType1Font(GooString *fileName, GooString *psName); void setupEmbeddedType1CFont(GfxFont *font, Ref *id, GooString *psName); void setupEmbeddedOpenTypeT1CFont(GfxFont *font, Ref *id, GooString *psName); diff --git a/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc b/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc index 60edb8ac8fbe9bd8f4e5f8d49e47ccc41738198d..dc5b687146213caf66b68feb520505d54a3b4506 100644 --- a/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc +++ b/source/libs/poppler/poppler-src/poppler/SplashOutputDev.cc @@ -128,6 +128,7 @@ static inline void convertGfxColor(SplashColorPtr dest, break; case splashModeXBGR8: color[3] = 255; + // fallthrough case splashModeBGR8: case splashModeRGB8: colorSpace->getRGB(src, &rgb); @@ -175,6 +176,7 @@ static inline void convertGfxShortColor(SplashColorPtr dest, break; case splashModeXBGR8: dest[3] = 255; + // fallthrough case splashModeBGR8: case splashModeRGB8: { @@ -1016,6 +1018,7 @@ static void splashOutBlendHue(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setSat(src[0], src[1], src[2], getSat(dest[0], dest[1], dest[2]), @@ -1066,6 +1069,7 @@ static void splashOutBlendSaturation(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setSat(dest[0], dest[1], dest[2], getSat(src[0], src[1], src[2]), @@ -1113,6 +1117,7 @@ static void splashOutBlendColor(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setLum(src[0], src[1], src[2], getLum(dest[0], dest[1], dest[2]), @@ -1157,6 +1162,7 @@ static void splashOutBlendLuminosity(SplashColorPtr src, SplashColorPtr dest, break; case splashModeXBGR8: src[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: setLum(dest[0], dest[1], dest[2], getLum(src[0], src[1], src[2]), @@ -1570,6 +1576,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state, XRef *xrefA) { break; case splashModeXBGR8: color[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: color[0] = color[1] = color[2] = 0; @@ -2716,7 +2723,11 @@ void SplashOutputDev::endType3Char(GfxState *state) { } void SplashOutputDev::type3D0(GfxState *state, double wx, double wy) { - t3GlyphStack->haveDx = gTrue; + if (likely(t3GlyphStack != nullptr)) { + t3GlyphStack->haveDx = gTrue; + } else { + error(errSyntaxWarning, -1, "t3GlyphStack was null in SplashOutputDev::type3D0"); + } } void SplashOutputDev::type3D1(GfxState *state, double wx, double wy, @@ -4424,6 +4435,7 @@ void SplashOutputDev::setSoftMask(GfxState *state, double *bbox, break; case splashModeXBGR8: color[3] = 255; + // fallthrough case splashModeRGB8: case splashModeBGR8: transpGroupStack->blendingColorSpace->getRGB(backdropColor, &rgb); diff --git a/source/libs/poppler/poppler-src/poppler/Stream.cc b/source/libs/poppler/poppler-src/poppler/Stream.cc index f4eda85b331bec080d5373dd8c324c85712b46dd..0ad602c79e3a6f4eae7de675665bc965c3e9a76a 100644 --- a/source/libs/poppler/poppler-src/poppler/Stream.cc +++ b/source/libs/poppler/poppler-src/poppler/Stream.cc @@ -454,11 +454,10 @@ ImageStream::ImageStream(Stream *strA, int widthA, int nCompsA, int nBitsA) { } else { imgLineSize = nVals; } - if (width > INT_MAX / nComps) { - // force a call to gmallocn(-1,...), which will throw an exception + if (nComps <= 0 || width > INT_MAX / nComps) { imgLineSize = -1; } - imgLine = (Guchar *)gmallocn(imgLineSize, sizeof(Guchar)); + imgLine = (Guchar *)gmallocn_checkoverflow(imgLineSize, sizeof(Guchar)); } imgIdx = nVals; } diff --git a/source/libs/poppler/poppler-src/poppler/Stream.h b/source/libs/poppler/poppler-src/poppler/Stream.h index 4f83275d35e3f236fb1682674f8f4c91ca04a583..c2c48111ceb9a2b088730b62c978fa595c88613b 100644 --- a/source/libs/poppler/poppler-src/poppler/Stream.h +++ b/source/libs/poppler/poppler-src/poppler/Stream.h @@ -284,7 +284,7 @@ public: void put (char c) override; - void printf (const char *format, ...) override; + void printf (const char *format, ...) override GCC_PRINTF_FORMAT(2,3); private: FILE *f; Goffset start; diff --git a/source/libs/poppler/poppler-src/poppler/StructElement.cc b/source/libs/poppler/poppler-src/poppler/StructElement.cc index 0fbd336a67a32f5e3f20dba2a1d1702374fffa40..629254743500d4431c0fe155e6f924d57ebd07ab 100644 --- a/source/libs/poppler/poppler-src/poppler/StructElement.cc +++ b/source/libs/poppler/poppler-src/poppler/StructElement.cc @@ -226,13 +226,13 @@ static GBool isTextString(Object *value) return okay; \ } -ARRAY_CHECKER(isRGBColorOrOptionalArray4, isRGBColor, 4, gTrue, gTrue ); -ARRAY_CHECKER(isPositiveOrOptionalArray4, isPositive, 4, gTrue, gTrue ); -ARRAY_CHECKER(isPositiveOrArray4, isPositive, 4, gTrue, gFalse); -ARRAY_CHECKER(isBorderStyle, isBorderStyleName, 4, gTrue, gTrue ); -ARRAY_CHECKER(isNumberArray4, isNumber, 4, gFalse, gFalse); -ARRAY_CHECKER(isNumberOrArrayN, isNumber, 0, gTrue, gFalse); -ARRAY_CHECKER(isTableHeaders, isTextString, 0, gFalse, gFalse); +ARRAY_CHECKER(isRGBColorOrOptionalArray4, isRGBColor, 4, gTrue, gTrue ) +ARRAY_CHECKER(isPositiveOrOptionalArray4, isPositive, 4, gTrue, gTrue ) +ARRAY_CHECKER(isPositiveOrArray4, isPositive, 4, gTrue, gFalse) +ARRAY_CHECKER(isBorderStyle, isBorderStyleName, 4, gTrue, gTrue ) +ARRAY_CHECKER(isNumberArray4, isNumber, 4, gFalse, gFalse) +ARRAY_CHECKER(isNumberOrArrayN, isNumber, 0, gTrue, gFalse) +ARRAY_CHECKER(isTableHeaders, isTextString, 0, gFalse, gFalse) // Type of functions used to do type-checking on attribute values @@ -248,6 +248,8 @@ struct AttributeMapEntry { }; struct AttributeDefaults { + AttributeDefaults() {}; // needed to support old clang + Object Inline = Object(objName, "Inline"); Object LrTb = Object(objName, "LrTb"); Object Normal = Object(objName, "Normal"); diff --git a/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc b/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc index a89ba23cdb58690b11c0dba61d49cbbedb1f4062..d30874cf3871ded5ff24526a32dd5bf34521f1d7 100644 --- a/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc +++ b/source/libs/poppler/poppler-src/poppler/TextOutputDev.cc @@ -565,7 +565,7 @@ static struct CombiningTable combiningTable[] = { }; // returning combining versions of characters -Unicode getCombiningChar(Unicode u) { +static Unicode getCombiningChar(Unicode u) { int len = sizeof(combiningTable) / sizeof(combiningTable[0]); for (int i = 0; i < len; ++i) { if (u == combiningTable[i].base) diff --git a/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc b/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc index 1319666779b0cf66cf876ceea4ad515006c4a59c..15d9a81e6e43dc4c48d42d715d25f4ed95e68892 100644 --- a/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc +++ b/source/libs/poppler/poppler-src/poppler/UnicodeMap.cc @@ -14,6 +14,7 @@ // under GPL version 2 or later // // Copyright (C) 2010 Jakub Wilk <jwilk@jwilk.net> +// Copyright (C) 2017 Albert Astals Cid <aacid@kde.org> // // 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 @@ -55,7 +56,7 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) { UnicodeMapExt *eMap; int size, eMapsSize; char buf[256]; - int line, nBytes, i, x; + int line, nBytes, i; char *tok1, *tok2, *tok3; char *tokptr; @@ -102,6 +103,7 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) { eMap = &map->eMaps[map->eMapsLen]; sscanf(tok1, "%x", &eMap->u); for (i = 0; i < nBytes; ++i) { + unsigned int x; sscanf(tok3 + i*2, "%2x", &x); eMap->code[i] = (char)x; } diff --git a/source/libs/poppler/poppler-src/poppler/XRef.cc b/source/libs/poppler/poppler-src/poppler/XRef.cc index eca2dc708996d422b0a8c527388bad759cd37217..f3b88ec0e4d63d8350ff3ddee9f307f4d0121573 100644 --- a/source/libs/poppler/poppler-src/poppler/XRef.cc +++ b/source/libs/poppler/poppler-src/poppler/XRef.cc @@ -1526,6 +1526,9 @@ GBool XRef::parseEntry(Goffset offset, XRefEntry *entry) { GBool r; + if (unlikely(entry == nullptr)) + return gFalse; + Parser parser(NULL, new Lexer(NULL, str->makeSubStream(offset, gFalse, 20, Object(objNull))), gTrue); diff --git a/source/libs/poppler/poppler-src/poppler/poppler-config.h.in b/source/libs/poppler/poppler-src/poppler/poppler-config.h.in index 0d0aa9e52b4d3670902f7950d516d4cd53c4b592..142f6df87a620d9bd155ff22a48d53443ffddd18 100644 --- a/source/libs/poppler/poppler-src/poppler/poppler-config.h.in +++ b/source/libs/poppler/poppler-src/poppler/poppler-config.h.in @@ -34,7 +34,7 @@ /* Defines the poppler version. */ #ifndef POPPLER_VERSION -#undef POPPLER_VERSION +#define POPPLER_VERSION "${POPPLER_VERSION}" #endif /* Enable multithreading support. */ @@ -82,9 +82,9 @@ #undef ENABLE_LIBPNG #endif -/* Use zlib instead of builtin zlib decoder for uncompressing flate streams. */ -#ifndef ENABLE_ZLIB_UNCOMPRESS -#undef ENABLE_ZLIB_UNCOMPRESS +/* Use zlib instead of builtin zlib decoder. */ +#ifndef ENABLE_ZLIB +#undef ENABLE_ZLIB #endif /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. diff --git a/source/libs/poppler/poppler-src/splash/Makefile.am b/source/libs/poppler/poppler-src/splash/Makefile.am deleted file mode 100644 index 5c265d6360c438f33de758299c09f22bb311658f..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -noinst_LTLIBRARIES = libsplash.la - -if ENABLE_XPDF_HEADERS - -poppler_splash_includedir = $(includedir)/poppler/splash -poppler_splash_include_HEADERS = \ - Splash.h \ - SplashBitmap.h \ - SplashClip.h \ - SplashErrorCodes.h \ - SplashFTFont.h \ - SplashFTFontEngine.h \ - SplashFTFontFile.h \ - SplashFont.h \ - SplashFontEngine.h \ - SplashFontFile.h \ - SplashFontFileID.h \ - SplashGlyphBitmap.h \ - SplashMath.h \ - SplashPath.h \ - SplashPattern.h \ - SplashScreen.h \ - SplashState.h \ - SplashT1Font.h \ - SplashT1FontEngine.h \ - SplashT1FontFile.h \ - SplashTypes.h \ - SplashXPath.h \ - SplashXPathScanner.h - -endif - -libsplash_la_SOURCES = \ - Splash.cc \ - SplashBitmap.cc \ - SplashClip.cc \ - SplashFTFont.cc \ - SplashFTFontEngine.cc \ - SplashFTFontFile.cc \ - SplashFont.cc \ - SplashFontEngine.cc \ - SplashFontFile.cc \ - SplashFontFileID.cc \ - SplashPath.cc \ - SplashPattern.cc \ - SplashScreen.cc \ - SplashState.cc \ - SplashT1Font.cc \ - SplashT1FontEngine.cc \ - SplashT1FontFile.cc \ - SplashXPath.cc \ - SplashXPathScanner.cc - -# SplashBitmap includes JpegWriter.h, TiffWriter.h, PNGWriter.h -if BUILD_LIBJPEG -libjpeg_includes = $(LIBJPEG_CFLAGS) -endif - -if BUILD_LIBTIFF -libtiff_includes = $(LIBTIFF_CFLAGS) -endif - -if BUILD_LIBPNG -libpng_includes = $(LIBPNG_CFLAGS) -endif - -libsplash_la_CPPFLAGS = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/goo \ - $(libjpeg_includes) \ - $(libtiff_includes) \ - $(libpng_includes) \ - $(FREETYPE_CFLAGS) diff --git a/source/libs/poppler/poppler-src/splash/Splash.cc b/source/libs/poppler/poppler-src/splash/Splash.cc deleted file mode 100644 index 46b8ce292c2cf407adb1df6d7d8f9941f82ffff6..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/Splash.cc +++ /dev/null @@ -1,6477 +0,0 @@ -//======================================================================== -// -// Splash.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005-2016 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> -// Copyright (C) 2010-2016 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> -// Copyright (C) 2011-2013, 2015 William Bader <williambader@hotmail.com> -// Copyright (C) 2012 Markus Trippelsdorf <markus@trippelsdorf.de> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2012 Matthias Kramm <kramm@quiss.org> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <string.h> -#include <limits.h> -#include <assert.h> -#include <math.h> -#include "goo/gmem.h" -#include "goo/GooLikely.h" -#include "goo/GooList.h" -#include "poppler/Error.h" -#include "SplashErrorCodes.h" -#include "SplashMath.h" -#include "SplashBitmap.h" -#include "SplashState.h" -#include "SplashPath.h" -#include "SplashXPath.h" -#include "SplashXPathScanner.h" -#include "SplashPattern.h" -#include "SplashScreen.h" -#include "SplashFont.h" -#include "SplashGlyphBitmap.h" -#include "Splash.h" -#include <algorithm> - -//------------------------------------------------------------------------ - -#define splashAAGamma 1.5 - -// distance of Bezier control point from center for circle approximation -// = (4 * (sqrt(2) - 1) / 3) * r -#define bezierCircle ((SplashCoord)0.55228475) -#define bezierCircle2 ((SplashCoord)(0.5 * 0.55228475)) - -// Divide a 16-bit value (in [0, 255*255]) by 255, returning an 8-bit result. -static inline Guchar div255(int x) { - return (Guchar)((x + (x >> 8) + 0x80) >> 8); -} - -// Clip x to lie in [0, 255]. -static inline Guchar clip255(int x) { - return x < 0 ? 0 : x > 255 ? 255 : x; -} - -template<typename T> -inline void Guswap( T&a, T&b ) { T tmp = a; a=b; b=tmp; } - -// The PDF spec says that all pixels whose *centers* lie within the -// image target region get painted, so we want to round n+0.5 down to -// n. But this causes problems, e.g., with PDF files that fill a -// rectangle with black and then draw an image to the exact same -// rectangle, so we instead use the fill scan conversion rule. -// However, the correct rule works better for glyphs, so we also -// provide that option in fillImageMask. -#if 0 -static inline int imgCoordMungeLower(SplashCoord x) { - return splashCeil(x + 0.5) - 1; -} -static inline int imgCoordMungeUpper(SplashCoord x) { - return splashCeil(x + 0.5) - 1; -} -#else -static inline int imgCoordMungeLower(SplashCoord x) { - return splashFloor(x); -} -static inline int imgCoordMungeUpper(SplashCoord x) { - return splashFloor(x) + 1; -} -static inline int imgCoordMungeLowerC(SplashCoord x, GBool glyphMode) { - return glyphMode ? (splashCeil(x + 0.5) - 1) : splashFloor(x); -} -static inline int imgCoordMungeUpperC(SplashCoord x, GBool glyphMode) { - return glyphMode ? (splashCeil(x + 0.5) - 1) : (splashFloor(x) + 1); -} -#endif - -// Used by drawImage and fillImageMask to divide the target -// quadrilateral into sections. -struct ImageSection { - int y0, y1; // actual y range - int ia0, ia1; // vertex indices for edge A - int ib0, ib1; // vertex indices for edge A - SplashCoord xa0, ya0, xa1, ya1; // edge A - SplashCoord dxdya; // slope of edge A - SplashCoord xb0, yb0, xb1, yb1; // edge B - SplashCoord dxdyb; // slope of edge B -}; - -//------------------------------------------------------------------------ -// SplashPipe -//------------------------------------------------------------------------ - -#define splashPipeMaxStages 9 - -struct SplashPipe { - // pixel coordinates - int x, y; - - // source pattern - SplashPattern *pattern; - - // source alpha and color - Guchar aInput; - GBool usesShape; - SplashColorPtr cSrc; - SplashColor cSrcVal; - - // non-isolated group alpha0 - Guchar *alpha0Ptr; - - // knockout groups - GBool knockout; - Guchar knockoutOpacity; - - // soft mask - SplashColorPtr softMaskPtr; - - // destination alpha and color - SplashColorPtr destColorPtr; - int destColorMask; - Guchar *destAlphaPtr; - - // shape - Guchar shape; - - // result alpha and color - GBool noTransparency; - SplashPipeResultColorCtrl resultColorCtrl; - - // non-isolated group correction - GBool nonIsolatedGroup; - - // the "run" function - void (Splash::*run)(SplashPipe *pipe); -}; - -SplashPipeResultColorCtrl Splash::pipeResultColorNoAlphaBlend[] = { - splashPipeResultColorNoAlphaBlendMono, - splashPipeResultColorNoAlphaBlendMono, - splashPipeResultColorNoAlphaBlendRGB, - splashPipeResultColorNoAlphaBlendRGB, - splashPipeResultColorNoAlphaBlendRGB -#if SPLASH_CMYK - , - splashPipeResultColorNoAlphaBlendCMYK, - splashPipeResultColorNoAlphaBlendDeviceN -#endif -}; - -SplashPipeResultColorCtrl Splash::pipeResultColorAlphaNoBlend[] = { - splashPipeResultColorAlphaNoBlendMono, - splashPipeResultColorAlphaNoBlendMono, - splashPipeResultColorAlphaNoBlendRGB, - splashPipeResultColorAlphaNoBlendRGB, - splashPipeResultColorAlphaNoBlendRGB -#if SPLASH_CMYK - , - splashPipeResultColorAlphaNoBlendCMYK, - splashPipeResultColorAlphaNoBlendDeviceN -#endif -}; - -SplashPipeResultColorCtrl Splash::pipeResultColorAlphaBlend[] = { - splashPipeResultColorAlphaBlendMono, - splashPipeResultColorAlphaBlendMono, - splashPipeResultColorAlphaBlendRGB, - splashPipeResultColorAlphaBlendRGB, - splashPipeResultColorAlphaBlendRGB -#if SPLASH_CMYK - , - splashPipeResultColorAlphaBlendCMYK, - splashPipeResultColorAlphaBlendDeviceN -#endif -}; - -//------------------------------------------------------------------------ - -static void blendXor(SplashColorPtr src, SplashColorPtr dest, - SplashColorPtr blend, SplashColorMode cm) { - int i; - - for (i = 0; i < splashColorModeNComps[cm]; ++i) { - blend[i] = src[i] ^ dest[i]; - } -} - -//------------------------------------------------------------------------ -// modified region -//------------------------------------------------------------------------ - -void Splash::clearModRegion() { - modXMin = bitmap->getWidth(); - modYMin = bitmap->getHeight(); - modXMax = -1; - modYMax = -1; -} - -inline void Splash::updateModX(int x) { - if (x < modXMin) { - modXMin = x; - } - if (x > modXMax) { - modXMax = x; - } -} - -inline void Splash::updateModY(int y) { - if (y < modYMin) { - modYMin = y; - } - if (y > modYMax) { - modYMax = y; - } -} - -//------------------------------------------------------------------------ -// pipeline -//------------------------------------------------------------------------ - -inline void Splash::pipeInit(SplashPipe *pipe, int x, int y, - SplashPattern *pattern, SplashColorPtr cSrc, - Guchar aInput, GBool usesShape, - GBool nonIsolatedGroup, - GBool knockout, Guchar knockoutOpacity) { - pipeSetXY(pipe, x, y); - pipe->pattern = NULL; - - // source color - if (pattern) { - if (pattern->isStatic()) { - pattern->getColor(x, y, pipe->cSrcVal); - } else { - pipe->pattern = pattern; - } - pipe->cSrc = pipe->cSrcVal; - } else { - pipe->cSrc = cSrc; - } - - // source alpha - pipe->aInput = aInput; - pipe->usesShape = usesShape; - pipe->shape = 0; - - // knockout - pipe->knockout = knockout; - pipe->knockoutOpacity = knockoutOpacity; - - // result alpha - if (aInput == 255 && !state->softMask && !usesShape && - !state->inNonIsolatedGroup && !nonIsolatedGroup) { - pipe->noTransparency = gTrue; - } else { - pipe->noTransparency = gFalse; - } - - // result color - if (pipe->noTransparency) { - // the !state->blendFunc case is handled separately in pipeRun - pipe->resultColorCtrl = pipeResultColorNoAlphaBlend[bitmap->mode]; - } else if (!state->blendFunc) { - pipe->resultColorCtrl = pipeResultColorAlphaNoBlend[bitmap->mode]; - } else { - pipe->resultColorCtrl = pipeResultColorAlphaBlend[bitmap->mode]; - } - - // non-isolated group correction - pipe->nonIsolatedGroup = nonIsolatedGroup; - - // select the 'run' function - pipe->run = &Splash::pipeRun; - if (!pipe->pattern && pipe->noTransparency && !state->blendFunc) { - if (bitmap->mode == splashModeMono1 && !pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunSimpleMono1; - } else if (bitmap->mode == splashModeMono8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunSimpleMono8; - } else if (bitmap->mode == splashModeRGB8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunSimpleRGB8; - } else if (bitmap->mode == splashModeXBGR8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunSimpleXBGR8; - } else if (bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunSimpleBGR8; -#if SPLASH_CMYK - } else if (bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunSimpleCMYK8; - } else if (bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunSimpleDeviceN8; -#endif - } - } else if (!pipe->pattern && !pipe->noTransparency && !state->softMask && - pipe->usesShape && - !(state->inNonIsolatedGroup && alpha0Bitmap->alpha) && - !state->blendFunc && !pipe->nonIsolatedGroup) { - if (bitmap->mode == splashModeMono1 && !pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunAAMono1; - } else if (bitmap->mode == splashModeMono8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunAAMono8; - } else if (bitmap->mode == splashModeRGB8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunAARGB8; - } else if (bitmap->mode == splashModeXBGR8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunAAXBGR8; - } else if (bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunAABGR8; -#if SPLASH_CMYK - } else if (bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunAACMYK8; - } else if (bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr) { - pipe->run = &Splash::pipeRunAADeviceN8; -#endif - } - } -} - -// general case -void Splash::pipeRun(SplashPipe *pipe) { - Guchar aSrc, aDest, alphaI, alphaIm1, alpha0, aResult; - SplashColor cSrcNonIso, cDest, cBlend; - SplashColorPtr cSrc; - Guchar cResult0, cResult1, cResult2, cResult3; - int t; -#if SPLASH_CMYK - int cp, mask; - Guchar cResult[SPOT_NCOMPS+4]; -#endif - - //----- source color - - // static pattern: handled in pipeInit - // fixed color: handled in pipeInit - - // dynamic pattern - if (pipe->pattern) { - if (!pipe->pattern->getColor(pipe->x, pipe->y, pipe->cSrcVal)) { - pipeIncX(pipe); - return; - } -#if SPLASH_CMYK - if (bitmap->mode == splashModeCMYK8 || bitmap->mode == splashModeDeviceN8) { - if (state->fillOverprint && state->overprintMode && pipe->pattern->isCMYK()) { - Guint mask = 15; - if (pipe->cSrcVal[0] == 0) { - mask &= ~1; - } - if (pipe->cSrcVal[1] == 0) { - mask &= ~2; - } - if (pipe->cSrcVal[2] == 0) { - mask &= ~4; - } - if (pipe->cSrcVal[3] == 0) { - mask &= ~8; - } - state->overprintMask = mask; - } - } -#endif - } - - if (pipe->noTransparency && !state->blendFunc) { - - //----- write destination pixel - - switch (bitmap->mode) { - case splashModeMono1: - cResult0 = state->grayTransfer[pipe->cSrc[0]]; - if (state->screen->test(pipe->x, pipe->y, cResult0)) { - *pipe->destColorPtr |= pipe->destColorMask; - } else { - *pipe->destColorPtr &= ~pipe->destColorMask; - } - if (!(pipe->destColorMask >>= 1)) { - pipe->destColorMask = 0x80; - ++pipe->destColorPtr; - } - break; - case splashModeMono8: - *pipe->destColorPtr++ = state->grayTransfer[pipe->cSrc[0]]; - break; - case splashModeRGB8: - *pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]]; - *pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]]; - *pipe->destColorPtr++ = state->rgbTransferB[pipe->cSrc[2]]; - break; - case splashModeXBGR8: - *pipe->destColorPtr++ = state->rgbTransferB[pipe->cSrc[2]]; - *pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]]; - *pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]]; - *pipe->destColorPtr++ = 255; - break; - case splashModeBGR8: - *pipe->destColorPtr++ = state->rgbTransferB[pipe->cSrc[2]]; - *pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]]; - *pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]]; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - if (state->overprintMask & 1) { - pipe->destColorPtr[0] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[0] + state->cmykTransferC[pipe->cSrc[0]], 255) : - state->cmykTransferC[pipe->cSrc[0]]; - } - if (state->overprintMask & 2) { - pipe->destColorPtr[1] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[1] + state->cmykTransferM[pipe->cSrc[1]], 255) : - state->cmykTransferM[pipe->cSrc[1]]; - } - if (state->overprintMask & 4) { - pipe->destColorPtr[2] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[2] + state->cmykTransferY[pipe->cSrc[2]], 255) : - state->cmykTransferY[pipe->cSrc[2]]; - } - if (state->overprintMask & 8) { - pipe->destColorPtr[3] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[3] + state->cmykTransferK[pipe->cSrc[3]], 255) : - state->cmykTransferK[pipe->cSrc[3]]; - } - pipe->destColorPtr += 4; - break; - case splashModeDeviceN8: - mask = 1; - for (cp = 0; cp < SPOT_NCOMPS + 4; cp ++) { - if (state->overprintMask & mask) { - pipe->destColorPtr[cp] = state->deviceNTransfer[cp][pipe->cSrc[cp]]; - } - mask <<= 1; - } - pipe->destColorPtr += (SPOT_NCOMPS+4); - break; -#endif - } - if (pipe->destAlphaPtr) { - *pipe->destAlphaPtr++ = 255; - } - - } else { - - //----- read destination pixel - - Guchar *destColorPtr; - if (pipe->shape && state->blendFunc && pipe->knockout && alpha0Bitmap != NULL) { - destColorPtr = alpha0Bitmap->data + (alpha0Y+pipe->y)*alpha0Bitmap->rowSize; - switch (bitmap->mode) { - case splashModeMono1: - destColorPtr += (alpha0X+pipe->x) / 8; - break; - case splashModeMono8: - destColorPtr += (alpha0X+pipe->x); - break; - case splashModeRGB8: - case splashModeBGR8: - destColorPtr += (alpha0X+pipe->x) * 3; - break; - case splashModeXBGR8: -#if SPLASH_CMYK - case splashModeCMYK8: -#endif - destColorPtr += (alpha0X+pipe->x) * 4; - break; -#if SPLASH_CMYK - case splashModeDeviceN8: - destColorPtr += (alpha0X+pipe->x) * (SPOT_NCOMPS + 4); - break; -#endif - } - } else { - destColorPtr = pipe->destColorPtr; - } - switch (bitmap->mode) { - case splashModeMono1: - cDest[0] = (*destColorPtr & pipe->destColorMask) ? 0xff : 0x00; - break; - case splashModeMono8: - cDest[0] = *destColorPtr; - break; - case splashModeRGB8: - cDest[0] = destColorPtr[0]; - cDest[1] = destColorPtr[1]; - cDest[2] = destColorPtr[2]; - break; - case splashModeXBGR8: - cDest[0] = destColorPtr[2]; - cDest[1] = destColorPtr[1]; - cDest[2] = destColorPtr[0]; - cDest[3] = 255; - break; - case splashModeBGR8: - cDest[0] = destColorPtr[2]; - cDest[1] = destColorPtr[1]; - cDest[2] = destColorPtr[0]; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - cDest[0] = destColorPtr[0]; - cDest[1] = destColorPtr[1]; - cDest[2] = destColorPtr[2]; - cDest[3] = destColorPtr[3]; - break; - case splashModeDeviceN8: - for (cp = 0; cp < SPOT_NCOMPS + 4; cp++) - cDest[cp] = destColorPtr[cp]; - break; -#endif - } - if (pipe->destAlphaPtr) { - aDest = *pipe->destAlphaPtr; - } else { - aDest = 0xff; - } - - //----- source alpha - - if (state->softMask) { - if (pipe->usesShape) { - aSrc = div255(div255(pipe->aInput * *pipe->softMaskPtr++) * - pipe->shape); - } else { - aSrc = div255(pipe->aInput * *pipe->softMaskPtr++); - } - } else if (pipe->usesShape) { - aSrc = div255(pipe->aInput * pipe->shape); - } else { - aSrc = pipe->aInput; - } - - //----- non-isolated group correction - - if (pipe->nonIsolatedGroup) { - // This path is only used when Splash::composite() is called to - // composite a non-isolated group onto the backdrop. In this - // case, pipe->shape is the source (group) alpha. - if (pipe->shape == 0) { - // this value will be multiplied by zero later, so it doesn't - // matter what we use - cSrc = pipe->cSrc; - } else { - t = (aDest * 255) / pipe->shape - aDest; - switch (bitmap->mode) { -#if SPLASH_CMYK - case splashModeDeviceN8: - for (cp = 0; cp < SPOT_NCOMPS + 4; cp++) - cSrcNonIso[cp] = clip255(pipe->cSrc[cp] + - ((pipe->cSrc[cp] - cDest[cp]) * t) / 255); - break; - case splashModeCMYK8: - for (cp = 0; cp < 4; cp++) - cSrcNonIso[cp] = clip255(pipe->cSrc[cp] + - ((pipe->cSrc[cp] - cDest[cp]) * t) / 255); - break; -#endif - case splashModeXBGR8: - cSrcNonIso[3] = 255; - case splashModeRGB8: - case splashModeBGR8: - cSrcNonIso[2] = clip255(pipe->cSrc[2] + - ((pipe->cSrc[2] - cDest[2]) * t) / 255); - cSrcNonIso[1] = clip255(pipe->cSrc[1] + - ((pipe->cSrc[1] - cDest[1]) * t) / 255); - case splashModeMono1: - case splashModeMono8: - cSrcNonIso[0] = clip255(pipe->cSrc[0] + - ((pipe->cSrc[0] - cDest[0]) * t) / 255); - break; - } - cSrc = cSrcNonIso; - // knockout: remove backdrop color - if (pipe->knockout && pipe->shape >= pipe->knockoutOpacity) { - aDest = 0; - } - } - } else { - cSrc = pipe->cSrc; - } - - //----- blend function - - if (state->blendFunc) { -#if SPLASH_CMYK - if (bitmap->mode == splashModeDeviceN8) { - for (int k = 4; k < 4 + SPOT_NCOMPS; k++) { - cBlend[k] = 0; - } - } -#endif - (*state->blendFunc)(cSrc, cDest, cBlend, bitmap->mode); - } - - //----- result alpha and non-isolated group element correction - - if (pipe->noTransparency) { - alphaI = alphaIm1 = aResult = 255; - } else { - aResult = aSrc + aDest - div255(aSrc * aDest); - - // alphaI = alpha_i - // alphaIm1 = alpha_(i-1) - if (pipe->alpha0Ptr) { - alpha0 = *pipe->alpha0Ptr++; - alphaI = aResult + alpha0 - div255(aResult * alpha0); - alphaIm1 = alpha0 + aDest - div255(alpha0 * aDest); - } else { - alphaI = aResult; - alphaIm1 = aDest; - } - } - - //----- result color - - cResult0 = cResult1 = cResult2 = cResult3 = 0; // make gcc happy - - switch (pipe->resultColorCtrl) { - - case splashPipeResultColorNoAlphaBlendMono: - cResult0 = state->grayTransfer[div255((255 - aDest) * cSrc[0] + - aDest * cBlend[0])]; - break; - case splashPipeResultColorNoAlphaBlendRGB: - cResult0 = state->rgbTransferR[div255((255 - aDest) * cSrc[0] + - aDest * cBlend[0])]; - cResult1 = state->rgbTransferG[div255((255 - aDest) * cSrc[1] + - aDest * cBlend[1])]; - cResult2 = state->rgbTransferB[div255((255 - aDest) * cSrc[2] + - aDest * cBlend[2])]; - break; -#if SPLASH_CMYK - case splashPipeResultColorNoAlphaBlendCMYK: - cResult0 = state->cmykTransferC[div255((255 - aDest) * cSrc[0] + - aDest * cBlend[0])]; - cResult1 = state->cmykTransferM[div255((255 - aDest) * cSrc[1] + - aDest * cBlend[1])]; - cResult2 = state->cmykTransferY[div255((255 - aDest) * cSrc[2] + - aDest * cBlend[2])]; - cResult3 = state->cmykTransferK[div255((255 - aDest) * cSrc[3] + - aDest * cBlend[3])]; - break; - case splashPipeResultColorNoAlphaBlendDeviceN: - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - cResult[cp] = state->deviceNTransfer[cp][div255((255 - aDest) * cSrc[cp] + - aDest * cBlend[cp])]; - break; -#endif - - case splashPipeResultColorAlphaNoBlendMono: - if (alphaI == 0) { - cResult0 = 0; - } else { - cResult0 = state->grayTransfer[((alphaI - aSrc) * cDest[0] + - aSrc * cSrc[0]) / alphaI]; - } - break; - case splashPipeResultColorAlphaNoBlendRGB: - if (alphaI == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - } else { - cResult0 = state->rgbTransferR[((alphaI - aSrc) * cDest[0] + - aSrc * cSrc[0]) / alphaI]; - cResult1 = state->rgbTransferG[((alphaI - aSrc) * cDest[1] + - aSrc * cSrc[1]) / alphaI]; - cResult2 = state->rgbTransferB[((alphaI - aSrc) * cDest[2] + - aSrc * cSrc[2]) / alphaI]; - } - break; -#if SPLASH_CMYK - case splashPipeResultColorAlphaNoBlendCMYK: - if (alphaI == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - cResult3 = 0; - } else { - cResult0 = state->cmykTransferC[((alphaI - aSrc) * cDest[0] + - aSrc * cSrc[0]) / alphaI]; - cResult1 = state->cmykTransferM[((alphaI - aSrc) * cDest[1] + - aSrc * cSrc[1]) / alphaI]; - cResult2 = state->cmykTransferY[((alphaI - aSrc) * cDest[2] + - aSrc * cSrc[2]) / alphaI]; - cResult3 = state->cmykTransferK[((alphaI - aSrc) * cDest[3] + - aSrc * cSrc[3]) / alphaI]; - } - break; - case splashPipeResultColorAlphaNoBlendDeviceN: - if (alphaI == 0) { - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - cResult[cp] = 0; - } else { - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - cResult[cp] = state->deviceNTransfer[cp][((alphaI - aSrc) * cDest[cp] + - aSrc * cSrc[cp]) / alphaI]; - } - break; -#endif - - case splashPipeResultColorAlphaBlendMono: - if (alphaI == 0) { - cResult0 = 0; - } else { - cResult0 = state->grayTransfer[((alphaI - aSrc) * cDest[0] + - aSrc * ((255 - alphaIm1) * cSrc[0] + - alphaIm1 * cBlend[0]) / 255) / - alphaI]; - } - break; - case splashPipeResultColorAlphaBlendRGB: - if (alphaI == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - } else { - cResult0 = state->rgbTransferR[((alphaI - aSrc) * cDest[0] + - aSrc * ((255 - alphaIm1) * cSrc[0] + - alphaIm1 * cBlend[0]) / 255) / - alphaI]; - cResult1 = state->rgbTransferG[((alphaI - aSrc) * cDest[1] + - aSrc * ((255 - alphaIm1) * cSrc[1] + - alphaIm1 * cBlend[1]) / 255) / - alphaI]; - cResult2 = state->rgbTransferB[((alphaI - aSrc) * cDest[2] + - aSrc * ((255 - alphaIm1) * cSrc[2] + - alphaIm1 * cBlend[2]) / 255) / - alphaI]; - } - break; -#if SPLASH_CMYK - case splashPipeResultColorAlphaBlendCMYK: - if (alphaI == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - cResult3 = 0; - } else { - cResult0 = state->cmykTransferC[((alphaI - aSrc) * cDest[0] + - aSrc * ((255 - alphaIm1) * cSrc[0] + - alphaIm1 * cBlend[0]) / 255) / - alphaI]; - cResult1 = state->cmykTransferM[((alphaI - aSrc) * cDest[1] + - aSrc * ((255 - alphaIm1) * cSrc[1] + - alphaIm1 * cBlend[1]) / 255) / - alphaI]; - cResult2 = state->cmykTransferY[((alphaI - aSrc) * cDest[2] + - aSrc * ((255 - alphaIm1) * cSrc[2] + - alphaIm1 * cBlend[2]) / 255) / - alphaI]; - cResult3 = state->cmykTransferK[((alphaI - aSrc) * cDest[3] + - aSrc * ((255 - alphaIm1) * cSrc[3] + - alphaIm1 * cBlend[3]) / 255) / - alphaI]; - } - break; - case splashPipeResultColorAlphaBlendDeviceN: - if (alphaI == 0) { - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - cResult[cp] = 0; - } else { - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - cResult[cp] = state->deviceNTransfer[cp][((alphaI - aSrc) * cDest[cp] + - aSrc * ((255 - alphaIm1) * cSrc[cp] + - alphaIm1 * cBlend[cp]) / 255) / - alphaI]; - } - break; -#endif - } - - //----- write destination pixel - - switch (bitmap->mode) { - case splashModeMono1: - if (state->screen->test(pipe->x, pipe->y, cResult0)) { - *pipe->destColorPtr |= pipe->destColorMask; - } else { - *pipe->destColorPtr &= ~pipe->destColorMask; - } - if (!(pipe->destColorMask >>= 1)) { - pipe->destColorMask = 0x80; - ++pipe->destColorPtr; - } - break; - case splashModeMono8: - *pipe->destColorPtr++ = cResult0; - break; - case splashModeRGB8: - *pipe->destColorPtr++ = cResult0; - *pipe->destColorPtr++ = cResult1; - *pipe->destColorPtr++ = cResult2; - break; - case splashModeXBGR8: - *pipe->destColorPtr++ = cResult2; - *pipe->destColorPtr++ = cResult1; - *pipe->destColorPtr++ = cResult0; - *pipe->destColorPtr++ = 255; - break; - case splashModeBGR8: - *pipe->destColorPtr++ = cResult2; - *pipe->destColorPtr++ = cResult1; - *pipe->destColorPtr++ = cResult0; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - if (state->overprintMask & 1) { - pipe->destColorPtr[0] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[0] + cResult0, 255) : - cResult0; - } - if (state->overprintMask & 2) { - pipe->destColorPtr[1] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[1] + cResult1, 255) : - cResult1; - } - if (state->overprintMask & 4) { - pipe->destColorPtr[2] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[2] + cResult2, 255) : - cResult2; - } - if (state->overprintMask & 8) { - pipe->destColorPtr[3] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[3] + cResult3, 255) : - cResult3; - } - pipe->destColorPtr += 4; - break; - case splashModeDeviceN8: - mask = 1; - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) { - if (state->overprintMask & mask) { - pipe->destColorPtr[cp] = cResult[cp]; - } - mask <<=1; - } - pipe->destColorPtr += (SPOT_NCOMPS+4); - break; -#endif - } - if (pipe->destAlphaPtr) { - *pipe->destAlphaPtr++ = aResult; - } - - } - - ++pipe->x; -} - -// special case: -// !pipe->pattern && pipe->noTransparency && !state->blendFunc && -// bitmap->mode == splashModeMono1 && !pipe->destAlphaPtr) { -void Splash::pipeRunSimpleMono1(SplashPipe *pipe) { - Guchar cResult0; - - //----- write destination pixel - cResult0 = state->grayTransfer[pipe->cSrc[0]]; - if (state->screen->test(pipe->x, pipe->y, cResult0)) { - *pipe->destColorPtr |= pipe->destColorMask; - } else { - *pipe->destColorPtr &= ~pipe->destColorMask; - } - if (!(pipe->destColorMask >>= 1)) { - pipe->destColorMask = 0x80; - ++pipe->destColorPtr; - } - - ++pipe->x; -} - -// special case: -// !pipe->pattern && pipe->noTransparency && !state->blendFunc && -// bitmap->mode == splashModeMono8 && pipe->destAlphaPtr) { -void Splash::pipeRunSimpleMono8(SplashPipe *pipe) { - //----- write destination pixel - *pipe->destColorPtr++ = state->grayTransfer[pipe->cSrc[0]]; - *pipe->destAlphaPtr++ = 255; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && pipe->noTransparency && !state->blendFunc && -// bitmap->mode == splashModeRGB8 && pipe->destAlphaPtr) { -void Splash::pipeRunSimpleRGB8(SplashPipe *pipe) { - //----- write destination pixel - *pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]]; - *pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]]; - *pipe->destColorPtr++ = state->rgbTransferB[pipe->cSrc[2]]; - *pipe->destAlphaPtr++ = 255; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && pipe->noTransparency && !state->blendFunc && -// bitmap->mode == splashModeXBGR8 && pipe->destAlphaPtr) { -void Splash::pipeRunSimpleXBGR8(SplashPipe *pipe) { - //----- write destination pixel - *pipe->destColorPtr++ = state->rgbTransferB[pipe->cSrc[2]]; - *pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]]; - *pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]]; - *pipe->destColorPtr++ = 255; - *pipe->destAlphaPtr++ = 255; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && pipe->noTransparency && !state->blendFunc && -// bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr) { -void Splash::pipeRunSimpleBGR8(SplashPipe *pipe) { - //----- write destination pixel - *pipe->destColorPtr++ = state->rgbTransferB[pipe->cSrc[2]]; - *pipe->destColorPtr++ = state->rgbTransferG[pipe->cSrc[1]]; - *pipe->destColorPtr++ = state->rgbTransferR[pipe->cSrc[0]]; - *pipe->destAlphaPtr++ = 255; - - ++pipe->x; -} - -#if SPLASH_CMYK -// special case: -// !pipe->pattern && pipe->noTransparency && !state->blendFunc && -// bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr) { -void Splash::pipeRunSimpleCMYK8(SplashPipe *pipe) { - //----- write destination pixel - if (state->overprintMask & 1) { - pipe->destColorPtr[0] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[0] + state->cmykTransferC[pipe->cSrc[0]], 255) : - state->cmykTransferC[pipe->cSrc[0]]; - } - if (state->overprintMask & 2) { - pipe->destColorPtr[1] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[1] + state->cmykTransferM[pipe->cSrc[1]], 255) : - state->cmykTransferM[pipe->cSrc[1]]; - } - if (state->overprintMask & 4) { - pipe->destColorPtr[2] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[2] + state->cmykTransferY[pipe->cSrc[2]], 255) : - state->cmykTransferY[pipe->cSrc[2]]; - } - if (state->overprintMask & 8) { - pipe->destColorPtr[3] = (state->overprintAdditive) ? - std::min<int>(pipe->destColorPtr[3] + state->cmykTransferK[pipe->cSrc[3]], 255) : - state->cmykTransferK[pipe->cSrc[3]]; - } - pipe->destColorPtr += 4; - *pipe->destAlphaPtr++ = 255; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && pipe->noTransparency && !state->blendFunc && -// bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr) { -void Splash::pipeRunSimpleDeviceN8(SplashPipe *pipe) { - //----- write destination pixel - int mask = 1; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) { - if (state->overprintMask & mask) { - pipe->destColorPtr[cp] = state->deviceNTransfer[cp][pipe->cSrc[cp]]; - } - mask <<=1; - } - pipe->destColorPtr += (SPOT_NCOMPS+4); - *pipe->destAlphaPtr++ = 255; - - ++pipe->x; -} -#endif - -// special case: -// !pipe->pattern && !pipe->noTransparency && !state->softMask && -// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && -// !pipe->nonIsolatedGroup && -// bitmap->mode == splashModeMono1 && !pipe->destAlphaPtr -void Splash::pipeRunAAMono1(SplashPipe *pipe) { - Guchar aSrc; - SplashColor cDest; - Guchar cResult0; - - //----- read destination pixel - cDest[0] = (*pipe->destColorPtr & pipe->destColorMask) ? 0xff : 0x00; - - //----- source alpha - aSrc = div255(pipe->aInput * pipe->shape); - - //----- result color - // note: aDest = alpha2 = aResult = 0xff - cResult0 = state->grayTransfer[(Guchar)div255((0xff - aSrc) * cDest[0] + - aSrc * pipe->cSrc[0])]; - - //----- write destination pixel - if (state->screen->test(pipe->x, pipe->y, cResult0)) { - *pipe->destColorPtr |= pipe->destColorMask; - } else { - *pipe->destColorPtr &= ~pipe->destColorMask; - } - if (!(pipe->destColorMask >>= 1)) { - pipe->destColorMask = 0x80; - ++pipe->destColorPtr; - } - - ++pipe->x; -} - -// special case: -// !pipe->pattern && !pipe->noTransparency && !state->softMask && -// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && -// !pipe->nonIsolatedGroup && -// bitmap->mode == splashModeMono8 && pipe->destAlphaPtr -void Splash::pipeRunAAMono8(SplashPipe *pipe) { - Guchar aSrc, aDest, alpha2, aResult; - SplashColor cDest; - Guchar cResult0; - - //----- read destination pixel - cDest[0] = *pipe->destColorPtr; - aDest = *pipe->destAlphaPtr; - - //----- source alpha - aSrc = div255(pipe->aInput * pipe->shape); - - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - - //----- result color - if (alpha2 == 0) { - cResult0 = 0; - } else { - cResult0 = state->grayTransfer[(Guchar)(((alpha2 - aSrc) * cDest[0] + - aSrc * pipe->cSrc[0]) / alpha2)]; - } - - //----- write destination pixel - *pipe->destColorPtr++ = cResult0; - *pipe->destAlphaPtr++ = aResult; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && !pipe->noTransparency && !state->softMask && -// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && -// !pipe->nonIsolatedGroup && -// bitmap->mode == splashModeRGB8 && pipe->destAlphaPtr -void Splash::pipeRunAARGB8(SplashPipe *pipe) { - Guchar aSrc, aDest, alpha2, aResult; - SplashColor cDest; - Guchar cResult0, cResult1, cResult2; - - //----- read destination pixel - cDest[0] = pipe->destColorPtr[0]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[2]; - aDest = *pipe->destAlphaPtr; - - //----- source alpha - aSrc = div255(pipe->aInput * pipe->shape); - - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - - //----- result color - if (alpha2 == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - } else { - cResult0 = state->rgbTransferR[(Guchar)(((alpha2 - aSrc) * cDest[0] + - aSrc * pipe->cSrc[0]) / alpha2)]; - cResult1 = state->rgbTransferG[(Guchar)(((alpha2 - aSrc) * cDest[1] + - aSrc * pipe->cSrc[1]) / alpha2)]; - cResult2 = state->rgbTransferB[(Guchar)(((alpha2 - aSrc) * cDest[2] + - aSrc * pipe->cSrc[2]) / alpha2)]; - } - - //----- write destination pixel - *pipe->destColorPtr++ = cResult0; - *pipe->destColorPtr++ = cResult1; - *pipe->destColorPtr++ = cResult2; - *pipe->destAlphaPtr++ = aResult; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && !pipe->noTransparency && !state->softMask && -// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && -// !pipe->nonIsolatedGroup && -// bitmap->mode == splashModeXBGR8 && pipe->destAlphaPtr -void Splash::pipeRunAAXBGR8(SplashPipe *pipe) { - Guchar aSrc, aDest, alpha2, aResult; - SplashColor cDest; - Guchar cResult0, cResult1, cResult2; - - //----- read destination pixel - cDest[0] = pipe->destColorPtr[2]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[0]; - aDest = *pipe->destAlphaPtr; - - //----- source alpha - aSrc = div255(pipe->aInput * pipe->shape); - - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - - //----- result color - if (alpha2 == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - } else { - cResult0 = state->rgbTransferR[(Guchar)(((alpha2 - aSrc) * cDest[0] + - aSrc * pipe->cSrc[0]) / alpha2)]; - cResult1 = state->rgbTransferG[(Guchar)(((alpha2 - aSrc) * cDest[1] + - aSrc * pipe->cSrc[1]) / alpha2)]; - cResult2 = state->rgbTransferB[(Guchar)(((alpha2 - aSrc) * cDest[2] + - aSrc * pipe->cSrc[2]) / alpha2)]; - } - - //----- write destination pixel - *pipe->destColorPtr++ = cResult2; - *pipe->destColorPtr++ = cResult1; - *pipe->destColorPtr++ = cResult0; - *pipe->destColorPtr++ = 255; - *pipe->destAlphaPtr++ = aResult; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && !pipe->noTransparency && !state->softMask && -// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && -// !pipe->nonIsolatedGroup && -// bitmap->mode == splashModeBGR8 && pipe->destAlphaPtr -void Splash::pipeRunAABGR8(SplashPipe *pipe) { - Guchar aSrc, aDest, alpha2, aResult; - SplashColor cDest; - Guchar cResult0, cResult1, cResult2; - - //----- read destination pixel - cDest[0] = pipe->destColorPtr[2]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[0]; - aDest = *pipe->destAlphaPtr; - - //----- source alpha - aSrc = div255(pipe->aInput * pipe->shape); - - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - - //----- result color - if (alpha2 == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - } else { - cResult0 = state->rgbTransferR[(Guchar)(((alpha2 - aSrc) * cDest[0] + - aSrc * pipe->cSrc[0]) / alpha2)]; - cResult1 = state->rgbTransferG[(Guchar)(((alpha2 - aSrc) * cDest[1] + - aSrc * pipe->cSrc[1]) / alpha2)]; - cResult2 = state->rgbTransferB[(Guchar)(((alpha2 - aSrc) * cDest[2] + - aSrc * pipe->cSrc[2]) / alpha2)]; - } - - //----- write destination pixel - *pipe->destColorPtr++ = cResult2; - *pipe->destColorPtr++ = cResult1; - *pipe->destColorPtr++ = cResult0; - *pipe->destAlphaPtr++ = aResult; - - ++pipe->x; -} - -#if SPLASH_CMYK -// special case: -// !pipe->pattern && !pipe->noTransparency && !state->softMask && -// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && -// !pipe->nonIsolatedGroup && -// bitmap->mode == splashModeCMYK8 && pipe->destAlphaPtr -void Splash::pipeRunAACMYK8(SplashPipe *pipe) { - Guchar aSrc, aDest, alpha2, aResult; - SplashColor cDest; - Guchar cResult0, cResult1, cResult2, cResult3; - - //----- read destination pixel - cDest[0] = pipe->destColorPtr[0]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[2]; - cDest[3] = pipe->destColorPtr[3]; - aDest = *pipe->destAlphaPtr; - - //----- source alpha - aSrc = div255(pipe->aInput * pipe->shape); - - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - - //----- result color - if (alpha2 == 0) { - cResult0 = 0; - cResult1 = 0; - cResult2 = 0; - cResult3 = 0; - } else { - cResult0 = state->cmykTransferC[(Guchar)(((alpha2 - aSrc) * cDest[0] + - aSrc * pipe->cSrc[0]) / alpha2)]; - cResult1 = state->cmykTransferM[(Guchar)(((alpha2 - aSrc) * cDest[1] + - aSrc * pipe->cSrc[1]) / alpha2)]; - cResult2 = state->cmykTransferY[(Guchar)(((alpha2 - aSrc) * cDest[2] + - aSrc * pipe->cSrc[2]) / alpha2)]; - cResult3 = state->cmykTransferK[(Guchar)(((alpha2 - aSrc) * cDest[3] + - aSrc * pipe->cSrc[3]) / alpha2)]; - } - - //----- write destination pixel - if (state->overprintMask & 1) { - pipe->destColorPtr[0] = (state->overprintAdditive && pipe->shape != 0) ? - std::min<int>(pipe->destColorPtr[0] + cResult0, 255) : - cResult0; - } - if (state->overprintMask & 2) { - pipe->destColorPtr[1] = (state->overprintAdditive && pipe->shape != 0) ? - std::min<int>(pipe->destColorPtr[1] + cResult1, 255) : - cResult1; - } - if (state->overprintMask & 4) { - pipe->destColorPtr[2] = (state->overprintAdditive && pipe->shape != 0) ? - std::min<int>(pipe->destColorPtr[2] + cResult2, 255) : - cResult2; - } - if (state->overprintMask & 8) { - pipe->destColorPtr[3] = (state->overprintAdditive && pipe->shape != 0) ? - std::min<int>(pipe->destColorPtr[3] + cResult3, 255) : - cResult3; - } - pipe->destColorPtr += 4; - *pipe->destAlphaPtr++ = aResult; - - ++pipe->x; -} - -// special case: -// !pipe->pattern && !pipe->noTransparency && !state->softMask && -// pipe->usesShape && !pipe->alpha0Ptr && !state->blendFunc && -// !pipe->nonIsolatedGroup && -// bitmap->mode == splashModeDeviceN8 && pipe->destAlphaPtr -void Splash::pipeRunAADeviceN8(SplashPipe *pipe) { - Guchar aSrc, aDest, alpha2, aResult; - SplashColor cDest; - Guchar cResult[SPOT_NCOMPS+4]; - int cp, mask; - - //----- read destination pixel - for (cp=0; cp < SPOT_NCOMPS+4; cp++) - cDest[cp] = pipe->destColorPtr[cp]; - aDest = *pipe->destAlphaPtr; - - //----- source alpha - aSrc = div255(pipe->aInput * pipe->shape); - - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - - //----- result color - if (alpha2 == 0) { - for (cp=0; cp < SPOT_NCOMPS+4; cp++) - cResult[cp] = 0; - } else { - for (cp=0; cp < SPOT_NCOMPS+4; cp++) - cResult[cp] = state->deviceNTransfer[cp][(Guchar)(((alpha2 - aSrc) * cDest[cp] + - aSrc * pipe->cSrc[cp]) / alpha2)]; - } - - //----- write destination pixel - mask = 1; - for (cp=0; cp < SPOT_NCOMPS+4; cp++) { - if (state->overprintMask & mask) { - pipe->destColorPtr[cp] = cResult[cp]; - } - mask <<= 1; - } - pipe->destColorPtr += (SPOT_NCOMPS+4); - *pipe->destAlphaPtr++ = aResult; - - ++pipe->x; -} -#endif - -inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) { - pipe->x = x; - pipe->y = y; - if (state->softMask) { - pipe->softMaskPtr = - &state->softMask->data[y * state->softMask->rowSize + x]; - } - switch (bitmap->mode) { - case splashModeMono1: - pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + (x >> 3)]; - pipe->destColorMask = 0x80 >> (x & 7); - break; - case splashModeMono8: - pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + x]; - break; - case splashModeRGB8: - case splashModeBGR8: - pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 3 * x]; - break; - case splashModeXBGR8: - pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; - break; - case splashModeDeviceN8: - pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + (SPOT_NCOMPS + 4) * x]; - break; -#endif - } - if (bitmap->alpha) { - pipe->destAlphaPtr = &bitmap->alpha[y * bitmap->width + x]; - } else { - pipe->destAlphaPtr = NULL; - } - if (state->inNonIsolatedGroup && alpha0Bitmap->alpha) { - pipe->alpha0Ptr = - &alpha0Bitmap->alpha[(alpha0Y + y) * alpha0Bitmap->width + - (alpha0X + x)]; - } else { - pipe->alpha0Ptr = NULL; - } -} - -inline void Splash::pipeIncX(SplashPipe *pipe) { - ++pipe->x; - if (state->softMask) { - ++pipe->softMaskPtr; - } - switch (bitmap->mode) { - case splashModeMono1: - if (!(pipe->destColorMask >>= 1)) { - pipe->destColorMask = 0x80; - ++pipe->destColorPtr; - } - break; - case splashModeMono8: - ++pipe->destColorPtr; - break; - case splashModeRGB8: - case splashModeBGR8: - pipe->destColorPtr += 3; - break; - case splashModeXBGR8: - pipe->destColorPtr += 4; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - pipe->destColorPtr += 4; - break; - case splashModeDeviceN8: - pipe->destColorPtr += (SPOT_NCOMPS+4); - break; -#endif - } - if (pipe->destAlphaPtr) { - ++pipe->destAlphaPtr; - } - if (pipe->alpha0Ptr) { - ++pipe->alpha0Ptr; - } -} - -inline void Splash::drawPixel(SplashPipe *pipe, int x, int y, GBool noClip) { - if (unlikely(y < 0)) - return; - - if (noClip || state->clip->test(x, y)) { - pipeSetXY(pipe, x, y); - (this->*pipe->run)(pipe); - updateModX(x); - updateModY(y); - } -} - -inline void Splash::drawAAPixelInit() { - aaBufY = -1; -} - -inline void Splash::drawAAPixel(SplashPipe *pipe, int x, int y) { -#if splashAASize == 4 - static int bitCount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, - 1, 2, 2, 3, 2, 3, 3, 4 }; - int w; -#else - int xx, yy; -#endif - SplashColorPtr p; - int x0, x1, t; - - if (x < 0 || x >= bitmap->width || - y < state->clip->getYMinI() || y > state->clip->getYMaxI()) { - return; - } - - // update aaBuf - if (y != aaBufY) { - memset(aaBuf->getDataPtr(), 0xff, - aaBuf->getRowSize() * aaBuf->getHeight()); - x0 = 0; - x1 = bitmap->width - 1; - state->clip->clipAALine(aaBuf, &x0, &x1, y); - aaBufY = y; - } - - // compute the shape value -#if splashAASize == 4 - p = aaBuf->getDataPtr() + (x >> 1); - w = aaBuf->getRowSize(); - if (x & 1) { - t = bitCount4[*p & 0x0f] + bitCount4[p[w] & 0x0f] + - bitCount4[p[2*w] & 0x0f] + bitCount4[p[3*w] & 0x0f]; - } else { - t = bitCount4[*p >> 4] + bitCount4[p[w] >> 4] + - bitCount4[p[2*w] >> 4] + bitCount4[p[3*w] >> 4]; - } -#else - t = 0; - for (yy = 0; yy < splashAASize; ++yy) { - for (xx = 0; xx < splashAASize; ++xx) { - p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + - ((x * splashAASize + xx) >> 3); - t += (*p >> (7 - ((x * splashAASize + xx) & 7))) & 1; - } - } -#endif - - // draw the pixel - if (t != 0) { - pipeSetXY(pipe, x, y); - pipe->shape = div255(aaGamma[t] * pipe->shape); - (this->*pipe->run)(pipe); - updateModX(x); - updateModY(y); - } -} - -inline void Splash::drawSpan(SplashPipe *pipe, int x0, int x1, int y, - GBool noClip) { - int x; - - if (noClip) { - pipeSetXY(pipe, x0, y); - for (x = x0; x <= x1; ++x) { - (this->*pipe->run)(pipe); - } - updateModX(x0); - updateModX(x1); - updateModY(y); - } else { - if (x0 < state->clip->getXMinI()) { - x0 = state->clip->getXMinI(); - } - if (x1 > state->clip->getXMaxI()) { - x1 = state->clip->getXMaxI(); - } - pipeSetXY(pipe, x0, y); - for (x = x0; x <= x1; ++x) { - if (state->clip->test(x, y)) { - (this->*pipe->run)(pipe); - updateModX(x); - updateModY(y); - } else { - pipeIncX(pipe); - } - } - } -} - -inline void Splash::drawAALine(SplashPipe *pipe, int x0, int x1, int y, GBool adjustLine, Guchar lineOpacity) { -#if splashAASize == 4 - static int bitCount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, - 1, 2, 2, 3, 2, 3, 3, 4 }; - SplashColorPtr p0, p1, p2, p3; - int t; -#else - SplashColorPtr p; - int xx, yy, t; -#endif - int x; - -#if splashAASize == 4 - p0 = aaBuf->getDataPtr() + (x0 >> 1); - p1 = p0 + aaBuf->getRowSize(); - p2 = p1 + aaBuf->getRowSize(); - p3 = p2 + aaBuf->getRowSize(); -#endif - pipeSetXY(pipe, x0, y); - for (x = x0; x <= x1; ++x) { - - // compute the shape value -#if splashAASize == 4 - if (x & 1) { - t = bitCount4[*p0 & 0x0f] + bitCount4[*p1 & 0x0f] + - bitCount4[*p2 & 0x0f] + bitCount4[*p3 & 0x0f]; - ++p0; ++p1; ++p2; ++p3; - } else { - t = bitCount4[*p0 >> 4] + bitCount4[*p1 >> 4] + - bitCount4[*p2 >> 4] + bitCount4[*p3 >> 4]; - } -#else - t = 0; - for (yy = 0; yy < splashAASize; ++yy) { - for (xx = 0; xx < splashAASize; ++xx) { - p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + - ((x * splashAASize + xx) >> 3); - t += (*p >> (7 - ((x * splashAASize + xx) & 7))) & 1; - } - } -#endif - - if (t != 0) { - pipe->shape = (adjustLine) ? div255((int) lineOpacity * (double)aaGamma[t]) : (double)aaGamma[t]; - (this->*pipe->run)(pipe); - updateModX(x); - updateModY(y); - } else { - pipeIncX(pipe); - } - } -} - -//------------------------------------------------------------------------ - -// Transform a point from user space to device space. -inline void Splash::transform(SplashCoord *matrix, - SplashCoord xi, SplashCoord yi, - SplashCoord *xo, SplashCoord *yo) { - // [ m[0] m[1] 0 ] - // [xo yo 1] = [xi yi 1] * [ m[2] m[3] 0 ] - // [ m[4] m[5] 1 ] - *xo = xi * matrix[0] + yi * matrix[2] + matrix[4]; - *yo = xi * matrix[1] + yi * matrix[3] + matrix[5]; -} - -//------------------------------------------------------------------------ -// Splash -//------------------------------------------------------------------------ - -Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, - SplashScreenParams *screenParams) { - int i; - - bitmap = bitmapA; - vectorAntialias = vectorAntialiasA; - inShading = gFalse; - state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, - screenParams); - if (vectorAntialias) { - aaBuf = new SplashBitmap(splashAASize * bitmap->width, splashAASize, - 1, splashModeMono1, gFalse); - for (i = 0; i <= splashAASize * splashAASize; ++i) { - aaGamma[i] = (Guchar)splashRound( - splashPow((SplashCoord)i / - (SplashCoord)(splashAASize * splashAASize), - splashAAGamma) * 255); - } - } else { - aaBuf = NULL; - } - minLineWidth = 0; - thinLineMode = splashThinLineDefault; - clearModRegion(); - debugMode = gFalse; - alpha0Bitmap = NULL; -} - -Splash::Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, - SplashScreen *screenA) { - int i; - - bitmap = bitmapA; - inShading = gFalse; - vectorAntialias = vectorAntialiasA; - state = new SplashState(bitmap->width, bitmap->height, vectorAntialias, - screenA); - if (vectorAntialias) { - aaBuf = new SplashBitmap(splashAASize * bitmap->width, splashAASize, - 1, splashModeMono1, gFalse); - for (i = 0; i <= splashAASize * splashAASize; ++i) { - aaGamma[i] = (Guchar)splashRound( - splashPow((SplashCoord)i / - (SplashCoord)(splashAASize * splashAASize), - splashAAGamma) * 255); - } - } else { - aaBuf = NULL; - } - minLineWidth = 0; - thinLineMode = splashThinLineDefault; - clearModRegion(); - debugMode = gFalse; - alpha0Bitmap = NULL; -} - -Splash::~Splash() { - while (state->next) { - restoreState(); - } - delete state; - delete aaBuf; -} - -//------------------------------------------------------------------------ -// state read -//------------------------------------------------------------------------ - -SplashCoord *Splash::getMatrix() { - return state->matrix; -} - -SplashPattern *Splash::getStrokePattern() { - return state->strokePattern; -} - -SplashPattern *Splash::getFillPattern() { - return state->fillPattern; -} - -SplashScreen *Splash::getScreen() { - return state->screen; -} - -SplashBlendFunc Splash::getBlendFunc() { - return state->blendFunc; -} - -SplashCoord Splash::getStrokeAlpha() { - return state->strokeAlpha; -} - -SplashCoord Splash::getFillAlpha() { - return state->fillAlpha; -} - -SplashCoord Splash::getLineWidth() { - return state->lineWidth; -} - -int Splash::getLineCap() { - return state->lineCap; -} - -int Splash::getLineJoin() { - return state->lineJoin; -} - -SplashCoord Splash::getMiterLimit() { - return state->miterLimit; -} - -SplashCoord Splash::getFlatness() { - return state->flatness; -} - -SplashCoord *Splash::getLineDash() { - return state->lineDash; -} - -int Splash::getLineDashLength() { - return state->lineDashLength; -} - -SplashCoord Splash::getLineDashPhase() { - return state->lineDashPhase; -} - -GBool Splash::getStrokeAdjust() { - return state->strokeAdjust; -} - -SplashClip *Splash::getClip() { - return state->clip; -} - -SplashBitmap *Splash::getSoftMask() { - return state->softMask; -} - -GBool Splash::getInNonIsolatedGroup() { - return state->inNonIsolatedGroup; -} - -//------------------------------------------------------------------------ -// state write -//------------------------------------------------------------------------ - -void Splash::setMatrix(SplashCoord *matrix) { - memcpy(state->matrix, matrix, 6 * sizeof(SplashCoord)); -} - -void Splash::setStrokePattern(SplashPattern *strokePattern) { - state->setStrokePattern(strokePattern); -} - -void Splash::setFillPattern(SplashPattern *fillPattern) { - state->setFillPattern(fillPattern); -} - -void Splash::setScreen(SplashScreen *screen) { - state->setScreen(screen); -} - -void Splash::setBlendFunc(SplashBlendFunc func) { - state->blendFunc = func; -} - -void Splash::setStrokeAlpha(SplashCoord alpha) { - state->strokeAlpha = (state->multiplyPatternAlpha) ? alpha * state->patternStrokeAlpha : alpha; -} - -void Splash::setFillAlpha(SplashCoord alpha) { - state->fillAlpha = (state->multiplyPatternAlpha) ? alpha * state->patternFillAlpha : alpha; -} - -void Splash::setPatternAlpha(SplashCoord strokeAlpha, SplashCoord fillAlpha) { - state->patternStrokeAlpha = strokeAlpha; - state->patternFillAlpha = fillAlpha; - state->multiplyPatternAlpha = gTrue; -} - -void Splash::clearPatternAlpha() { - state->patternStrokeAlpha = 1; - state->patternFillAlpha = 1; - state->multiplyPatternAlpha = gFalse; -} - -void Splash::setFillOverprint(GBool fop) { - state->fillOverprint = fop; -} - -void Splash::setStrokeOverprint(GBool gop) { - state->strokeOverprint = gop; -} - -void Splash::setOverprintMode(int opm) { - state->overprintMode = opm; -} - -void Splash::setLineWidth(SplashCoord lineWidth) { - state->lineWidth = lineWidth; -} - -void Splash::setLineCap(int lineCap) { - state->lineCap = lineCap; -} - -void Splash::setLineJoin(int lineJoin) { - state->lineJoin = lineJoin; -} - -void Splash::setMiterLimit(SplashCoord miterLimit) { - state->miterLimit = miterLimit; -} - -void Splash::setFlatness(SplashCoord flatness) { - if (flatness < 1) { - state->flatness = 1; - } else { - state->flatness = flatness; - } -} - -void Splash::setLineDash(SplashCoord *lineDash, int lineDashLength, - SplashCoord lineDashPhase) { - state->setLineDash(lineDash, lineDashLength, lineDashPhase); -} - -void Splash::setStrokeAdjust(GBool strokeAdjust) { - state->strokeAdjust = strokeAdjust; -} - -void Splash::clipResetToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1) { - state->clip->resetToRect(x0, y0, x1, y1); -} - -SplashError Splash::clipToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1) { - return state->clip->clipToRect(x0, y0, x1, y1); -} - -SplashError Splash::clipToPath(SplashPath *path, GBool eo) { - return state->clip->clipToPath(path, state->matrix, state->flatness, eo); -} - -void Splash::setSoftMask(SplashBitmap *softMask) { - state->setSoftMask(softMask); -} - -void Splash::setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA, - int alpha0XA, int alpha0YA) { - alpha0Bitmap = alpha0BitmapA; - alpha0X = alpha0XA; - alpha0Y = alpha0YA; - state->inNonIsolatedGroup = gTrue; -} - -void Splash::setTransfer(Guchar *red, Guchar *green, Guchar *blue, - Guchar *gray) { - state->setTransfer(red, green, blue, gray); -} - -void Splash::setOverprintMask(Guint overprintMask, GBool additive) { - state->overprintMask = overprintMask; - state->overprintAdditive = additive; -} - -//------------------------------------------------------------------------ -// state save/restore -//------------------------------------------------------------------------ - -void Splash::saveState() { - SplashState *newState; - - newState = state->copy(); - newState->next = state; - state = newState; -} - -SplashError Splash::restoreState() { - SplashState *oldState; - - if (!state->next) { - return splashErrNoSave; - } - oldState = state; - state = state->next; - delete oldState; - return splashOk; -} - -//------------------------------------------------------------------------ -// drawing operations -//------------------------------------------------------------------------ - -void Splash::clear(SplashColorPtr color, Guchar alpha) { - SplashColorPtr row, p; - Guchar mono; - int x, y; - - switch (bitmap->mode) { - case splashModeMono1: - mono = (color[0] & 0x80) ? 0xff : 0x00; - if (bitmap->rowSize < 0) { - memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), - mono, -bitmap->rowSize * bitmap->height); - } else { - memset(bitmap->data, mono, bitmap->rowSize * bitmap->height); - } - break; - case splashModeMono8: - if (bitmap->rowSize < 0) { - memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), - color[0], -bitmap->rowSize * bitmap->height); - } else { - memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); - } - break; - case splashModeRGB8: - if (color[0] == color[1] && color[1] == color[2]) { - if (bitmap->rowSize < 0) { - memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), - color[0], -bitmap->rowSize * bitmap->height); - } else { - memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); - } - } else { - row = bitmap->data; - for (y = 0; y < bitmap->height; ++y) { - p = row; - for (x = 0; x < bitmap->width; ++x) { - *p++ = color[2]; - *p++ = color[1]; - *p++ = color[0]; - } - row += bitmap->rowSize; - } - } - break; - case splashModeXBGR8: - if (color[0] == color[1] && color[1] == color[2]) { - if (bitmap->rowSize < 0) { - memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), - color[0], -bitmap->rowSize * bitmap->height); - } else { - memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); - } - } else { - row = bitmap->data; - for (y = 0; y < bitmap->height; ++y) { - p = row; - for (x = 0; x < bitmap->width; ++x) { - *p++ = color[0]; - *p++ = color[1]; - *p++ = color[2]; - *p++ = 255; - } - row += bitmap->rowSize; - } - } - break; - case splashModeBGR8: - if (color[0] == color[1] && color[1] == color[2]) { - if (bitmap->rowSize < 0) { - memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), - color[0], -bitmap->rowSize * bitmap->height); - } else { - memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); - } - } else { - row = bitmap->data; - for (y = 0; y < bitmap->height; ++y) { - p = row; - for (x = 0; x < bitmap->width; ++x) { - *p++ = color[0]; - *p++ = color[1]; - *p++ = color[2]; - } - row += bitmap->rowSize; - } - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - if (color[0] == color[1] && color[1] == color[2] && color[2] == color[3]) { - if (bitmap->rowSize < 0) { - memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1), - color[0], -bitmap->rowSize * bitmap->height); - } else { - memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height); - } - } else { - row = bitmap->data; - for (y = 0; y < bitmap->height; ++y) { - p = row; - for (x = 0; x < bitmap->width; ++x) { - *p++ = color[0]; - *p++ = color[1]; - *p++ = color[2]; - *p++ = color[3]; - } - row += bitmap->rowSize; - } - } - break; - case splashModeDeviceN8: - row = bitmap->data; - for (y = 0; y < bitmap->height; ++y) { - p = row; - for (x = 0; x < bitmap->width; ++x) { - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *p++ = color[cp]; - } - row += bitmap->rowSize; - } - break; -#endif - } - - if (bitmap->alpha) { - memset(bitmap->alpha, alpha, bitmap->width * bitmap->height); - } - - updateModX(0); - updateModY(0); - updateModX(bitmap->width - 1); - updateModY(bitmap->height - 1); -} - -SplashError Splash::stroke(SplashPath *path) { - SplashPath *path2, *dPath; - SplashCoord d1, d2, t1, t2, w; - - if (debugMode) { - printf("stroke [dash:%d] [width:%.2f]:\n", - state->lineDashLength, (double)state->lineWidth); - dumpPath(path); - } - opClipRes = splashClipAllOutside; - if (path->length == 0) { - return splashErrEmptyPath; - } - path2 = flattenPath(path, state->matrix, state->flatness); - if (state->lineDashLength > 0) { - dPath = makeDashedPath(path2); - delete path2; - path2 = dPath; - if (path2->length == 0) { - delete path2; - return splashErrEmptyPath; - } - } - - // transform a unit square, and take the half the max of the two - // diagonals; the product of this number and the line width is the - // (approximate) transformed line width - t1 = state->matrix[0] + state->matrix[2]; - t2 = state->matrix[1] + state->matrix[3]; - d1 = t1 * t1 + t2 * t2; - t1 = state->matrix[0] - state->matrix[2]; - t2 = state->matrix[1] - state->matrix[3]; - d2 = t1 * t1 + t2 * t2; - if (d2 > d1) { - d1 = d2; - } - d1 *= 0.5; - if (d1 > 0 && - d1 * state->lineWidth * state->lineWidth < minLineWidth * minLineWidth) { - w = minLineWidth / splashSqrt(d1); - strokeWide(path2, w); - } else if (bitmap->mode == splashModeMono1) { - // this gets close to Adobe's behavior in mono mode - if (d1 * state->lineWidth <= 2) { - strokeNarrow(path2); - } else { - strokeWide(path2, state->lineWidth); - } - } else { - if (state->lineWidth == 0) { - strokeNarrow(path2); - } else { - strokeWide(path2, state->lineWidth); - } - } - - delete path2; - return splashOk; -} - -void Splash::strokeNarrow(SplashPath *path) { - SplashPipe pipe; - SplashXPath *xPath; - SplashXPathSeg *seg; - int x0, x1, y0, y1, xa, xb, y; - SplashCoord dxdy; - SplashClipResult clipRes; - int nClipRes[3]; - int i; - - nClipRes[0] = nClipRes[1] = nClipRes[2] = 0; - - xPath = new SplashXPath(path, state->matrix, state->flatness, gFalse); - - pipeInit(&pipe, 0, 0, state->strokePattern, NULL, - (Guchar)splashRound(state->strokeAlpha * 255), - gFalse, gFalse); - - for (i = 0, seg = xPath->segs; i < xPath->length; ++i, ++seg) { - if (seg->y0 <= seg->y1) { - y0 = splashFloor(seg->y0); - y1 = splashFloor(seg->y1); - x0 = splashFloor(seg->x0); - x1 = splashFloor(seg->x1); - } else { - y0 = splashFloor(seg->y1); - y1 = splashFloor(seg->y0); - x0 = splashFloor(seg->x1); - x1 = splashFloor(seg->x0); - } - if ((clipRes = state->clip->testRect(x0 <= x1 ? x0 : x1, y0, - x0 <= x1 ? x1 : x0, y1)) - != splashClipAllOutside) { - if (y0 == y1) { - if (x0 <= x1) { - drawSpan(&pipe, x0, x1, y0, clipRes == splashClipAllInside); - } else { - drawSpan(&pipe, x1, x0, y0, clipRes == splashClipAllInside); - } - } else { - dxdy = seg->dxdy; - if (y0 < state->clip->getYMinI()) { - y0 = state->clip->getYMinI(); - x0 = splashFloor(seg->x0 + ((SplashCoord)y0 - seg->y0) * dxdy); - } - if (y1 > state->clip->getYMaxI()) { - y1 = state->clip->getYMaxI(); - x1 = splashFloor(seg->x0 + ((SplashCoord)y1 - seg->y0) * dxdy); - } - if (x0 <= x1) { - xa = x0; - for (y = y0; y <= y1; ++y) { - if (y < y1) { - xb = splashFloor(seg->x0 + - ((SplashCoord)y + 1 - seg->y0) * dxdy); - } else { - xb = x1 + 1; - } - if (xa == xb) { - drawPixel(&pipe, xa, y, clipRes == splashClipAllInside); - } else { - drawSpan(&pipe, xa, xb - 1, y, clipRes == splashClipAllInside); - } - xa = xb; - } - } else { - xa = x0; - for (y = y0; y <= y1; ++y) { - if (y < y1) { - xb = splashFloor(seg->x0 + - ((SplashCoord)y + 1 - seg->y0) * dxdy); - } else { - xb = x1 - 1; - } - if (xa == xb) { - drawPixel(&pipe, xa, y, clipRes == splashClipAllInside); - } else { - drawSpan(&pipe, xb + 1, xa, y, clipRes == splashClipAllInside); - } - xa = xb; - } - } - } - } - ++nClipRes[clipRes]; - } - if (nClipRes[splashClipPartial] || - (nClipRes[splashClipAllInside] && nClipRes[splashClipAllOutside])) { - opClipRes = splashClipPartial; - } else if (nClipRes[splashClipAllInside]) { - opClipRes = splashClipAllInside; - } else { - opClipRes = splashClipAllOutside; - } - - delete xPath; -} - -void Splash::strokeWide(SplashPath *path, SplashCoord w) { - SplashPath *path2; - - path2 = makeStrokePath(path, w, gFalse); - fillWithPattern(path2, gFalse, state->strokePattern, state->strokeAlpha); - delete path2; -} - -SplashPath *Splash::flattenPath(SplashPath *path, SplashCoord *matrix, - SplashCoord flatness) { - SplashPath *fPath; - SplashCoord flatness2; - Guchar flag; - int i; - - fPath = new SplashPath(); -#if USE_FIXEDPOINT - flatness2 = flatness; -#else - flatness2 = flatness * flatness; -#endif - i = 0; - while (i < path->length) { - flag = path->flags[i]; - if (flag & splashPathFirst) { - fPath->moveTo(path->pts[i].x, path->pts[i].y); - ++i; - } else { - if (flag & splashPathCurve) { - flattenCurve(path->pts[i-1].x, path->pts[i-1].y, - path->pts[i ].x, path->pts[i ].y, - path->pts[i+1].x, path->pts[i+1].y, - path->pts[i+2].x, path->pts[i+2].y, - matrix, flatness2, fPath); - i += 3; - } else { - fPath->lineTo(path->pts[i].x, path->pts[i].y); - ++i; - } - if (path->flags[i-1] & splashPathClosed) { - fPath->close(); - } - } - } - return fPath; -} - -void Splash::flattenCurve(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1, - SplashCoord x2, SplashCoord y2, - SplashCoord x3, SplashCoord y3, - SplashCoord *matrix, SplashCoord flatness2, - SplashPath *fPath) { - SplashCoord cx[splashMaxCurveSplits + 1][3]; - SplashCoord cy[splashMaxCurveSplits + 1][3]; - int cNext[splashMaxCurveSplits + 1]; - SplashCoord xl0, xl1, xl2, xr0, xr1, xr2, xr3, xx1, xx2, xh; - SplashCoord yl0, yl1, yl2, yr0, yr1, yr2, yr3, yy1, yy2, yh; - SplashCoord dx, dy, mx, my, tx, ty, d1, d2; - int p1, p2, p3; - - // initial segment - p1 = 0; - p2 = splashMaxCurveSplits; - cx[p1][0] = x0; cy[p1][0] = y0; - cx[p1][1] = x1; cy[p1][1] = y1; - cx[p1][2] = x2; cy[p1][2] = y2; - cx[p2][0] = x3; cy[p2][0] = y3; - cNext[p1] = p2; - - while (p1 < splashMaxCurveSplits) { - - // get the next segment - xl0 = cx[p1][0]; yl0 = cy[p1][0]; - xx1 = cx[p1][1]; yy1 = cy[p1][1]; - xx2 = cx[p1][2]; yy2 = cy[p1][2]; - p2 = cNext[p1]; - xr3 = cx[p2][0]; yr3 = cy[p2][0]; - - // compute the distances (in device space) from the control points - // to the midpoint of the straight line (this is a bit of a hack, - // but it's much faster than computing the actual distances to the - // line) - transform(matrix, (xl0 + xr3) * 0.5, (yl0 + yr3) * 0.5, &mx, &my); - transform(matrix, xx1, yy1, &tx, &ty); -#if USE_FIXEDPOINT - d1 = splashDist(tx, ty, mx, my); -#else - dx = tx - mx; - dy = ty - my; - d1 = dx*dx + dy*dy; -#endif - transform(matrix, xx2, yy2, &tx, &ty); -#if USE_FIXEDPOINT - d2 = splashDist(tx, ty, mx, my); -#else - dx = tx - mx; - dy = ty - my; - d2 = dx*dx + dy*dy; -#endif - - // if the curve is flat enough, or no more subdivisions are - // allowed, add the straight line segment - if (p2 - p1 == 1 || (d1 <= flatness2 && d2 <= flatness2)) { - fPath->lineTo(xr3, yr3); - p1 = p2; - - // otherwise, subdivide the curve - } else { - xl1 = splashAvg(xl0, xx1); - yl1 = splashAvg(yl0, yy1); - xh = splashAvg(xx1, xx2); - yh = splashAvg(yy1, yy2); - xl2 = splashAvg(xl1, xh); - yl2 = splashAvg(yl1, yh); - xr2 = splashAvg(xx2, xr3); - yr2 = splashAvg(yy2, yr3); - xr1 = splashAvg(xh, xr2); - yr1 = splashAvg(yh, yr2); - xr0 = splashAvg(xl2, xr1); - yr0 = splashAvg(yl2, yr1); - // add the new subdivision points - p3 = (p1 + p2) / 2; - cx[p1][1] = xl1; cy[p1][1] = yl1; - cx[p1][2] = xl2; cy[p1][2] = yl2; - cNext[p1] = p3; - cx[p3][0] = xr0; cy[p3][0] = yr0; - cx[p3][1] = xr1; cy[p3][1] = yr1; - cx[p3][2] = xr2; cy[p3][2] = yr2; - cNext[p3] = p2; - } - } -} - -SplashPath *Splash::makeDashedPath(SplashPath *path) { - SplashPath *dPath; - SplashCoord lineDashTotal; - SplashCoord lineDashStartPhase, lineDashDist, segLen; - SplashCoord x0, y0, x1, y1, xa, ya; - GBool lineDashStartOn, lineDashOn, newPath; - int lineDashStartIdx, lineDashIdx; - int i, j, k; - - lineDashTotal = 0; - for (i = 0; i < state->lineDashLength; ++i) { - lineDashTotal += state->lineDash[i]; - } - // Acrobat simply draws nothing if the dash array is [0] - if (lineDashTotal == 0) { - return new SplashPath(); - } - lineDashStartPhase = state->lineDashPhase; - i = splashFloor(lineDashStartPhase / lineDashTotal); - lineDashStartPhase -= (SplashCoord)i * lineDashTotal; - lineDashStartOn = gTrue; - lineDashStartIdx = 0; - if (lineDashStartPhase > 0) { - while (lineDashStartIdx < state->lineDashLength && lineDashStartPhase >= state->lineDash[lineDashStartIdx]) { - lineDashStartOn = !lineDashStartOn; - lineDashStartPhase -= state->lineDash[lineDashStartIdx]; - ++lineDashStartIdx; - } - if (unlikely(lineDashStartIdx == state->lineDashLength)) { - return new SplashPath(); - } - } - - dPath = new SplashPath(); - - // process each subpath - i = 0; - while (i < path->length) { - - // find the end of the subpath - for (j = i; - j < path->length - 1 && !(path->flags[j] & splashPathLast); - ++j) ; - - // initialize the dash parameters - lineDashOn = lineDashStartOn; - lineDashIdx = lineDashStartIdx; - lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase; - - // process each segment of the subpath - newPath = gTrue; - for (k = i; k < j; ++k) { - - // grab the segment - x0 = path->pts[k].x; - y0 = path->pts[k].y; - x1 = path->pts[k+1].x; - y1 = path->pts[k+1].y; - segLen = splashDist(x0, y0, x1, y1); - - // process the segment - while (segLen > 0) { - - if (lineDashDist >= segLen) { - if (lineDashOn) { - if (newPath) { - dPath->moveTo(x0, y0); - newPath = gFalse; - } - dPath->lineTo(x1, y1); - } - lineDashDist -= segLen; - segLen = 0; - - } else { - xa = x0 + (lineDashDist / segLen) * (x1 - x0); - ya = y0 + (lineDashDist / segLen) * (y1 - y0); - if (lineDashOn) { - if (newPath) { - dPath->moveTo(x0, y0); - newPath = gFalse; - } - dPath->lineTo(xa, ya); - } - x0 = xa; - y0 = ya; - segLen -= lineDashDist; - lineDashDist = 0; - } - - // get the next entry in the dash array - if (lineDashDist <= 0) { - lineDashOn = !lineDashOn; - if (++lineDashIdx == state->lineDashLength) { - lineDashIdx = 0; - } - lineDashDist = state->lineDash[lineDashIdx]; - newPath = gTrue; - } - } - } - i = j + 1; - } - - if (dPath->length == 0) { - GBool allSame = gTrue; - for (int i = 0; allSame && i < path->length - 1; ++i) { - allSame = path->pts[i].x == path->pts[i + 1].x && path->pts[i].y == path->pts[i + 1].y; - } - if (allSame) { - x0 = path->pts[0].x; - y0 = path->pts[0].y; - dPath->moveTo(x0, y0); - dPath->lineTo(x0, y0); - } - } - - return dPath; -} - -SplashError Splash::fill(SplashPath *path, GBool eo) { - if (debugMode) { - printf("fill [eo:%d]:\n", eo); - dumpPath(path); - } - return fillWithPattern(path, eo, state->fillPattern, state->fillAlpha); -} - -inline void Splash::getBBoxFP(SplashPath *path, SplashCoord *xMinA, SplashCoord *yMinA, - SplashCoord *xMaxA, SplashCoord *yMaxA) { - SplashCoord xMinFP, yMinFP, xMaxFP, yMaxFP, tx, ty; - - // make compiler happy: - xMinFP = xMaxFP = yMinFP = yMaxFP = 0; - for (int i = 0; i < path->length; ++i) { - transform(state->matrix, path->pts[i].x, path->pts[i].y, &tx, &ty); - if (i == 0) { - xMinFP = xMaxFP = tx; - yMinFP = yMaxFP = ty; - } else { - if (tx < xMinFP) xMinFP = tx; - if (tx > xMaxFP) xMaxFP = tx; - if (ty < yMinFP) yMinFP = ty; - if (ty > yMaxFP) yMaxFP = ty; - } - } - - *xMinA = xMinFP; - *yMinA = yMinFP; - *xMaxA = xMaxFP; - *yMaxA = yMaxFP; -} - -SplashError Splash::fillWithPattern(SplashPath *path, GBool eo, - SplashPattern *pattern, - SplashCoord alpha) { - SplashPipe pipe; - SplashXPath *xPath; - SplashXPathScanner *scanner; - int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y; - SplashClipResult clipRes, clipRes2; - GBool adjustLine = gFalse; - int linePosI = 0; - - if (path->length == 0) { - return splashErrEmptyPath; - } - if (pathAllOutside(path)) { - opClipRes = splashClipAllOutside; - return splashOk; - } - - // add stroke adjustment hints for filled rectangles -- this only - // applies to paths that consist of a single subpath - // (this appears to match Acrobat's behavior) - if (state->strokeAdjust && !path->hints) { - int n; - n = path->getLength(); - if (n == 4 && - !(path->flags[0] & splashPathClosed) && - !(path->flags[1] & splashPathLast) && - !(path->flags[2] & splashPathLast)) { - path->close(gTrue); - path->addStrokeAdjustHint(0, 2, 0, 4); - path->addStrokeAdjustHint(1, 3, 0, 4); - } else if (n == 5 && - (path->flags[0] & splashPathClosed) && - !(path->flags[1] & splashPathLast) && - !(path->flags[2] & splashPathLast) && - !(path->flags[3] & splashPathLast)) { - path->addStrokeAdjustHint(0, 2, 0, 4); - path->addStrokeAdjustHint(1, 3, 0, 4); - } - } - - if (thinLineMode != splashThinLineDefault) { - if (state->clip->getXMinI() == state->clip->getXMaxI()) { - linePosI = state->clip->getXMinI(); - adjustLine = gTrue; - } else if (state->clip->getXMinI() == state->clip->getXMaxI() - 1) { - adjustLine = gTrue; - linePosI = splashFloor(state->clip->getXMin() + state->lineWidth); - } else if (state->clip->getYMinI() == state->clip->getYMaxI()) { - linePosI = state->clip->getYMinI(); - adjustLine = gTrue; - } else if (state->clip->getYMinI() == state->clip->getYMaxI() - 1) { - adjustLine = gTrue; - linePosI = splashFloor(state->clip->getYMin() + state->lineWidth); - } - } - - xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue, - adjustLine, linePosI); - if (vectorAntialias && !inShading) { - xPath->aaScale(); - } - xPath->sort(); - yMinI = state->clip->getYMinI(); - yMaxI = state->clip->getYMaxI(); - if (vectorAntialias && !inShading) { - yMinI = yMinI * splashAASize; - yMaxI = (yMaxI + 1) * splashAASize - 1; - } - scanner = new SplashXPathScanner(xPath, eo, yMinI, yMaxI); - - // get the min and max x and y values - if (vectorAntialias && !inShading) { - scanner->getBBoxAA(&xMinI, &yMinI, &xMaxI, &yMaxI); - } else { - scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI); - } - - if (eo && (yMinI == yMaxI || xMinI == xMaxI) && thinLineMode != splashThinLineDefault) { - SplashCoord delta, xMinFP, yMinFP, xMaxFP, yMaxFP; - getBBoxFP(path, &xMinFP, &yMinFP, &xMaxFP, &yMaxFP); - delta = (yMinI == yMaxI) ? yMaxFP - yMinFP : xMaxFP - xMinFP; - if (delta < 0.2) { - opClipRes = splashClipAllOutside; - delete scanner; - delete xPath; - return splashOk; - } - } - - // check clipping - if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI)) - != splashClipAllOutside) { - if (scanner->hasPartialClip()) { - clipRes = splashClipPartial; - } - - pipeInit(&pipe, 0, yMinI, pattern, NULL, (Guchar)splashRound(alpha * 255), - vectorAntialias && !inShading, gFalse); - - // draw the spans - if (vectorAntialias && !inShading) { - for (y = yMinI; y <= yMaxI; ++y) { - scanner->renderAALine(aaBuf, &x0, &x1, y, thinLineMode != splashThinLineDefault && xMinI == xMaxI); - if (clipRes != splashClipAllInside) { - state->clip->clipAALine(aaBuf, &x0, &x1, y, thinLineMode != splashThinLineDefault && xMinI == xMaxI); - } - Guchar lineShape = 255; - GBool adjustLine = gFalse; - if (thinLineMode == splashThinLineShape && (xMinI == xMaxI || yMinI == yMaxI)) { - // compute line shape for thin lines: - SplashCoord mx, my, delta; - transform(state->matrix, 0, 0, &mx, &my); - transform(state->matrix, state->lineWidth, 0, &delta, &my); - adjustLine = gTrue; - lineShape = clip255((delta - mx) * 255); - } - drawAALine(&pipe, x0, x1, y, adjustLine, lineShape); - } - } else { - for (y = yMinI; y <= yMaxI; ++y) { - while (scanner->getNextSpan(y, &x0, &x1)) { - if (clipRes == splashClipAllInside) { - drawSpan(&pipe, x0, x1, y, gTrue); - } else { - // limit the x range - if (x0 < state->clip->getXMinI()) { - x0 = state->clip->getXMinI(); - } - if (x1 > state->clip->getXMaxI()) { - x1 = state->clip->getXMaxI(); - } - clipRes2 = state->clip->testSpan(x0, x1, y); - drawSpan(&pipe, x0, x1, y, clipRes2 == splashClipAllInside); - } - } - } - } - } - opClipRes = clipRes; - - delete scanner; - delete xPath; - return splashOk; -} - -GBool Splash::pathAllOutside(SplashPath *path) { - SplashCoord xMin1, yMin1, xMax1, yMax1; - SplashCoord xMin2, yMin2, xMax2, yMax2; - SplashCoord x, y; - int xMinI, yMinI, xMaxI, yMaxI; - int i; - - xMin1 = xMax1 = path->pts[0].x; - yMin1 = yMax1 = path->pts[0].y; - for (i = 1; i < path->length; ++i) { - if (path->pts[i].x < xMin1) { - xMin1 = path->pts[i].x; - } else if (path->pts[i].x > xMax1) { - xMax1 = path->pts[i].x; - } - if (path->pts[i].y < yMin1) { - yMin1 = path->pts[i].y; - } else if (path->pts[i].y > yMax1) { - yMax1 = path->pts[i].y; - } - } - - transform(state->matrix, xMin1, yMin1, &x, &y); - xMin2 = xMax2 = x; - yMin2 = yMax2 = y; - transform(state->matrix, xMin1, yMax1, &x, &y); - if (x < xMin2) { - xMin2 = x; - } else if (x > xMax2) { - xMax2 = x; - } - if (y < yMin2) { - yMin2 = y; - } else if (y > yMax2) { - yMax2 = y; - } - transform(state->matrix, xMax1, yMin1, &x, &y); - if (x < xMin2) { - xMin2 = x; - } else if (x > xMax2) { - xMax2 = x; - } - if (y < yMin2) { - yMin2 = y; - } else if (y > yMax2) { - yMax2 = y; - } - transform(state->matrix, xMax1, yMax1, &x, &y); - if (x < xMin2) { - xMin2 = x; - } else if (x > xMax2) { - xMax2 = x; - } - if (y < yMin2) { - yMin2 = y; - } else if (y > yMax2) { - yMax2 = y; - } - xMinI = splashFloor(xMin2); - yMinI = splashFloor(yMin2); - xMaxI = splashFloor(xMax2); - yMaxI = splashFloor(yMax2); - - return state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI) == - splashClipAllOutside; -} - -SplashError Splash::xorFill(SplashPath *path, GBool eo) { - SplashPipe pipe; - SplashXPath *xPath; - SplashXPathScanner *scanner; - int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y; - SplashClipResult clipRes, clipRes2; - SplashBlendFunc origBlendFunc; - - if (path->length == 0) { - return splashErrEmptyPath; - } - xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue); - xPath->sort(); - scanner = new SplashXPathScanner(xPath, eo, state->clip->getYMinI(), - state->clip->getYMaxI()); - - // get the min and max x and y values - scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI); - - // check clipping - if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI)) - != splashClipAllOutside) { - if (scanner->hasPartialClip()) { - clipRes = splashClipPartial; - } - - origBlendFunc = state->blendFunc; - state->blendFunc = &blendXor; - pipeInit(&pipe, 0, yMinI, state->fillPattern, NULL, 255, gFalse, gFalse); - - // draw the spans - for (y = yMinI; y <= yMaxI; ++y) { - while (scanner->getNextSpan(y, &x0, &x1)) { - if (clipRes == splashClipAllInside) { - drawSpan(&pipe, x0, x1, y, gTrue); - } else { - // limit the x range - if (x0 < state->clip->getXMinI()) { - x0 = state->clip->getXMinI(); - } - if (x1 > state->clip->getXMaxI()) { - x1 = state->clip->getXMaxI(); - } - clipRes2 = state->clip->testSpan(x0, x1, y); - drawSpan(&pipe, x0, x1, y, clipRes2 == splashClipAllInside); - } - } - } - state->blendFunc = origBlendFunc; - } - opClipRes = clipRes; - - delete scanner; - delete xPath; - return splashOk; -} - -SplashError Splash::fillChar(SplashCoord x, SplashCoord y, - int c, SplashFont *font) { - SplashGlyphBitmap glyph; - SplashCoord xt, yt; - int x0, y0, xFrac, yFrac; - SplashClipResult clipRes; - - if (debugMode) { - printf("fillChar: x=%.2f y=%.2f c=%3d=0x%02x='%c'\n", - (double)x, (double)y, c, c, c); - } - transform(state->matrix, x, y, &xt, &yt); - x0 = splashFloor(xt); - xFrac = splashFloor((xt - x0) * splashFontFraction); - y0 = splashFloor(yt); - yFrac = splashFloor((yt - y0) * splashFontFraction); - if (!font->getGlyph(c, xFrac, yFrac, &glyph, x0, y0, state->clip, &clipRes)) { - return splashErrNoGlyph; - } - if (clipRes != splashClipAllOutside) { - fillGlyph2(x0, y0, &glyph, clipRes == splashClipAllInside); - } - opClipRes = clipRes; - if (glyph.freeData) { - gfree(glyph.data); - } - return splashOk; -} - -void Splash::fillGlyph(SplashCoord x, SplashCoord y, - SplashGlyphBitmap *glyph) { - SplashCoord xt, yt; - int x0, y0; - - transform(state->matrix, x, y, &xt, &yt); - x0 = splashFloor(xt); - y0 = splashFloor(yt); - SplashClipResult clipRes = state->clip->testRect(x0 - glyph->x, - y0 - glyph->y, - x0 - glyph->x + glyph->w - 1, - y0 - glyph->y + glyph->h - 1); - if (clipRes != splashClipAllOutside) { - fillGlyph2(x0, y0, glyph, clipRes == splashClipAllInside); - } - opClipRes = clipRes; -} - -void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip) { - SplashPipe pipe; - int alpha0; - Guchar alpha; - Guchar *p; - int x1, y1, xx, xx1, yy; - - p = glyph->data; - int xStart = x0 - glyph->x; - int yStart = y0 - glyph->y; - int xxLimit = glyph->w; - int yyLimit = glyph->h; - int xShift = 0; - - if (yStart < 0) - { - p += (glyph->aa ? glyph->w : splashCeil(glyph->w / 8.0)) * -yStart; // move p to the beginning of the first painted row - yyLimit += yStart; - yStart = 0; - } - - if (xStart < 0) - { - if (glyph->aa) { - p += -xStart; - } else { - p += (-xStart) / 8; - xShift = (-xStart) % 8; - } - xxLimit += xStart; - xStart = 0; - } - - if (xxLimit + xStart >= bitmap->width) xxLimit = bitmap->width - xStart; - if (yyLimit + yStart >= bitmap->height) yyLimit = bitmap->height - yStart; - - if (noClip) { - if (glyph->aa) { - pipeInit(&pipe, xStart, yStart, - state->fillPattern, NULL, (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); - for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { - pipeSetXY(&pipe, xStart, y1); - for (xx = 0, x1 = xStart; xx < xxLimit; ++xx, ++x1) { - alpha = p[xx]; - if (alpha != 0) { - pipe.shape = alpha; - (this->*pipe.run)(&pipe); - updateModX(x1); - updateModY(y1); - } else { - pipeIncX(&pipe); - } - } - p += glyph->w; - } - } else { - const int widthEight = splashCeil(glyph->w / 8.0); - - pipeInit(&pipe, xStart, yStart, - state->fillPattern, NULL, (Guchar)splashRound(state->fillAlpha * 255), gFalse, gFalse); - for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { - pipeSetXY(&pipe, xStart, y1); - for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { - alpha0 = (xShift > 0 ? (p[xx / 8] << xShift) | (p[xx / 8 + 1] >> (8 - xShift)) : p[xx / 8]); - for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { - if (alpha0 & 0x80) { - (this->*pipe.run)(&pipe); - updateModX(x1); - updateModY(y1); - } else { - pipeIncX(&pipe); - } - alpha0 <<= 1; - } - } - p += widthEight; - } - } - } else { - if (glyph->aa) { - pipeInit(&pipe, xStart, yStart, - state->fillPattern, NULL, (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); - for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { - pipeSetXY(&pipe, xStart, y1); - for (xx = 0, x1 = xStart; xx < xxLimit; ++xx, ++x1) { - if (state->clip->test(x1, y1)) { - alpha = p[xx]; - if (alpha != 0) { - pipe.shape = alpha; - (this->*pipe.run)(&pipe); - updateModX(x1); - updateModY(y1); - } else { - pipeIncX(&pipe); - } - } else { - pipeIncX(&pipe); - } - } - p += glyph->w; - } - } else { - const int widthEight = splashCeil(glyph->w / 8.0); - - pipeInit(&pipe, xStart, yStart, - state->fillPattern, NULL, (Guchar)splashRound(state->fillAlpha * 255), gFalse, gFalse); - for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) { - pipeSetXY(&pipe, xStart, y1); - for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) { - alpha0 = (xShift > 0 ? (p[xx / 8] << xShift) | (p[xx / 8 + 1] >> (8 - xShift)) : p[xx / 8]); - for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) { - if (state->clip->test(x1, y1)) { - if (alpha0 & 0x80) { - (this->*pipe.run)(&pipe); - updateModX(x1); - updateModY(y1); - } else { - pipeIncX(&pipe); - } - } else { - pipeIncX(&pipe); - } - alpha0 <<= 1; - } - } - p += widthEight; - } - } - } -} - -SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, - int w, int h, SplashCoord *mat, - GBool glyphMode) { - SplashBitmap *scaledMask; - SplashClipResult clipRes; - GBool minorAxisZero; - int x0, y0, x1, y1, scaledWidth, scaledHeight; - int yp; - - if (debugMode) { - printf("fillImageMask: w=%d h=%d mat=[%.2f %.2f %.2f %.2f %.2f %.2f]\n", - w, h, (double)mat[0], (double)mat[1], (double)mat[2], - (double)mat[3], (double)mat[4], (double)mat[5]); - } - - if (w == 0 && h == 0) return splashErrZeroImage; - - // check for singular matrix - if (!splashCheckDet(mat[0], mat[1], mat[2], mat[3], 0.000001)) { - return splashErrSingularMatrix; - } - - minorAxisZero = mat[1] == 0 && mat[2] == 0; - - // scaling only - if (mat[0] > 0 && minorAxisZero && mat[3] > 0) { - x0 = imgCoordMungeLowerC(mat[4], glyphMode); - y0 = imgCoordMungeLowerC(mat[5], glyphMode); - x1 = imgCoordMungeUpperC(mat[0] + mat[4], glyphMode); - y1 = imgCoordMungeUpperC(mat[3] + mat[5], glyphMode); - // make sure narrow images cover at least one pixel - if (x0 == x1) { - ++x1; - } - if (y0 == y1) { - ++y1; - } - clipRes = state->clip->testRect(x0, y0, x1 - 1, y1 - 1); - opClipRes = clipRes; - if (clipRes != splashClipAllOutside) { - scaledWidth = x1 - x0; - scaledHeight = y1 - y0; - yp = h / scaledHeight; - if (yp < 0 || yp > INT_MAX - 1) { - return splashErrBadArg; - } - scaledMask = scaleMask(src, srcData, w, h, scaledWidth, scaledHeight); - blitMask(scaledMask, x0, y0, clipRes); - delete scaledMask; - } - - // scaling plus vertical flip - } else if (mat[0] > 0 && minorAxisZero && mat[3] < 0) { - x0 = imgCoordMungeLowerC(mat[4], glyphMode); - y0 = imgCoordMungeLowerC(mat[3] + mat[5], glyphMode); - x1 = imgCoordMungeUpperC(mat[0] + mat[4], glyphMode); - y1 = imgCoordMungeUpperC(mat[5], glyphMode); - // make sure narrow images cover at least one pixel - if (x0 == x1) { - ++x1; - } - if (y0 == y1) { - ++y1; - } - clipRes = state->clip->testRect(x0, y0, x1 - 1, y1 - 1); - opClipRes = clipRes; - if (clipRes != splashClipAllOutside) { - scaledWidth = x1 - x0; - scaledHeight = y1 - y0; - yp = h / scaledHeight; - if (yp < 0 || yp > INT_MAX - 1) { - return splashErrBadArg; - } - scaledMask = scaleMask(src, srcData, w, h, scaledWidth, scaledHeight); - vertFlipImage(scaledMask, scaledWidth, scaledHeight, 1); - blitMask(scaledMask, x0, y0, clipRes); - delete scaledMask; - } - - // all other cases - } else { - arbitraryTransformMask(src, srcData, w, h, mat, glyphMode); - } - - return splashOk; -} - -void Splash::arbitraryTransformMask(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - SplashCoord *mat, GBool glyphMode) { - SplashBitmap *scaledMask; - SplashClipResult clipRes, clipRes2; - SplashPipe pipe; - int scaledWidth, scaledHeight, t0, t1; - SplashCoord r00, r01, r10, r11, det, ir00, ir01, ir10, ir11; - SplashCoord vx[4], vy[4]; - int xMin, yMin, xMax, yMax; - ImageSection section[3]; - int nSections; - int y, xa, xb, x, i, xx, yy; - - // compute the four vertices of the target quadrilateral - vx[0] = mat[4]; vy[0] = mat[5]; - vx[1] = mat[2] + mat[4]; vy[1] = mat[3] + mat[5]; - vx[2] = mat[0] + mat[2] + mat[4]; vy[2] = mat[1] + mat[3] + mat[5]; - vx[3] = mat[0] + mat[4]; vy[3] = mat[1] + mat[5]; - - // clipping - xMin = imgCoordMungeLowerC(vx[0], glyphMode); - xMax = imgCoordMungeUpperC(vx[0], glyphMode); - yMin = imgCoordMungeLowerC(vy[0], glyphMode); - yMax = imgCoordMungeUpperC(vy[0], glyphMode); - for (i = 1; i < 4; ++i) { - t0 = imgCoordMungeLowerC(vx[i], glyphMode); - if (t0 < xMin) { - xMin = t0; - } - t0 = imgCoordMungeUpperC(vx[i], glyphMode); - if (t0 > xMax) { - xMax = t0; - } - t1 = imgCoordMungeLowerC(vy[i], glyphMode); - if (t1 < yMin) { - yMin = t1; - } - t1 = imgCoordMungeUpperC(vy[i], glyphMode); - if (t1 > yMax) { - yMax = t1; - } - } - clipRes = state->clip->testRect(xMin, yMin, xMax - 1, yMax - 1); - opClipRes = clipRes; - if (clipRes == splashClipAllOutside) { - return; - } - - // compute the scale factors - if (mat[0] >= 0) { - t0 = imgCoordMungeUpperC(mat[0] + mat[4], glyphMode) - - imgCoordMungeLowerC(mat[4], glyphMode); - } else { - t0 = imgCoordMungeUpperC(mat[4], glyphMode) - - imgCoordMungeLowerC(mat[0] + mat[4], glyphMode); - } - if (mat[1] >= 0) { - t1 = imgCoordMungeUpperC(mat[1] + mat[5], glyphMode) - - imgCoordMungeLowerC(mat[5], glyphMode); - } else { - t1 = imgCoordMungeUpperC(mat[5], glyphMode) - - imgCoordMungeLowerC(mat[1] + mat[5], glyphMode); - } - scaledWidth = t0 > t1 ? t0 : t1; - if (mat[2] >= 0) { - t0 = imgCoordMungeUpperC(mat[2] + mat[4], glyphMode) - - imgCoordMungeLowerC(mat[4], glyphMode); - } else { - t0 = imgCoordMungeUpperC(mat[4], glyphMode) - - imgCoordMungeLowerC(mat[2] + mat[4], glyphMode); - } - if (mat[3] >= 0) { - t1 = imgCoordMungeUpperC(mat[3] + mat[5], glyphMode) - - imgCoordMungeLowerC(mat[5], glyphMode); - } else { - t1 = imgCoordMungeUpperC(mat[5], glyphMode) - - imgCoordMungeLowerC(mat[3] + mat[5], glyphMode); - } - scaledHeight = t0 > t1 ? t0 : t1; - if (scaledWidth == 0) { - scaledWidth = 1; - } - if (scaledHeight == 0) { - scaledHeight = 1; - } - - // compute the inverse transform (after scaling) matrix - r00 = mat[0] / scaledWidth; - r01 = mat[1] / scaledWidth; - r10 = mat[2] / scaledHeight; - r11 = mat[3] / scaledHeight; - det = r00 * r11 - r01 * r10; - if (splashAbs(det) < 1e-6) { - // this should be caught by the singular matrix check in fillImageMask - return; - } - ir00 = r11 / det; - ir01 = -r01 / det; - ir10 = -r10 / det; - ir11 = r00 / det; - - // scale the input image - scaledMask = scaleMask(src, srcData, srcWidth, srcHeight, - scaledWidth, scaledHeight); - if (scaledMask->data == NULL) { - error(errInternal, -1, "scaledMask->data is NULL in Splash::arbitraryTransformMask"); - delete scaledMask; - return; - } - - // construct the three sections - i = (vy[2] <= vy[3]) ? 2 : 3; - if (vy[1] <= vy[i]) { - i = 1; - } - if (vy[0] < vy[i] || (i != 3 && vy[0] == vy[i])) { - i = 0; - } - if (vy[i] == vy[(i+1) & 3]) { - section[0].y0 = imgCoordMungeLowerC(vy[i], glyphMode); - section[0].y1 = imgCoordMungeUpperC(vy[(i+2) & 3], glyphMode) - 1; - if (vx[i] < vx[(i+1) & 3]) { - section[0].ia0 = i; - section[0].ia1 = (i+3) & 3; - section[0].ib0 = (i+1) & 3; - section[0].ib1 = (i+2) & 3; - } else { - section[0].ia0 = (i+1) & 3; - section[0].ia1 = (i+2) & 3; - section[0].ib0 = i; - section[0].ib1 = (i+3) & 3; - } - nSections = 1; - } else { - section[0].y0 = imgCoordMungeLowerC(vy[i], glyphMode); - section[2].y1 = imgCoordMungeUpperC(vy[(i+2) & 3], glyphMode) - 1; - section[0].ia0 = section[0].ib0 = i; - section[2].ia1 = section[2].ib1 = (i+2) & 3; - if (vx[(i+1) & 3] < vx[(i+3) & 3]) { - section[0].ia1 = section[2].ia0 = (i+1) & 3; - section[0].ib1 = section[2].ib0 = (i+3) & 3; - } else { - section[0].ia1 = section[2].ia0 = (i+3) & 3; - section[0].ib1 = section[2].ib0 = (i+1) & 3; - } - if (vy[(i+1) & 3] < vy[(i+3) & 3]) { - section[1].y0 = imgCoordMungeLowerC(vy[(i+1) & 3], glyphMode); - section[2].y0 = imgCoordMungeUpperC(vy[(i+3) & 3], glyphMode); - if (vx[(i+1) & 3] < vx[(i+3) & 3]) { - section[1].ia0 = (i+1) & 3; - section[1].ia1 = (i+2) & 3; - section[1].ib0 = i; - section[1].ib1 = (i+3) & 3; - } else { - section[1].ia0 = i; - section[1].ia1 = (i+3) & 3; - section[1].ib0 = (i+1) & 3; - section[1].ib1 = (i+2) & 3; - } - } else { - section[1].y0 = imgCoordMungeLowerC(vy[(i+3) & 3], glyphMode); - section[2].y0 = imgCoordMungeUpperC(vy[(i+1) & 3], glyphMode); - if (vx[(i+1) & 3] < vx[(i+3) & 3]) { - section[1].ia0 = i; - section[1].ia1 = (i+1) & 3; - section[1].ib0 = (i+3) & 3; - section[1].ib1 = (i+2) & 3; - } else { - section[1].ia0 = (i+3) & 3; - section[1].ia1 = (i+2) & 3; - section[1].ib0 = i; - section[1].ib1 = (i+1) & 3; - } - } - section[0].y1 = section[1].y0 - 1; - section[1].y1 = section[2].y0 - 1; - nSections = 3; - } - for (i = 0; i < nSections; ++i) { - section[i].xa0 = vx[section[i].ia0]; - section[i].ya0 = vy[section[i].ia0]; - section[i].xa1 = vx[section[i].ia1]; - section[i].ya1 = vy[section[i].ia1]; - section[i].xb0 = vx[section[i].ib0]; - section[i].yb0 = vy[section[i].ib0]; - section[i].xb1 = vx[section[i].ib1]; - section[i].yb1 = vy[section[i].ib1]; - section[i].dxdya = (section[i].xa1 - section[i].xa0) / - (section[i].ya1 - section[i].ya0); - section[i].dxdyb = (section[i].xb1 - section[i].xb0) / - (section[i].yb1 - section[i].yb0); - } - - // initialize the pixel pipe - pipeInit(&pipe, 0, 0, state->fillPattern, NULL, - (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); - if (vectorAntialias) { - drawAAPixelInit(); - } - - // make sure narrow images cover at least one pixel - if (nSections == 1) { - if (section[0].y0 == section[0].y1) { - ++section[0].y1; - clipRes = opClipRes = splashClipPartial; - } - } else { - if (section[0].y0 == section[2].y1) { - ++section[1].y1; - clipRes = opClipRes = splashClipPartial; - } - } - - // scan all pixels inside the target region - for (i = 0; i < nSections; ++i) { - for (y = section[i].y0; y <= section[i].y1; ++y) { - xa = imgCoordMungeLowerC(section[i].xa0 + - ((SplashCoord)y + 0.5 - section[i].ya0) * - section[i].dxdya, - glyphMode); - xb = imgCoordMungeUpperC(section[i].xb0 + - ((SplashCoord)y + 0.5 - section[i].yb0) * - section[i].dxdyb, - glyphMode); - if (unlikely(xa < 0)) - xa = 0; - // make sure narrow images cover at least one pixel - if (xa == xb) { - ++xb; - } - if (clipRes != splashClipAllInside) { - clipRes2 = state->clip->testSpan(xa, xb - 1, y); - } else { - clipRes2 = clipRes; - } - for (x = xa; x < xb; ++x) { - // map (x+0.5, y+0.5) back to the scaled image - xx = splashFloor(((SplashCoord)x + 0.5 - mat[4]) * ir00 + - ((SplashCoord)y + 0.5 - mat[5]) * ir10); - yy = splashFloor(((SplashCoord)x + 0.5 - mat[4]) * ir01 + - ((SplashCoord)y + 0.5 - mat[5]) * ir11); - // xx should always be within bounds, but floating point - // inaccuracy can cause problems - if (xx < 0) { - xx = 0; - } else if (xx >= scaledWidth) { - xx = scaledWidth - 1; - } - if (yy < 0) { - yy = 0; - } else if (yy >= scaledHeight) { - yy = scaledHeight - 1; - } - pipe.shape = scaledMask->data[yy * scaledWidth + xx]; - if (vectorAntialias && clipRes2 != splashClipAllInside) { - drawAAPixel(&pipe, x, y); - } else { - drawPixel(&pipe, x, y, clipRes2 == splashClipAllInside); - } - } - } - } - - delete scaledMask; -} - -// Scale an image mask into a SplashBitmap. -SplashBitmap *Splash::scaleMask(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight) { - SplashBitmap *dest; - - dest = new SplashBitmap(scaledWidth, scaledHeight, 1, splashModeMono8, - gFalse); - if (scaledHeight < srcHeight) { - if (scaledWidth < srcWidth) { - scaleMaskYdXd(src, srcData, srcWidth, srcHeight, - scaledWidth, scaledHeight, dest); - } else { - scaleMaskYdXu(src, srcData, srcWidth, srcHeight, - scaledWidth, scaledHeight, dest); - } - } else { - if (scaledWidth < srcWidth) { - scaleMaskYuXd(src, srcData, srcWidth, srcHeight, - scaledWidth, scaledHeight, dest); - } else { - scaleMaskYuXu(src, srcData, srcWidth, srcHeight, - scaledWidth, scaledHeight, dest); - } - } - return dest; -} - -void Splash::scaleMaskYdXd(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf; - Guint *pixBuf; - Guint pix; - Guchar *destPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx, d, d0, d1; - int i, j; - - // Bresenham parameters for y scale - yp = srcHeight / scaledHeight; - yq = srcHeight % scaledHeight; - - // Bresenham parameters for x scale - xp = srcWidth / scaledWidth; - xq = srcWidth % scaledWidth; - - // allocate buffers - lineBuf = (Guchar *)gmalloc(srcWidth); - pixBuf = (Guint *)gmallocn(srcWidth, sizeof(int)); - - // init y scale Bresenham - yt = 0; - - destPtr = dest->data; - for (y = 0; y < scaledHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= scaledHeight) { - yt -= scaledHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read rows from image - memset(pixBuf, 0, srcWidth * sizeof(int)); - for (i = 0; i < yStep; ++i) { - (*src)(srcData, lineBuf); - for (j = 0; j < srcWidth; ++j) { - pixBuf[j] += lineBuf[j]; - } - } - - // init x scale Bresenham - xt = 0; - d0 = (255 << 23) / (yStep * xp); - d1 = (255 << 23) / (yStep * (xp + 1)); - - xx = 0; - for (x = 0; x < scaledWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= scaledWidth) { - xt -= scaledWidth; - xStep = xp + 1; - d = d1; - } else { - xStep = xp; - d = d0; - } - - // compute the final pixel - pix = 0; - for (i = 0; i < xStep; ++i) { - pix += pixBuf[xx++]; - } - // (255 * pix) / xStep * yStep - pix = (pix * d) >> 23; - - // store the pixel - *destPtr++ = (Guchar)pix; - } - } - - gfree(pixBuf); - gfree(lineBuf); -} - -void Splash::scaleMaskYdXu(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf; - Guint *pixBuf; - Guint pix; - Guchar *destPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, d; - int i, j; - - destPtr = dest->data; - if (destPtr == NULL) { - error(errInternal, -1, "dest->data is NULL in Splash::scaleMaskYdXu"); - return; - } - - // Bresenham parameters for y scale - yp = srcHeight / scaledHeight; - yq = srcHeight % scaledHeight; - - // Bresenham parameters for x scale - xp = scaledWidth / srcWidth; - xq = scaledWidth % srcWidth; - - // allocate buffers - lineBuf = (Guchar *)gmalloc(srcWidth); - pixBuf = (Guint *)gmallocn(srcWidth, sizeof(int)); - - // init y scale Bresenham - yt = 0; - - for (y = 0; y < scaledHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= scaledHeight) { - yt -= scaledHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read rows from image - memset(pixBuf, 0, srcWidth * sizeof(int)); - for (i = 0; i < yStep; ++i) { - (*src)(srcData, lineBuf); - for (j = 0; j < srcWidth; ++j) { - pixBuf[j] += lineBuf[j]; - } - } - - // init x scale Bresenham - xt = 0; - d = (255 << 23) / yStep; - - for (x = 0; x < srcWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= srcWidth) { - xt -= srcWidth; - xStep = xp + 1; - } else { - xStep = xp; - } - - // compute the final pixel - pix = pixBuf[x]; - // (255 * pix) / yStep - pix = (pix * d) >> 23; - - // store the pixel - for (i = 0; i < xStep; ++i) { - *destPtr++ = (Guchar)pix; - } - } - } - - gfree(pixBuf); - gfree(lineBuf); -} - -void Splash::scaleMaskYuXd(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf; - Guint pix; - Guchar *destPtr0, *destPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx, d, d0, d1; - int i; - - destPtr0 = dest->data; - if (destPtr0 == NULL) { - error(errInternal, -1, "dest->data is NULL in Splash::scaleMaskYuXd"); - return; - } - - // Bresenham parameters for y scale - yp = scaledHeight / srcHeight; - yq = scaledHeight % srcHeight; - - // Bresenham parameters for x scale - xp = srcWidth / scaledWidth; - xq = srcWidth % scaledWidth; - - // allocate buffers - lineBuf = (Guchar *)gmalloc(srcWidth); - - // init y scale Bresenham - yt = 0; - - for (y = 0; y < srcHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= srcHeight) { - yt -= srcHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read row from image - (*src)(srcData, lineBuf); - - // init x scale Bresenham - xt = 0; - d0 = (255 << 23) / xp; - d1 = (255 << 23) / (xp + 1); - - xx = 0; - for (x = 0; x < scaledWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= scaledWidth) { - xt -= scaledWidth; - xStep = xp + 1; - d = d1; - } else { - xStep = xp; - d = d0; - } - - // compute the final pixel - pix = 0; - for (i = 0; i < xStep; ++i) { - pix += lineBuf[xx++]; - } - // (255 * pix) / xStep - pix = (pix * d) >> 23; - - // store the pixel - for (i = 0; i < yStep; ++i) { - destPtr = destPtr0 + i * scaledWidth + x; - *destPtr = (Guchar)pix; - } - } - - destPtr0 += yStep * scaledWidth; - } - - gfree(lineBuf); -} - -void Splash::scaleMaskYuXu(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf; - Guint pix; - Guchar *destPtr0, *destPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx; - int i, j; - - destPtr0 = dest->data; - if (destPtr0 == NULL) { - error(errInternal, -1, "dest->data is NULL in Splash::scaleMaskYuXu"); - return; - } - - // Bresenham parameters for y scale - yp = scaledHeight / srcHeight; - yq = scaledHeight % srcHeight; - - // Bresenham parameters for x scale - xp = scaledWidth / srcWidth; - xq = scaledWidth % srcWidth; - - // allocate buffers - lineBuf = (Guchar *)gmalloc(srcWidth); - - // init y scale Bresenham - yt = 0; - - for (y = 0; y < srcHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= srcHeight) { - yt -= srcHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read row from image - (*src)(srcData, lineBuf); - - // init x scale Bresenham - xt = 0; - - xx = 0; - for (x = 0; x < srcWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= srcWidth) { - xt -= srcWidth; - xStep = xp + 1; - } else { - xStep = xp; - } - - // compute the final pixel - pix = lineBuf[x] ? 255 : 0; - - // store the pixel - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destPtr = destPtr0 + i * scaledWidth + xx + j; - *destPtr++ = (Guchar)pix; - } - } - - xx += xStep; - } - - destPtr0 += yStep * scaledWidth; - } - - gfree(lineBuf); -} - -void Splash::blitMask(SplashBitmap *src, int xDest, int yDest, - SplashClipResult clipRes) { - SplashPipe pipe; - Guchar *p; - int w, h, x, y; - - w = src->getWidth(); - h = src->getHeight(); - p = src->getDataPtr(); - if (p == NULL) { - error(errInternal, -1, "src->getDataPtr() is NULL in Splash::blitMask"); - return; - } - if (vectorAntialias && clipRes != splashClipAllInside) { - pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, - (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); - drawAAPixelInit(); - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - pipe.shape = *p++; - drawAAPixel(&pipe, xDest + x, yDest + y); - } - } - } else { - pipeInit(&pipe, xDest, yDest, state->fillPattern, NULL, - (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); - if (clipRes == splashClipAllInside) { - for (y = 0; y < h; ++y) { - pipeSetXY(&pipe, xDest, yDest + y); - for (x = 0; x < w; ++x) { - if (*p) { - pipe.shape = *p; - (this->*pipe.run)(&pipe); - } else { - pipeIncX(&pipe); - } - ++p; - } - } - updateModX(xDest); - updateModX(xDest + w - 1); - updateModY(yDest); - updateModY(yDest + h - 1); - } else { - for (y = 0; y < h; ++y) { - pipeSetXY(&pipe, xDest, yDest + y); - for (x = 0; x < w; ++x) { - if (*p && state->clip->test(xDest + x, yDest + y)) { - pipe.shape = *p; - (this->*pipe.run)(&pipe); - updateModX(xDest + x); - updateModY(yDest + y); - } else { - pipeIncX(&pipe); - } - ++p; - } - } - } - } -} - -SplashError Splash::drawImage(SplashImageSource src, SplashICCTransform tf, void *srcData, - SplashColorMode srcMode, GBool srcAlpha, - int w, int h, SplashCoord *mat, GBool interpolate, - GBool tilingPattern) { - GBool ok; - SplashBitmap *scaledImg; - SplashClipResult clipRes; - GBool minorAxisZero; - int x0, y0, x1, y1, scaledWidth, scaledHeight; - int nComps; - int yp; - - if (debugMode) { - printf("drawImage: srcMode=%d srcAlpha=%d w=%d h=%d mat=[%.2f %.2f %.2f %.2f %.2f %.2f]\n", - srcMode, srcAlpha, w, h, (double)mat[0], (double)mat[1], (double)mat[2], - (double)mat[3], (double)mat[4], (double)mat[5]); - } - - // check color modes - ok = gFalse; // make gcc happy - nComps = 0; // make gcc happy - switch (bitmap->mode) { - case splashModeMono1: - case splashModeMono8: - ok = srcMode == splashModeMono8; - nComps = 1; - break; - case splashModeRGB8: - ok = srcMode == splashModeRGB8; - nComps = 3; - break; - case splashModeXBGR8: - ok = srcMode == splashModeXBGR8; - nComps = 4; - break; - case splashModeBGR8: - ok = srcMode == splashModeBGR8; - nComps = 3; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - ok = srcMode == splashModeCMYK8; - nComps = 4; - break; - case splashModeDeviceN8: - ok = srcMode == splashModeDeviceN8; - nComps = SPOT_NCOMPS+4; - break; -#endif - default: - ok = gFalse; - break; - } - if (!ok) { - return splashErrModeMismatch; - } - - // check for singular matrix - if (!splashCheckDet(mat[0], mat[1], mat[2], mat[3], 0.000001)) { - return splashErrSingularMatrix; - } - - minorAxisZero = mat[1] == 0 && mat[2] == 0; - - // scaling only - if (mat[0] > 0 && minorAxisZero && mat[3] > 0) { - x0 = imgCoordMungeLower(mat[4]); - y0 = imgCoordMungeLower(mat[5]); - x1 = imgCoordMungeUpper(mat[0] + mat[4]); - y1 = imgCoordMungeUpper(mat[3] + mat[5]); - // make sure narrow images cover at least one pixel - if (x0 == x1) { - ++x1; - } - if (y0 == y1) { - ++y1; - } - clipRes = state->clip->testRect(x0, y0, x1 - 1, y1 - 1); - opClipRes = clipRes; - if (clipRes != splashClipAllOutside) { - scaledWidth = x1 - x0; - scaledHeight = y1 - y0; - yp = h / scaledHeight; - if (yp < 0 || yp > INT_MAX - 1) { - return splashErrBadArg; - } - scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h, - scaledWidth, scaledHeight, interpolate, tilingPattern); - if (scaledImg == NULL) { - return splashErrBadArg; - } - if (tf != NULL) { - (*tf)(srcData, scaledImg); - } - blitImage(scaledImg, srcAlpha, x0, y0, clipRes); - delete scaledImg; - } - - // scaling plus vertical flip - } else if (mat[0] > 0 && minorAxisZero && mat[3] < 0) { - x0 = imgCoordMungeLower(mat[4]); - y0 = imgCoordMungeLower(mat[3] + mat[5]); - x1 = imgCoordMungeUpper(mat[0] + mat[4]); - y1 = imgCoordMungeUpper(mat[5]); - if (x0 == x1) { - if (mat[4] + mat[0] * 0.5 < x0) { - --x0; - } else { - ++x1; - } - } - if (y0 == y1) { - if (mat[5] + mat[1] * 0.5 < y0) { - --y0; - } else { - ++y1; - } - } - clipRes = state->clip->testRect(x0, y0, x1 - 1, y1 - 1); - opClipRes = clipRes; - if (clipRes != splashClipAllOutside) { - scaledWidth = x1 - x0; - scaledHeight = y1 - y0; - yp = h / scaledHeight; - if (yp < 0 || yp > INT_MAX - 1) { - return splashErrBadArg; - } - scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h, - scaledWidth, scaledHeight, interpolate, tilingPattern); - if (scaledImg == NULL) { - return splashErrBadArg; - } - if (tf != NULL) { - (*tf)(srcData, scaledImg); - } - vertFlipImage(scaledImg, scaledWidth, scaledHeight, nComps); - blitImage(scaledImg, srcAlpha, x0, y0, clipRes); - delete scaledImg; - } - - // all other cases - } else { - return arbitraryTransformImage(src, tf, srcData, srcMode, nComps, srcAlpha, - w, h, mat, interpolate, tilingPattern); - } - - return splashOk; -} - -SplashError Splash::arbitraryTransformImage(SplashImageSource src, SplashICCTransform tf, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, - int srcWidth, int srcHeight, - SplashCoord *mat, GBool interpolate, - GBool tilingPattern) { - SplashBitmap *scaledImg; - SplashClipResult clipRes, clipRes2; - SplashPipe pipe; - SplashColor pixel; - int scaledWidth, scaledHeight, t0, t1, th; - SplashCoord r00, r01, r10, r11, det, ir00, ir01, ir10, ir11; - SplashCoord vx[4], vy[4]; - int xMin, yMin, xMax, yMax; - ImageSection section[3]; - int nSections; - int y, xa, xb, x, i, xx, yy, yp; - - // compute the four vertices of the target quadrilateral - vx[0] = mat[4]; vy[0] = mat[5]; - vx[1] = mat[2] + mat[4]; vy[1] = mat[3] + mat[5]; - vx[2] = mat[0] + mat[2] + mat[4]; vy[2] = mat[1] + mat[3] + mat[5]; - vx[3] = mat[0] + mat[4]; vy[3] = mat[1] + mat[5]; - - // clipping - xMin = imgCoordMungeLower(vx[0]); - xMax = imgCoordMungeUpper(vx[0]); - yMin = imgCoordMungeLower(vy[0]); - yMax = imgCoordMungeUpper(vy[0]); - for (i = 1; i < 4; ++i) { - t0 = imgCoordMungeLower(vx[i]); - if (t0 < xMin) { - xMin = t0; - } - t0 = imgCoordMungeUpper(vx[i]); - if (t0 > xMax) { - xMax = t0; - } - t1 = imgCoordMungeLower(vy[i]); - if (t1 < yMin) { - yMin = t1; - } - t1 = imgCoordMungeUpper(vy[i]); - if (t1 > yMax) { - yMax = t1; - } - } - clipRes = state->clip->testRect(xMin, yMin, xMax, yMax); - opClipRes = clipRes; - if (clipRes == splashClipAllOutside) { - return splashOk; - } - - // compute the scale factors - if (splashAbs(mat[0]) >= splashAbs(mat[1])) { - scaledWidth = xMax - xMin; - scaledHeight = yMax - yMin; - } else { - scaledWidth = yMax - yMin; - scaledHeight = xMax - xMin; - } - if (scaledHeight <= 1 || scaledWidth <= 1 || tilingPattern) { - if (mat[0] >= 0) { - t0 = imgCoordMungeUpper(mat[0] + mat[4]) - imgCoordMungeLower(mat[4]); - } else { - t0 = imgCoordMungeUpper(mat[4]) - imgCoordMungeLower(mat[0] + mat[4]); - } - if (mat[1] >= 0) { - t1 = imgCoordMungeUpper(mat[1] + mat[5]) - imgCoordMungeLower(mat[5]); - } else { - t1 = imgCoordMungeUpper(mat[5]) - imgCoordMungeLower(mat[1] + mat[5]); - } - scaledWidth = t0 > t1 ? t0 : t1; - if (mat[2] >= 0) { - t0 = imgCoordMungeUpper(mat[2] + mat[4]) - imgCoordMungeLower(mat[4]); - if (splashAbs(mat[1]) >= 1) { - th = imgCoordMungeUpper(mat[2]) - imgCoordMungeLower(mat[0] * mat[3] / mat[1]); - if (th > t0) t0 = th; - } - } else { - t0 = imgCoordMungeUpper(mat[4]) - imgCoordMungeLower(mat[2] + mat[4]); - if (splashAbs(mat[1]) >= 1) { - th = imgCoordMungeUpper(mat[0] * mat[3] / mat[1]) - imgCoordMungeLower(mat[2]); - if (th > t0) t0 = th; - } - } - if (mat[3] >= 0) { - t1 = imgCoordMungeUpper(mat[3] + mat[5]) - imgCoordMungeLower(mat[5]); - if (splashAbs(mat[0]) >= 1) { - th = imgCoordMungeUpper(mat[3]) - imgCoordMungeLower(mat[1] * mat[2] / mat[0]); - if (th > t1) t1 = th; - } - } else { - t1 = imgCoordMungeUpper(mat[5]) - imgCoordMungeLower(mat[3] + mat[5]); - if (splashAbs(mat[0]) >= 1) { - th = imgCoordMungeUpper(mat[1] * mat[2] / mat[0]) - imgCoordMungeLower(mat[3]); - if (th > t1) t1 = th; - } - } - scaledHeight = t0 > t1 ? t0 : t1; - } - if (scaledWidth == 0) { - scaledWidth = 1; - } - if (scaledHeight == 0) { - scaledHeight = 1; - } - - // compute the inverse transform (after scaling) matrix - r00 = mat[0] / scaledWidth; - r01 = mat[1] / scaledWidth; - r10 = mat[2] / scaledHeight; - r11 = mat[3] / scaledHeight; - det = r00 * r11 - r01 * r10; - if (splashAbs(det) < 1e-6) { - // this should be caught by the singular matrix check in drawImage - return splashErrBadArg; - } - ir00 = r11 / det; - ir01 = -r01 / det; - ir10 = -r10 / det; - ir11 = r00 / det; - - // scale the input image - yp = srcHeight / scaledHeight; - if (yp < 0 || yp > INT_MAX - 1) { - return splashErrBadArg; - } - scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, - srcWidth, srcHeight, scaledWidth, scaledHeight, interpolate); - - if (scaledImg == NULL) { - return splashErrBadArg; - } - - if (tf != NULL) { - (*tf)(srcData, scaledImg); - } - // construct the three sections - i = 0; - if (vy[1] < vy[i]) { - i = 1; - } - if (vy[2] < vy[i]) { - i = 2; - } - if (vy[3] < vy[i]) { - i = 3; - } - // NB: if using fixed point, 0.000001 will be truncated to zero, - // so these two comparisons must be <=, not < - if (splashAbs(vy[i] - vy[(i-1) & 3]) <= 0.000001 && - vy[(i-1) & 3] < vy[(i+1) & 3]) { - i = (i-1) & 3; - } - if (splashAbs(vy[i] - vy[(i+1) & 3]) <= 0.000001) { - section[0].y0 = imgCoordMungeLower(vy[i]); - section[0].y1 = imgCoordMungeUpper(vy[(i+2) & 3]) - 1; - if (vx[i] < vx[(i+1) & 3]) { - section[0].ia0 = i; - section[0].ia1 = (i+3) & 3; - section[0].ib0 = (i+1) & 3; - section[0].ib1 = (i+2) & 3; - } else { - section[0].ia0 = (i+1) & 3; - section[0].ia1 = (i+2) & 3; - section[0].ib0 = i; - section[0].ib1 = (i+3) & 3; - } - nSections = 1; - } else { - section[0].y0 = imgCoordMungeLower(vy[i]); - section[2].y1 = imgCoordMungeUpper(vy[(i+2) & 3]) - 1; - section[0].ia0 = section[0].ib0 = i; - section[2].ia1 = section[2].ib1 = (i+2) & 3; - if (vx[(i+1) & 3] < vx[(i+3) & 3]) { - section[0].ia1 = section[2].ia0 = (i+1) & 3; - section[0].ib1 = section[2].ib0 = (i+3) & 3; - } else { - section[0].ia1 = section[2].ia0 = (i+3) & 3; - section[0].ib1 = section[2].ib0 = (i+1) & 3; - } - if (vy[(i+1) & 3] < vy[(i+3) & 3]) { - section[1].y0 = imgCoordMungeLower(vy[(i+1) & 3]); - section[2].y0 = imgCoordMungeUpper(vy[(i+3) & 3]); - if (vx[(i+1) & 3] < vx[(i+3) & 3]) { - section[1].ia0 = (i+1) & 3; - section[1].ia1 = (i+2) & 3; - section[1].ib0 = i; - section[1].ib1 = (i+3) & 3; - } else { - section[1].ia0 = i; - section[1].ia1 = (i+3) & 3; - section[1].ib0 = (i+1) & 3; - section[1].ib1 = (i+2) & 3; - } - } else { - section[1].y0 = imgCoordMungeLower(vy[(i+3) & 3]); - section[2].y0 = imgCoordMungeUpper(vy[(i+1) & 3]); - if (vx[(i+1) & 3] < vx[(i+3) & 3]) { - section[1].ia0 = i; - section[1].ia1 = (i+1) & 3; - section[1].ib0 = (i+3) & 3; - section[1].ib1 = (i+2) & 3; - } else { - section[1].ia0 = (i+3) & 3; - section[1].ia1 = (i+2) & 3; - section[1].ib0 = i; - section[1].ib1 = (i+1) & 3; - } - } - section[0].y1 = section[1].y0 - 1; - section[1].y1 = section[2].y0 - 1; - nSections = 3; - } - for (i = 0; i < nSections; ++i) { - section[i].xa0 = vx[section[i].ia0]; - section[i].ya0 = vy[section[i].ia0]; - section[i].xa1 = vx[section[i].ia1]; - section[i].ya1 = vy[section[i].ia1]; - section[i].xb0 = vx[section[i].ib0]; - section[i].yb0 = vy[section[i].ib0]; - section[i].xb1 = vx[section[i].ib1]; - section[i].yb1 = vy[section[i].ib1]; - section[i].dxdya = (section[i].xa1 - section[i].xa0) / - (section[i].ya1 - section[i].ya0); - section[i].dxdyb = (section[i].xb1 - section[i].xb0) / - (section[i].yb1 - section[i].yb0); - } - - // initialize the pixel pipe - pipeInit(&pipe, 0, 0, NULL, pixel, - (Guchar)splashRound(state->fillAlpha * 255), - srcAlpha || (vectorAntialias && clipRes != splashClipAllInside), - gFalse); - if (vectorAntialias) { - drawAAPixelInit(); - } - - // make sure narrow images cover at least one pixel - if (nSections == 1) { - if (section[0].y0 == section[0].y1) { - ++section[0].y1; - clipRes = opClipRes = splashClipPartial; - } - } else { - if (section[0].y0 == section[2].y1) { - ++section[1].y1; - clipRes = opClipRes = splashClipPartial; - } - } - - // scan all pixels inside the target region - for (i = 0; i < nSections; ++i) { - for (y = section[i].y0; y <= section[i].y1; ++y) { - xa = imgCoordMungeLower(section[i].xa0 + - ((SplashCoord)y + 0.5 - section[i].ya0) * - section[i].dxdya); - if (unlikely(xa < 0)) - xa = 0; - xb = imgCoordMungeUpper(section[i].xb0 + - ((SplashCoord)y + 0.5 - section[i].yb0) * - section[i].dxdyb); - // make sure narrow images cover at least one pixel - if (xa == xb) { - ++xb; - } - if (clipRes != splashClipAllInside) { - clipRes2 = state->clip->testSpan(xa, xb - 1, y); - } else { - clipRes2 = clipRes; - } - for (x = xa; x < xb; ++x) { - // map (x+0.5, y+0.5) back to the scaled image - xx = splashFloor(((SplashCoord)x + 0.5 - mat[4]) * ir00 + - ((SplashCoord)y + 0.5 - mat[5]) * ir10); - yy = splashFloor(((SplashCoord)x + 0.5 - mat[4]) * ir01 + - ((SplashCoord)y + 0.5 - mat[5]) * ir11); - // xx should always be within bounds, but floating point - // inaccuracy can cause problems - if (xx < 0) { - xx = 0; - } else if (xx >= scaledWidth) { - xx = scaledWidth - 1; - } - if (yy < 0) { - yy = 0; - } else if (yy >= scaledHeight) { - yy = scaledHeight - 1; - } - scaledImg->getPixel(xx, yy, pixel); - if (srcAlpha) { - pipe.shape = scaledImg->alpha[yy * scaledWidth + xx]; - } else { - pipe.shape = 255; - } - if (vectorAntialias && clipRes2 != splashClipAllInside) { - drawAAPixel(&pipe, x, y); - } else { - drawPixel(&pipe, x, y, clipRes2 == splashClipAllInside); - } - } - } - } - - delete scaledImg; - return splashOk; -} - -// determine if a scaled image requires interpolation based on the scale and -// the interpolate flag from the image dictionary -static GBool isImageInterpolationRequired(int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - GBool interpolate) { - if (interpolate) - return gTrue; - - /* When scale factor is >= 400% we don't interpolate. See bugs #25268, #9860 */ - if (scaledWidth / srcWidth >= 4 || scaledHeight / srcHeight >= 4) - return gFalse; - - return gTrue; -} - -// Scale an image into a SplashBitmap. -SplashBitmap *Splash::scaleImage(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, GBool interpolate, GBool tilingPattern) { - SplashBitmap *dest; - - dest = new SplashBitmap(scaledWidth, scaledHeight, 1, srcMode, srcAlpha, gTrue, bitmap->getSeparationList()); - if (dest->getDataPtr() != NULL) { - if (scaledHeight < srcHeight) { - if (scaledWidth < srcWidth) { - scaleImageYdXd(src, srcData, srcMode, nComps, srcAlpha, - srcWidth, srcHeight, scaledWidth, scaledHeight, dest); - } else { - scaleImageYdXu(src, srcData, srcMode, nComps, srcAlpha, - srcWidth, srcHeight, scaledWidth, scaledHeight, dest); - } - } else { - if (scaledWidth < srcWidth) { - scaleImageYuXd(src, srcData, srcMode, nComps, srcAlpha, - srcWidth, srcHeight, scaledWidth, scaledHeight, dest); - } else { - if (!tilingPattern && isImageInterpolationRequired(srcWidth, srcHeight, scaledWidth, scaledHeight, interpolate)) { - scaleImageYuXuBilinear(src, srcData, srcMode, nComps, srcAlpha, - srcWidth, srcHeight, scaledWidth, scaledHeight, dest); - } else { - scaleImageYuXu(src, srcData, srcMode, nComps, srcAlpha, - srcWidth, srcHeight, scaledWidth, scaledHeight, dest); - } - } - } - } else { - delete dest; - dest = NULL; - } - return dest; -} - -void Splash::scaleImageYdXd(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf, *alphaLineBuf; - Guint *pixBuf, *alphaPixBuf; - Guint pix0, pix1, pix2; -#if SPLASH_CMYK - Guint pix3; - Guint pix[SPOT_NCOMPS+4], cp; -#endif - Guint alpha; - Guchar *destPtr, *destAlphaPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx, xxa, d, d0, d1; - int i, j; - - // Bresenham parameters for y scale - yp = srcHeight / scaledHeight; - yq = srcHeight % scaledHeight; - - // Bresenham parameters for x scale - xp = srcWidth / scaledWidth; - xq = srcWidth % scaledWidth; - - // allocate buffers - lineBuf = (Guchar *)gmallocn(srcWidth, nComps); - pixBuf = (Guint *)gmallocn(srcWidth, nComps * sizeof(int)); - if (srcAlpha) { - alphaLineBuf = (Guchar *)gmalloc(srcWidth); - alphaPixBuf = (Guint *)gmallocn(srcWidth, sizeof(int)); - } else { - alphaLineBuf = NULL; - alphaPixBuf = NULL; - } - - // init y scale Bresenham - yt = 0; - - destPtr = dest->data; - destAlphaPtr = dest->alpha; - for (y = 0; y < scaledHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= scaledHeight) { - yt -= scaledHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read rows from image - memset(pixBuf, 0, srcWidth * nComps * sizeof(int)); - if (srcAlpha) { - memset(alphaPixBuf, 0, srcWidth * sizeof(int)); - } - for (i = 0; i < yStep; ++i) { - (*src)(srcData, lineBuf, alphaLineBuf); - for (j = 0; j < srcWidth * nComps; ++j) { - pixBuf[j] += lineBuf[j]; - } - if (srcAlpha) { - for (j = 0; j < srcWidth; ++j) { - alphaPixBuf[j] += alphaLineBuf[j]; - } - } - } - - // init x scale Bresenham - xt = 0; - d0 = (1 << 23) / (yStep * xp); - d1 = (1 << 23) / (yStep * (xp + 1)); - - xx = xxa = 0; - for (x = 0; x < scaledWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= scaledWidth) { - xt -= scaledWidth; - xStep = xp + 1; - d = d1; - } else { - xStep = xp; - d = d0; - } - - switch (srcMode) { - - case splashModeMono8: - - // compute the final pixel - pix0 = 0; - for (i = 0; i < xStep; ++i) { - pix0 += pixBuf[xx++]; - } - // pix / xStep * yStep - pix0 = (pix0 * d) >> 23; - - // store the pixel - *destPtr++ = (Guchar)pix0; - break; - - case splashModeRGB8: - - // compute the final pixel - pix0 = pix1 = pix2 = 0; - for (i = 0; i < xStep; ++i) { - pix0 += pixBuf[xx]; - pix1 += pixBuf[xx+1]; - pix2 += pixBuf[xx+2]; - xx += 3; - } - // pix / xStep * yStep - pix0 = (pix0 * d) >> 23; - pix1 = (pix1 * d) >> 23; - pix2 = (pix2 * d) >> 23; - - // store the pixel - *destPtr++ = (Guchar)pix0; - *destPtr++ = (Guchar)pix1; - *destPtr++ = (Guchar)pix2; - break; - - case splashModeXBGR8: - - // compute the final pixel - pix0 = pix1 = pix2 = 0; - for (i = 0; i < xStep; ++i) { - pix0 += pixBuf[xx]; - pix1 += pixBuf[xx+1]; - pix2 += pixBuf[xx+2]; - xx += 4; - } - // pix / xStep * yStep - pix0 = (pix0 * d) >> 23; - pix1 = (pix1 * d) >> 23; - pix2 = (pix2 * d) >> 23; - - // store the pixel - *destPtr++ = (Guchar)pix2; - *destPtr++ = (Guchar)pix1; - *destPtr++ = (Guchar)pix0; - *destPtr++ = (Guchar)255; - break; - - case splashModeBGR8: - - // compute the final pixel - pix0 = pix1 = pix2 = 0; - for (i = 0; i < xStep; ++i) { - pix0 += pixBuf[xx]; - pix1 += pixBuf[xx+1]; - pix2 += pixBuf[xx+2]; - xx += 3; - } - // pix / xStep * yStep - pix0 = (pix0 * d) >> 23; - pix1 = (pix1 * d) >> 23; - pix2 = (pix2 * d) >> 23; - - // store the pixel - *destPtr++ = (Guchar)pix2; - *destPtr++ = (Guchar)pix1; - *destPtr++ = (Guchar)pix0; - break; - -#if SPLASH_CMYK - case splashModeCMYK8: - - // compute the final pixel - pix0 = pix1 = pix2 = pix3 = 0; - for (i = 0; i < xStep; ++i) { - pix0 += pixBuf[xx]; - pix1 += pixBuf[xx+1]; - pix2 += pixBuf[xx+2]; - pix3 += pixBuf[xx+3]; - xx += 4; - } - // pix / xStep * yStep - pix0 = (pix0 * d) >> 23; - pix1 = (pix1 * d) >> 23; - pix2 = (pix2 * d) >> 23; - pix3 = (pix3 * d) >> 23; - - // store the pixel - *destPtr++ = (Guchar)pix0; - *destPtr++ = (Guchar)pix1; - *destPtr++ = (Guchar)pix2; - *destPtr++ = (Guchar)pix3; - break; - case splashModeDeviceN8: - - // compute the final pixel - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - pix[cp] = 0; - for (i = 0; i < xStep; ++i) { - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) { - pix[cp] += pixBuf[xx + cp]; - } - xx += (SPOT_NCOMPS+4); - } - // pix / xStep * yStep - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - pix[cp] = (pix[cp] * d) >> 23; - - // store the pixel - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - *destPtr++ = (Guchar)pix[cp]; - break; -#endif - - - case splashModeMono1: // mono1 is not allowed - default: - break; - } - - // process alpha - if (srcAlpha) { - alpha = 0; - for (i = 0; i < xStep; ++i, ++xxa) { - alpha += alphaPixBuf[xxa]; - } - // alpha / xStep * yStep - alpha = (alpha * d) >> 23; - *destAlphaPtr++ = (Guchar)alpha; - } - } - } - - gfree(alphaPixBuf); - gfree(alphaLineBuf); - gfree(pixBuf); - gfree(lineBuf); -} - -void Splash::scaleImageYdXu(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf, *alphaLineBuf; - Guint *pixBuf, *alphaPixBuf; - Guint pix[splashMaxColorComps]; - Guint alpha; - Guchar *destPtr, *destAlphaPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, d; - int i, j; - - // Bresenham parameters for y scale - yp = srcHeight / scaledHeight; - yq = srcHeight % scaledHeight; - - // Bresenham parameters for x scale - xp = scaledWidth / srcWidth; - xq = scaledWidth % srcWidth; - - // allocate buffers - lineBuf = (Guchar *)gmallocn(srcWidth, nComps); - pixBuf = (Guint *)gmallocn(srcWidth, nComps * sizeof(int)); - if (srcAlpha) { - alphaLineBuf = (Guchar *)gmalloc(srcWidth); - alphaPixBuf = (Guint *)gmallocn(srcWidth, sizeof(int)); - } else { - alphaLineBuf = NULL; - alphaPixBuf = NULL; - } - - // init y scale Bresenham - yt = 0; - - destPtr = dest->data; - destAlphaPtr = dest->alpha; - for (y = 0; y < scaledHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= scaledHeight) { - yt -= scaledHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read rows from image - memset(pixBuf, 0, srcWidth * nComps * sizeof(int)); - if (srcAlpha) { - memset(alphaPixBuf, 0, srcWidth * sizeof(int)); - } - for (i = 0; i < yStep; ++i) { - (*src)(srcData, lineBuf, alphaLineBuf); - for (j = 0; j < srcWidth * nComps; ++j) { - pixBuf[j] += lineBuf[j]; - } - if (srcAlpha) { - for (j = 0; j < srcWidth; ++j) { - alphaPixBuf[j] += alphaLineBuf[j]; - } - } - } - - // init x scale Bresenham - xt = 0; - d = (1 << 23) / yStep; - - for (x = 0; x < srcWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= srcWidth) { - xt -= srcWidth; - xStep = xp + 1; - } else { - xStep = xp; - } - - // compute the final pixel - for (i = 0; i < nComps; ++i) { - // pixBuf[] / yStep - pix[i] = (pixBuf[x * nComps + i] * d) >> 23; - } - - // store the pixel - switch (srcMode) { - case splashModeMono1: // mono1 is not allowed - break; - case splashModeMono8: - for (i = 0; i < xStep; ++i) { - *destPtr++ = (Guchar)pix[0]; - } - break; - case splashModeRGB8: - for (i = 0; i < xStep; ++i) { - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - } - break; - case splashModeXBGR8: - for (i = 0; i < xStep; ++i) { - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)255; - } - break; - case splashModeBGR8: - for (i = 0; i < xStep; ++i) { - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - for (i = 0; i < xStep; ++i) { - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[3]; - } - break; - case splashModeDeviceN8: - for (i = 0; i < xStep; ++i) { - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *destPtr++ = (Guchar)pix[cp]; - } - break; -#endif - } - - // process alpha - if (srcAlpha) { - // alphaPixBuf[] / yStep - alpha = (alphaPixBuf[x] * d) >> 23; - for (i = 0; i < xStep; ++i) { - *destAlphaPtr++ = (Guchar)alpha; - } - } - } - } - - gfree(alphaPixBuf); - gfree(alphaLineBuf); - gfree(pixBuf); - gfree(lineBuf); -} - -void Splash::scaleImageYuXd(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf, *alphaLineBuf; - Guint pix[splashMaxColorComps]; - Guint alpha; - Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx, xxa, d, d0, d1; - int i, j; - - // Bresenham parameters for y scale - yp = scaledHeight / srcHeight; - yq = scaledHeight % srcHeight; - - // Bresenham parameters for x scale - xp = srcWidth / scaledWidth; - xq = srcWidth % scaledWidth; - - // allocate buffers - lineBuf = (Guchar *)gmallocn_checkoverflow(srcWidth, nComps); - if (unlikely(!lineBuf)) - return; - if (srcAlpha) { - alphaLineBuf = (Guchar *)gmalloc(srcWidth); - } else { - alphaLineBuf = NULL; - } - - // init y scale Bresenham - yt = 0; - - destPtr0 = dest->data; - destAlphaPtr0 = dest->alpha; - for (y = 0; y < srcHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= srcHeight) { - yt -= srcHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read row from image - (*src)(srcData, lineBuf, alphaLineBuf); - - // init x scale Bresenham - xt = 0; - d0 = (1 << 23) / xp; - d1 = (1 << 23) / (xp + 1); - - xx = xxa = 0; - for (x = 0; x < scaledWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= scaledWidth) { - xt -= scaledWidth; - xStep = xp + 1; - d = d1; - } else { - xStep = xp; - d = d0; - } - - // compute the final pixel - for (i = 0; i < nComps; ++i) { - pix[i] = 0; - } - for (i = 0; i < xStep; ++i) { - for (j = 0; j < nComps; ++j, ++xx) { - pix[j] += lineBuf[xx]; - } - } - for (i = 0; i < nComps; ++i) { - // pix[] / xStep - pix[i] = (pix[i] * d) >> 23; - } - - // store the pixel - switch (srcMode) { - case splashModeMono1: // mono1 is not allowed - break; - case splashModeMono8: - for (i = 0; i < yStep; ++i) { - destPtr = destPtr0 + (i * scaledWidth + x) * nComps; - *destPtr++ = (Guchar)pix[0]; - } - break; - case splashModeRGB8: - for (i = 0; i < yStep; ++i) { - destPtr = destPtr0 + (i * scaledWidth + x) * nComps; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - } - break; - case splashModeXBGR8: - for (i = 0; i < yStep; ++i) { - destPtr = destPtr0 + (i * scaledWidth + x) * nComps; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)255; - } - break; - case splashModeBGR8: - for (i = 0; i < yStep; ++i) { - destPtr = destPtr0 + (i * scaledWidth + x) * nComps; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - for (i = 0; i < yStep; ++i) { - destPtr = destPtr0 + (i * scaledWidth + x) * nComps; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[3]; - } - break; - case splashModeDeviceN8: - for (i = 0; i < yStep; ++i) { - destPtr = destPtr0 + (i * scaledWidth + x) * nComps; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *destPtr++ = (Guchar)pix[cp]; - } - break; -#endif - } - - // process alpha - if (srcAlpha) { - alpha = 0; - for (i = 0; i < xStep; ++i, ++xxa) { - alpha += alphaLineBuf[xxa]; - } - // alpha / xStep - alpha = (alpha * d) >> 23; - for (i = 0; i < yStep; ++i) { - destAlphaPtr = destAlphaPtr0 + i * scaledWidth + x; - *destAlphaPtr = (Guchar)alpha; - } - } - } - - destPtr0 += yStep * scaledWidth * nComps; - if (srcAlpha) { - destAlphaPtr0 += yStep * scaledWidth; - } - } - - gfree(alphaLineBuf); - gfree(lineBuf); -} - -void Splash::scaleImageYuXu(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *lineBuf, *alphaLineBuf; - Guint pix[splashMaxColorComps]; - Guint alpha; - Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; - int yp, yq, xp, xq, yt, y, yStep, xt, x, xStep, xx; - int i, j; - - // Bresenham parameters for y scale - yp = scaledHeight / srcHeight; - yq = scaledHeight % srcHeight; - - // Bresenham parameters for x scale - xp = scaledWidth / srcWidth; - xq = scaledWidth % srcWidth; - - // allocate buffers - lineBuf = (Guchar *)gmallocn(srcWidth, nComps); - if (srcAlpha) { - alphaLineBuf = (Guchar *)gmalloc(srcWidth); - } else { - alphaLineBuf = NULL; - } - - // init y scale Bresenham - yt = 0; - - destPtr0 = dest->data; - destAlphaPtr0 = dest->alpha; - for (y = 0; y < srcHeight; ++y) { - - // y scale Bresenham - if ((yt += yq) >= srcHeight) { - yt -= srcHeight; - yStep = yp + 1; - } else { - yStep = yp; - } - - // read row from image - (*src)(srcData, lineBuf, alphaLineBuf); - - // init x scale Bresenham - xt = 0; - - xx = 0; - for (x = 0; x < srcWidth; ++x) { - - // x scale Bresenham - if ((xt += xq) >= srcWidth) { - xt -= srcWidth; - xStep = xp + 1; - } else { - xStep = xp; - } - - // compute the final pixel - for (i = 0; i < nComps; ++i) { - pix[i] = lineBuf[x * nComps + i]; - } - - // store the pixel - switch (srcMode) { - case splashModeMono1: // mono1 is not allowed - break; - case splashModeMono8: - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; - *destPtr++ = (Guchar)pix[0]; - } - } - break; - case splashModeRGB8: - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - } - } - break; - case splashModeXBGR8: - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)255; - } - } - break; - case splashModeBGR8: - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - } - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[3]; - } - } - break; - case splashModeDeviceN8: - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destPtr = destPtr0 + (i * scaledWidth + xx + j) * nComps; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *destPtr++ = (Guchar)pix[cp]; - } - } - break; -#endif - } - - // process alpha - if (srcAlpha) { - alpha = alphaLineBuf[x]; - for (i = 0; i < yStep; ++i) { - for (j = 0; j < xStep; ++j) { - destAlphaPtr = destAlphaPtr0 + i * scaledWidth + xx + j; - *destAlphaPtr = (Guchar)alpha; - } - } - } - - xx += xStep; - } - - destPtr0 += yStep * scaledWidth * nComps; - if (srcAlpha) { - destAlphaPtr0 += yStep * scaledWidth; - } - } - - gfree(alphaLineBuf); - gfree(lineBuf); -} - -// expand source row to scaledWidth using linear interpolation -static void expandRow(Guchar *srcBuf, Guchar *dstBuf, int srcWidth, int scaledWidth, int nComps) -{ - double xStep = (double)srcWidth/scaledWidth; - double xSrc = 0.0; - double xFrac, xInt; - int p; - - // pad the source with an extra pixel equal to the last pixel - // so that when xStep is inside the last pixel we still have two - // pixels to interpolate between. - for (int i = 0; i < nComps; i++) - srcBuf[srcWidth*nComps + i] = srcBuf[(srcWidth-1)*nComps + i]; - - for (int x = 0; x < scaledWidth; x++) { - xFrac = modf(xSrc, &xInt); - p = (int)xInt; - for (int c = 0; c < nComps; c++) { - dstBuf[nComps*x + c] = srcBuf[nComps*p + c]*(1.0 - xFrac) + srcBuf[nComps*(p+1) + c]*xFrac; - } - xSrc += xStep; - } -} - -// Scale up image using bilinear interpolation -void Splash::scaleImageYuXuBilinear(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest) { - Guchar *srcBuf, *lineBuf1, *lineBuf2, *alphaSrcBuf, *alphaLineBuf1, *alphaLineBuf2; - Guint pix[splashMaxColorComps]; - Guchar *destPtr0, *destPtr, *destAlphaPtr0, *destAlphaPtr; - int i; - - if (srcWidth < 1 || srcHeight < 1) - return; - - // allocate buffers - srcBuf = (Guchar *)gmallocn(srcWidth+1, nComps); // + 1 pixel of padding - lineBuf1 = (Guchar *)gmallocn(scaledWidth, nComps); - lineBuf2 = (Guchar *)gmallocn(scaledWidth, nComps); - if (srcAlpha) { - alphaSrcBuf = (Guchar *)gmalloc(srcWidth+1); // + 1 pixel of padding - alphaLineBuf1 = (Guchar *)gmalloc(scaledWidth); - alphaLineBuf2 = (Guchar *)gmalloc(scaledWidth); - } else { - alphaSrcBuf = NULL; - alphaLineBuf1 = NULL; - alphaLineBuf2 = NULL; - } - - double ySrc = 0.0; - double yStep = (double)srcHeight/scaledHeight; - double yFrac, yInt; - int currentSrcRow = -1; - (*src)(srcData, srcBuf, alphaSrcBuf); - expandRow(srcBuf, lineBuf2, srcWidth, scaledWidth, nComps); - if (srcAlpha) - expandRow(alphaSrcBuf, alphaLineBuf2, srcWidth, scaledWidth, 1); - - destPtr0 = dest->data; - destAlphaPtr0 = dest->alpha; - for (int y = 0; y < scaledHeight; y++) { - yFrac = modf(ySrc, &yInt); - if ((int)yInt > currentSrcRow) { - currentSrcRow++; - // Copy line2 data to line1 and get next line2 data. - // If line2 already contains the last source row we don't touch it. - // This effectively adds an extra row of padding for interpolating the - // last source row with. - memcpy(lineBuf1, lineBuf2, scaledWidth * nComps); - if (srcAlpha) - memcpy(alphaLineBuf1, alphaLineBuf2, scaledWidth); - if (currentSrcRow < srcHeight) { - (*src)(srcData, srcBuf, alphaSrcBuf); - expandRow(srcBuf, lineBuf2, srcWidth, scaledWidth, nComps); - if (srcAlpha) - expandRow(alphaSrcBuf, alphaLineBuf2, srcWidth, scaledWidth, 1); - } - } - - // write row y using linear interpolation on lineBuf1 and lineBuf2 - for (int x = 0; x < scaledWidth; ++x) { - // compute the final pixel - for (i = 0; i < nComps; ++i) { - pix[i] = lineBuf1[x*nComps + i]*(1.0 - yFrac) + lineBuf2[x*nComps + i]*yFrac; - } - - // store the pixel - destPtr = destPtr0 + (y * scaledWidth + x) * nComps; - switch (srcMode) { - case splashModeMono1: // mono1 is not allowed - break; - case splashModeMono8: - *destPtr++ = (Guchar)pix[0]; - break; - case splashModeRGB8: - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - break; - case splashModeXBGR8: - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)255; - break; - case splashModeBGR8: - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[0]; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - *destPtr++ = (Guchar)pix[0]; - *destPtr++ = (Guchar)pix[1]; - *destPtr++ = (Guchar)pix[2]; - *destPtr++ = (Guchar)pix[3]; - break; - case splashModeDeviceN8: - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - *destPtr++ = (Guchar)pix[cp]; - break; -#endif - } - - // process alpha - if (srcAlpha) { - destAlphaPtr = destAlphaPtr0 + y*scaledWidth + x; - *destAlphaPtr = alphaLineBuf1[x]*(1.0 - yFrac) + alphaLineBuf2[x]*yFrac; - } - } - - ySrc += yStep; - } - - gfree(alphaSrcBuf); - gfree(alphaLineBuf1); - gfree(alphaLineBuf2); - gfree(srcBuf); - gfree(lineBuf1); - gfree(lineBuf2); -} - -void Splash::vertFlipImage(SplashBitmap *img, int width, int height, - int nComps) { - Guchar *lineBuf; - Guchar *p0, *p1; - int w; - - if (unlikely(img->data == NULL)) { - error(errInternal, -1, "img->data is NULL in Splash::vertFlipImage"); - return; - } - - w = width * nComps; - lineBuf = (Guchar *)gmalloc(w); - for (p0 = img->data, p1 = img->data + (height - 1) * w; - p0 < p1; - p0 += w, p1 -= w) { - memcpy(lineBuf, p0, w); - memcpy(p0, p1, w); - memcpy(p1, lineBuf, w); - } - if (img->alpha) { - for (p0 = img->alpha, p1 = img->alpha + (height - 1) * width; - p0 < p1; - p0 += width, p1 -= width) { - memcpy(lineBuf, p0, width); - memcpy(p0, p1, width); - memcpy(p1, lineBuf, width); - } - } - gfree(lineBuf); -} - -void Splash::blitImage(SplashBitmap *src, GBool srcAlpha, int xDest, int yDest) { - SplashClipResult clipRes = state->clip->testRect(xDest, yDest, xDest + src->getWidth() - 1, yDest + src->getHeight() - 1); - if (clipRes != splashClipAllOutside) { - blitImage(src, srcAlpha, xDest, yDest, clipRes); - } -} - -void Splash::blitImage(SplashBitmap *src, GBool srcAlpha, int xDest, int yDest, - SplashClipResult clipRes) { - SplashPipe pipe; - SplashColor pixel; - Guchar *ap; - int w, h, x0, y0, x1, y1, x, y; - - // split the image into clipped and unclipped regions - w = src->getWidth(); - h = src->getHeight(); - if (clipRes == splashClipAllInside) { - x0 = 0; - y0 = 0; - x1 = w; - y1 = h; - } else { - if (state->clip->getNumPaths()) { - x0 = x1 = w; - y0 = y1 = h; - } else { - if ((x0 = splashCeil(state->clip->getXMin()) - xDest) < 0) { - x0 = 0; - } - if ((y0 = splashCeil(state->clip->getYMin()) - yDest) < 0) { - y0 = 0; - } - if ((x1 = splashFloor(state->clip->getXMax()) - xDest) > w) { - x1 = w; - } - if (x1 < x0) { - x1 = x0; - } - if ((y1 = splashFloor(state->clip->getYMax()) - yDest) > h) { - y1 = h; - } - if (y1 < y0) { - y1 = y0; - } - } - } - - // draw the unclipped region - if (x0 < w && y0 < h && x0 < x1 && y0 < y1) { - pipeInit(&pipe, xDest + x0, yDest + y0, NULL, pixel, - (Guchar)splashRound(state->fillAlpha * 255), srcAlpha, gFalse); - if (srcAlpha) { - for (y = y0; y < y1; ++y) { - pipeSetXY(&pipe, xDest + x0, yDest + y); - ap = src->getAlphaPtr() + y * w + x0; - for (x = x0; x < x1; ++x) { - src->getPixel(x, y, pixel); - pipe.shape = *ap++; - (this->*pipe.run)(&pipe); - } - } - } else { - for (y = y0; y < y1; ++y) { - pipeSetXY(&pipe, xDest + x0, yDest + y); - for (x = x0; x < x1; ++x) { - src->getPixel(x, y, pixel); - (this->*pipe.run)(&pipe); - } - } - } - updateModX(xDest + x0); - updateModX(xDest + x1 - 1); - updateModY(yDest + y0); - updateModY(yDest + y1 - 1); - } - - // draw the clipped regions - if (y0 > 0) { - blitImageClipped(src, srcAlpha, 0, 0, xDest, yDest, w, y0); - } - if (y1 < h) { - blitImageClipped(src, srcAlpha, 0, y1, xDest, yDest + y1, w, h - y1); - } - if (x0 > 0 && y0 < y1) { - blitImageClipped(src, srcAlpha, 0, y0, xDest, yDest + y0, x0, y1 - y0); - } - if (x1 < w && y0 < y1) { - blitImageClipped(src, srcAlpha, x1, y0, xDest + x1, yDest + y0, - w - x1, y1 - y0); - } -} - -void Splash::blitImageClipped(SplashBitmap *src, GBool srcAlpha, - int xSrc, int ySrc, int xDest, int yDest, - int w, int h) { - SplashPipe pipe; - SplashColor pixel; - Guchar *ap; - int x, y; - - if (vectorAntialias) { - pipeInit(&pipe, xDest, yDest, NULL, pixel, - (Guchar)splashRound(state->fillAlpha * 255), gTrue, gFalse); - drawAAPixelInit(); - if (srcAlpha) { - for (y = 0; y < h; ++y) { - ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc; - for (x = 0; x < w; ++x) { - src->getPixel(xSrc + x, ySrc + y, pixel); - pipe.shape = *ap++; - drawAAPixel(&pipe, xDest + x, yDest + y); - } - } - } else { - for (y = 0; y < h; ++y) { - for (x = 0; x < w; ++x) { - src->getPixel(xSrc + x, ySrc + y, pixel); - pipe.shape = 255; - drawAAPixel(&pipe, xDest + x, yDest + y); - } - } - } - } else { - pipeInit(&pipe, xDest, yDest, NULL, pixel, - (Guchar)splashRound(state->fillAlpha * 255), srcAlpha, gFalse); - if (srcAlpha) { - for (y = 0; y < h; ++y) { - ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc; - pipeSetXY(&pipe, xDest, yDest + y); - for (x = 0; x < w; ++x) { - if (state->clip->test(xDest + x, yDest + y)) { - src->getPixel(xSrc + x, ySrc + y, pixel); - pipe.shape = *ap++; - (this->*pipe.run)(&pipe); - updateModX(xDest + x); - updateModY(yDest + y); - } else { - pipeIncX(&pipe); - ++ap; - } - } - } - } else { - for (y = 0; y < h; ++y) { - pipeSetXY(&pipe, xDest, yDest + y); - for (x = 0; x < w; ++x) { - if (state->clip->test(xDest + x, yDest + y)) { - src->getPixel(xSrc + x, ySrc + y, pixel); - (this->*pipe.run)(&pipe); - updateModX(xDest + x); - updateModY(yDest + y); - } else { - pipeIncX(&pipe); - } - } - } - } - } -} - -SplashError Splash::composite(SplashBitmap *src, int xSrc, int ySrc, - int xDest, int yDest, int w, int h, - GBool noClip, GBool nonIsolated, - GBool knockout, SplashCoord knockoutOpacity) { - SplashPipe pipe; - SplashColor pixel; - Guchar alpha; - Guchar *ap; - int x, y; - - if (src->mode != bitmap->mode) { - return splashErrModeMismatch; - } - - if (unlikely(!bitmap->data)) { - return splashErrZeroImage; - } - - if(src->getSeparationList()->getLength() > bitmap->getSeparationList()->getLength()) { - for (x = bitmap->getSeparationList()->getLength(); x < src->getSeparationList()->getLength(); x++) - bitmap->getSeparationList()->append(((GfxSeparationColorSpace *)src->getSeparationList()->get(x))->copy()); - } - if (src->alpha) { - pipeInit(&pipe, xDest, yDest, NULL, pixel, - (Guchar)splashRound(state->fillAlpha * 255), gTrue, nonIsolated, - knockout, (Guchar)splashRound(knockoutOpacity * 255)); - if (noClip) { - for (y = 0; y < h; ++y) { - pipeSetXY(&pipe, xDest, yDest + y); - ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc; - for (x = 0; x < w; ++x) { - src->getPixel(xSrc + x, ySrc + y, pixel); - alpha = *ap++; - // this uses shape instead of alpha, which isn't technically - // correct, but works out the same - pipe.shape = alpha; - (this->*pipe.run)(&pipe); - } - } - updateModX(xDest); - updateModX(xDest + w - 1); - updateModY(yDest); - updateModY(yDest + h - 1); - } else { - for (y = 0; y < h; ++y) { - pipeSetXY(&pipe, xDest, yDest + y); - ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc; - for (x = 0; x < w; ++x) { - src->getPixel(xSrc + x, ySrc + y, pixel); - alpha = *ap++; - if (state->clip->test(xDest + x, yDest + y)) { - // this uses shape instead of alpha, which isn't technically - // correct, but works out the same - pipe.shape = alpha; - (this->*pipe.run)(&pipe); - updateModX(xDest + x); - updateModY(yDest + y); - } else { - pipeIncX(&pipe); - } - } - } - } - } else { - pipeInit(&pipe, xDest, yDest, NULL, pixel, - (Guchar)splashRound(state->fillAlpha * 255), gFalse, nonIsolated); - if (noClip) { - for (y = 0; y < h; ++y) { - pipeSetXY(&pipe, xDest, yDest + y); - for (x = 0; x < w; ++x) { - src->getPixel(xSrc + x, ySrc + y, pixel); - (this->*pipe.run)(&pipe); - } - } - updateModX(xDest); - updateModX(xDest + w - 1); - updateModY(yDest); - updateModY(yDest + h - 1); - } else { - for (y = 0; y < h; ++y) { - pipeSetXY(&pipe, xDest, yDest + y); - for (x = 0; x < w; ++x) { - src->getPixel(xSrc + x, ySrc + y, pixel); - if (state->clip->test(xDest + x, yDest + y)) { - (this->*pipe.run)(&pipe); - updateModX(xDest + x); - updateModY(yDest + y); - } else { - pipeIncX(&pipe); - } - } - } - } - } - - return splashOk; -} - -void Splash::compositeBackground(SplashColorPtr color) { - SplashColorPtr p; - Guchar *q; - Guchar alpha, alpha1, c, color0, color1, color2; -#if SPLASH_CMYK - Guchar color3; - Guchar colorsp[SPOT_NCOMPS+4], cp; -#endif - int x, y, mask; - - if (unlikely(bitmap->alpha == NULL)) { - error(errInternal, -1, "bitmap->alpha is NULL in Splash::compositeBackground"); - return; - } - - switch (bitmap->mode) { - case splashModeMono1: - color0 = color[0]; - for (y = 0; y < bitmap->height; ++y) { - p = &bitmap->data[y * bitmap->rowSize]; - q = &bitmap->alpha[y * bitmap->width]; - mask = 0x80; - for (x = 0; x < bitmap->width; ++x) { - alpha = *q++; - alpha1 = 255 - alpha; - c = (*p & mask) ? 0xff : 0x00; - c = div255(alpha1 * color0 + alpha * c); - if (c & 0x80) { - *p |= mask; - } else { - *p &= ~mask; - } - if (!(mask >>= 1)) { - mask = 0x80; - ++p; - } - } - } - break; - case splashModeMono8: - color0 = color[0]; - for (y = 0; y < bitmap->height; ++y) { - p = &bitmap->data[y * bitmap->rowSize]; - q = &bitmap->alpha[y * bitmap->width]; - for (x = 0; x < bitmap->width; ++x) { - alpha = *q++; - alpha1 = 255 - alpha; - p[0] = div255(alpha1 * color0 + alpha * p[0]); - ++p; - } - } - break; - case splashModeRGB8: - case splashModeBGR8: - color0 = color[0]; - color1 = color[1]; - color2 = color[2]; - for (y = 0; y < bitmap->height; ++y) { - p = &bitmap->data[y * bitmap->rowSize]; - q = &bitmap->alpha[y * bitmap->width]; - for (x = 0; x < bitmap->width; ++x) { - alpha = *q++; - if (alpha == 0) - { - p[0] = color0; - p[1] = color1; - p[2] = color2; - } - else if (alpha != 255) - { - alpha1 = 255 - alpha; - p[0] = div255(alpha1 * color0 + alpha * p[0]); - p[1] = div255(alpha1 * color1 + alpha * p[1]); - p[2] = div255(alpha1 * color2 + alpha * p[2]); - } - p += 3; - } - } - break; - case splashModeXBGR8: - color0 = color[0]; - color1 = color[1]; - color2 = color[2]; - for (y = 0; y < bitmap->height; ++y) { - p = &bitmap->data[y * bitmap->rowSize]; - q = &bitmap->alpha[y * bitmap->width]; - for (x = 0; x < bitmap->width; ++x) { - alpha = *q++; - if (alpha == 0) - { - p[0] = color0; - p[1] = color1; - p[2] = color2; - } - else if (alpha != 255) - { - alpha1 = 255 - alpha; - p[0] = div255(alpha1 * color0 + alpha * p[0]); - p[1] = div255(alpha1 * color1 + alpha * p[1]); - p[2] = div255(alpha1 * color2 + alpha * p[2]); - } - p[3] = 255; - p += 4; - } - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - color0 = color[0]; - color1 = color[1]; - color2 = color[2]; - color3 = color[3]; - for (y = 0; y < bitmap->height; ++y) { - p = &bitmap->data[y * bitmap->rowSize]; - q = &bitmap->alpha[y * bitmap->width]; - for (x = 0; x < bitmap->width; ++x) { - alpha = *q++; - if (alpha == 0) - { - p[0] = color0; - p[1] = color1; - p[2] = color2; - p[3] = color3; - } - else if (alpha != 255) - { - alpha1 = 255 - alpha; - p[0] = div255(alpha1 * color0 + alpha * p[0]); - p[1] = div255(alpha1 * color1 + alpha * p[1]); - p[2] = div255(alpha1 * color2 + alpha * p[2]); - p[3] = div255(alpha1 * color3 + alpha * p[3]); - } - p += 4; - } - } - break; - case splashModeDeviceN8: - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - colorsp[cp] = color[cp]; - for (y = 0; y < bitmap->height; ++y) { - p = &bitmap->data[y * bitmap->rowSize]; - q = &bitmap->alpha[y * bitmap->width]; - for (x = 0; x < bitmap->width; ++x) { - alpha = *q++; - if (alpha == 0) - { - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - p[cp] = colorsp[cp]; - } - else if (alpha != 255) - { - alpha1 = 255 - alpha; - for (cp = 0; cp < SPOT_NCOMPS+4; cp++) - p[cp] = div255(alpha1 * colorsp[cp] + alpha * p[cp]); - } - p += (SPOT_NCOMPS+4); - } - } - break; -#endif - } - memset(bitmap->alpha, 255, bitmap->width * bitmap->height); -} - -GBool Splash::gouraudTriangleShadedFill(SplashGouraudColor *shading) -{ - double xdbl[3] = {0., 0., 0.}; - double ydbl[3] = {0., 0., 0.}; - int x[3] = {0, 0, 0}; - int y[3] = {0, 0, 0}; - double xt=0., xa=0., yt=0.; - double ca=0., ct=0.; - - // triangle interpolation: - // - double scanLimitMapL[2] = {0., 0.}; - double scanLimitMapR[2] = {0., 0.}; - double scanColorMapL[2] = {0., 0.}; - double scanColorMapR[2] = {0., 0.}; - double scanColorMap[2] = {0., 0.}; - int scanEdgeL[2] = { 0, 0 }; - int scanEdgeR[2] = { 0, 0 }; - GBool hasFurtherSegment = gFalse; - - int scanLineOff = 0; - int bitmapOff = 0; - int scanLimitR = 0, scanLimitL = 0; - - int bitmapWidth = bitmap->getWidth(); - SplashClip* clip = getClip(); - SplashBitmap *blitTarget = bitmap; - SplashColorPtr bitmapData = bitmap->getDataPtr(); - int bitmapOffLimit = bitmap->getHeight() * bitmap->getRowSize(); - SplashColorPtr bitmapAlpha = bitmap->getAlphaPtr(); - SplashColorPtr cur = NULL; - SplashCoord* userToCanvasMatrix = getMatrix(); - SplashColorMode bitmapMode = bitmap->getMode(); - GBool hasAlpha = (bitmapAlpha != NULL); - int rowSize = bitmap->getRowSize(); - int colorComps = 0; - switch (bitmapMode) { - case splashModeMono1: - break; - case splashModeMono8: - colorComps=1; - break; - case splashModeRGB8: - colorComps=3; - break; - case splashModeBGR8: - colorComps=3; - break; - case splashModeXBGR8: - colorComps=4; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - colorComps=4; - break; - case splashModeDeviceN8: - colorComps=SPOT_NCOMPS+4; - break; -#endif - } - - SplashPipe pipe; - SplashColor cSrcVal; - - pipeInit(&pipe, 0, 0, NULL, cSrcVal, (Guchar)splashRound(state->strokeAlpha * 255), gFalse, gFalse); - - if (vectorAntialias) { - if (aaBuf == NULL) - return gFalse; // fall back to old behaviour - drawAAPixelInit(); - } - - // idea: - // 1. If pipe->noTransparency && !state->blendFunc - // -> blit directly into the drawing surface! - // -> disable alpha manually. - // 2. Otherwise: - // - blit also directly, but into an intermediate surface. - // Afterwards, blit the intermediate surface using the drawing pipeline. - // This is necessary because triangle elements can be on top of each - // other, so the complete shading needs to be drawn before opacity is - // applied. - // - the final step, is performed using a SplashPipe: - // - assign the actual color into cSrcVal: pipe uses cSrcVal by reference - // - invoke drawPixel(&pipe,X,Y,bNoClip); - GBool bDirectBlit = vectorAntialias ? gFalse : pipe.noTransparency && !state->blendFunc; - if (!bDirectBlit) { - blitTarget = new SplashBitmap(bitmap->getWidth(), - bitmap->getHeight(), - bitmap->getRowPad(), - bitmap->getMode(), - gTrue, - bitmap->getRowSize() >= 0); - bitmapData = blitTarget->getDataPtr(); - bitmapAlpha = blitTarget->getAlphaPtr(); - - // initialisation seems to be necessary: - int S = bitmap->getWidth() * bitmap->getHeight(); - for (int i = 0; i < S; ++i) - bitmapAlpha[i] = 0; - hasAlpha = gTrue; - } - - if (shading->isParameterized()) { - double color[3]; - double colorinterp; - - for (int i = 0; i < shading->getNTriangles(); ++i) { - shading->getTriangle(i, - xdbl + 0, ydbl + 0, color + 0, - xdbl + 1, ydbl + 1, color + 1, - xdbl + 2, ydbl + 2, color + 2); - for (int m = 0; m < 3; ++m) { - xt = xdbl[m] * (double)userToCanvasMatrix[0] + ydbl[m] * (double)userToCanvasMatrix[2] + (double)userToCanvasMatrix[4]; - yt = xdbl[m] * (double)userToCanvasMatrix[1] + ydbl[m] * (double)userToCanvasMatrix[3] + (double)userToCanvasMatrix[5]; - xdbl[m] = xt; - ydbl[m] = yt; - // we operate on scanlines which are integer offsets into the - // raster image. The double offsets are of no use here. - x[m] = splashRound(xt); - y[m] = splashRound(yt); - } - // sort according to y coordinate to simplify sweep through scanlines: - // INSERTION SORT. - if (y[0] > y[1]) { - Guswap(x[0], x[1]); - Guswap(y[0], y[1]); - Guswap(color[0], color[1]); - } - // first two are sorted. - assert(y[0] <= y[1]); - if (y[1] > y[2]) { - int tmpX = x[2]; - int tmpY = y[2]; - double tmpC = color[2]; - x[2] = x[1]; y[2] = y[1]; color[2] = color[1]; - - if (y[0] > tmpY) { - x[1] = x[0]; y[1] = y[0]; color[1] = color[0]; - x[0] = tmpX; y[0] = tmpY; color[0] = tmpC; - } else { - x[1] = tmpX; y[1] = tmpY; color[1] = tmpC; - } - } - // first three are sorted - assert(y[0] <= y[1]); - assert(y[1] <= y[2]); - ///// - - // this here is det( T ) == 0 - // where T is the matrix to map to barycentric coordinates. - if ((x[0] - x[2]) * (y[1] - y[2]) - (x[1] - x[2]) * (y[0] - y[2]) == 0) - continue; // degenerate triangle. - - // this here initialises the scanline generation. - // We start with low Y coordinates and sweep up to the large Y - // coordinates. - // - // scanEdgeL[m] in {0,1,2} m=0,1 - // scanEdgeR[m] in {0,1,2} m=0,1 - // - // are the two edges between which scanlines are (currently) - // sweeped. The values {0,1,2} are indices into 'x' and 'y'. - // scanEdgeL[0] = 0 means: the left scan edge has (x[0],y[0]) as vertex. - // - scanEdgeL[0] = 0; - scanEdgeR[0] = 0; - if (y[0] == y[1]) { - scanEdgeL[0] = 1; - scanEdgeL[1] = scanEdgeR[1] = 2; - - } else { - scanEdgeL[1] = 1; scanEdgeR[1] = 2; - } - assert(y[scanEdgeL[0]] < y[scanEdgeL[1]]); - assert(y[scanEdgeR[0]] < y[scanEdgeR[1]]); - - // Ok. Now prepare the linear maps which map the y coordinate of - // the current scanline to the corresponding LEFT and RIGHT x - // coordinate (which define the scanline). - scanLimitMapL[0] = double(x[scanEdgeL[1]] - x[scanEdgeL[0]]) / (y[scanEdgeL[1]] - y[scanEdgeL[0]]); - scanLimitMapL[1] = x[scanEdgeL[0]] - y[scanEdgeL[0]] * scanLimitMapL[0]; - scanLimitMapR[0] = double(x[scanEdgeR[1]] - x[scanEdgeR[0]]) / (y[scanEdgeR[1]] - y[scanEdgeR[0]]); - scanLimitMapR[1] = x[scanEdgeR[0]] - y[scanEdgeR[0]] * scanLimitMapR[0]; - - xa = y[1] * scanLimitMapL[0] + scanLimitMapL[1]; - xt = y[1] * scanLimitMapR[0] + scanLimitMapR[1]; - if (xa > xt) { - // I have "left" is to the right of "right". - // Exchange sides! - Guswap(scanEdgeL[0], scanEdgeR[0]); - Guswap(scanEdgeL[1], scanEdgeR[1]); - Guswap(scanLimitMapL[0], scanLimitMapR[0]); - Guswap(scanLimitMapL[1], scanLimitMapR[1]); - // FIXME I'm sure there is a more efficient way to check this. - } - - // Same game: we can linearly interpolate the color based on the - // current y coordinate (that's correct for triangle - // interpolation due to linearity. We could also have done it in - // barycentric coordinates, but that's slightly more involved) - scanColorMapL[0] = (color[scanEdgeL[1]] - color[scanEdgeL[0]]) / (y[scanEdgeL[1]] - y[scanEdgeL[0]]); - scanColorMapL[1] = color[scanEdgeL[0]] - y[scanEdgeL[0]] * scanColorMapL[0]; - scanColorMapR[0] = (color[scanEdgeR[1]] - color[scanEdgeR[0]]) / (y[scanEdgeR[1]] - y[scanEdgeR[0]]); - scanColorMapR[1] = color[scanEdgeR[0]] - y[scanEdgeR[0]] * scanColorMapR[0]; - - hasFurtherSegment = (y[1] < y[2]); - scanLineOff = y[0] * rowSize; - - for (int Y = y[0]; Y <= y[2]; ++Y, scanLineOff += rowSize) { - if (hasFurtherSegment && Y == y[1]) { - // SWEEP EVENT: we encountered the next segment. - // - // switch to next segment, either at left end or at right - // end: - if (scanEdgeL[1] == 1) { - scanEdgeL[0] = 1; - scanEdgeL[1] = 2; - scanLimitMapL[0] = double(x[scanEdgeL[1]] - x[scanEdgeL[0]]) / (y[scanEdgeL[1]] - y[scanEdgeL[0]]); - scanLimitMapL[1] = x[scanEdgeL[0]] - y[scanEdgeL[0]] * scanLimitMapL[0]; - - scanColorMapL[0] = (color[scanEdgeL[1]] - color[scanEdgeL[0]]) / (y[scanEdgeL[1]] - y[scanEdgeL[0]]); - scanColorMapL[1] = color[scanEdgeL[0]] - y[scanEdgeL[0]] * scanColorMapL[0]; - } else if (scanEdgeR[1] == 1) { - scanEdgeR[0] = 1; - scanEdgeR[1] = 2; - scanLimitMapR[0] = double(x[scanEdgeR[1]] - x[scanEdgeR[0]]) / (y[scanEdgeR[1]] - y[scanEdgeR[0]]); - scanLimitMapR[1] = x[scanEdgeR[0]] - y[scanEdgeR[0]] * scanLimitMapR[0]; - - scanColorMapR[0] = (color[scanEdgeR[1]] - color[scanEdgeR[0]]) / (y[scanEdgeR[1]] - y[scanEdgeR[0]]); - scanColorMapR[1] = color[scanEdgeR[0]] - y[scanEdgeR[0]] * scanColorMapR[0]; - } - assert( y[scanEdgeL[0]] < y[scanEdgeL[1]] ); - assert( y[scanEdgeR[0]] < y[scanEdgeR[1]] ); - hasFurtherSegment = gFalse; - } - - yt = Y; - - xa = yt * scanLimitMapL[0] + scanLimitMapL[1]; - xt = yt * scanLimitMapR[0] + scanLimitMapR[1]; - - ca = yt * scanColorMapL[0] + scanColorMapL[1]; - ct = yt * scanColorMapR[0] + scanColorMapR[1]; - - scanLimitL = splashRound(xa); - scanLimitR = splashRound(xt); - - // Ok. Now: init the color interpolation depending on the X - // coordinate inside of the current scanline: - scanColorMap[0] = (scanLimitR == scanLimitL) ? 0. : ((ct - ca) / (scanLimitR - scanLimitL)); - scanColorMap[1] = ca - scanLimitL * scanColorMap[0]; - - // handled by clipping: - // assert( scanLimitL >= 0 && scanLimitR < bitmap->getWidth() ); - assert(scanLimitL <= scanLimitR || abs(scanLimitL - scanLimitR) <= 2); // allow rounding inaccuracies - assert(scanLineOff == Y * rowSize); - - colorinterp = scanColorMap[0] * scanLimitL + scanColorMap[1]; - - bitmapOff = scanLineOff + scanLimitL * colorComps; - if (likely(bitmapOff >= 0)) { - for (int X = scanLimitL; X <= scanLimitR && bitmapOff + colorComps <= bitmapOffLimit; ++X, colorinterp += scanColorMap[0], bitmapOff += colorComps) { - // FIXME : standard rectangular clipping can be done for a - // complete scanline which is faster - // --> see SplashClip and its methods - if (!clip->test(X, Y)) - continue; - - assert(fabs(colorinterp - (scanColorMap[0] * X + scanColorMap[1])) < 1e-10); - assert(bitmapOff == Y * rowSize + colorComps * X && scanLineOff == Y * rowSize); - - shading->getParameterizedColor(colorinterp, bitmapMode, &bitmapData[bitmapOff]); - - // make the shading visible. - // Note that opacity is handled by the bDirectBlit stuff, see - // above for comments and below for implementation. - if (hasAlpha) - bitmapAlpha[Y * bitmapWidth + X] = 255; - } - } - } - } - } else { - if (!bDirectBlit) { - delete blitTarget; - } - return gFalse; - } - - if (!bDirectBlit) { - // ok. Finalize the stuff by blitting the shading into the final - // geometry, this time respecting the rendering pipe. - int W = blitTarget->getWidth(); - int H = blitTarget->getHeight(); - cur = cSrcVal; - - for (int X = 0; X < W; ++X) { - for (int Y = 0; Y < H; ++Y) { - if (!bitmapAlpha[Y * bitmapWidth + X]) - continue; // draw only parts of the shading! - bitmapOff = Y * rowSize + colorComps * X; - - for (int m = 0; m < colorComps; ++m) - cur[m] = bitmapData[bitmapOff + m]; - if (vectorAntialias) { - drawAAPixel(&pipe, X, Y); - } else { - drawPixel(&pipe, X, Y, gTrue); // no clipping - has already been done. - } - } - } - - delete blitTarget; - blitTarget = NULL; - } - - return gTrue; -} - -SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc, - int xDest, int yDest, int w, int h) { - SplashColorPtr p, sp; - Guchar *q; - int x, y, mask, srcMask; - - if (src->mode != bitmap->mode) { - return splashErrModeMismatch; - } - - if (unlikely(!bitmap->data)) { - return splashErrZeroImage; - } - - switch (bitmap->mode) { - case splashModeMono1: - for (y = 0; y < h; ++y) { - p = &bitmap->data[(yDest + y) * bitmap->rowSize + (xDest >> 3)]; - mask = 0x80 >> (xDest & 7); - sp = &src->data[(ySrc + y) * src->rowSize + (xSrc >> 3)]; - srcMask = 0x80 >> (xSrc & 7); - for (x = 0; x < w; ++x) { - if (*sp & srcMask) { - *p |= mask; - } else { - *p &= ~mask; - } - if (!(mask >>= 1)) { - mask = 0x80; - ++p; - } - if (!(srcMask >>= 1)) { - srcMask = 0x80; - ++sp; - } - } - } - break; - case splashModeMono8: - for (y = 0; y < h; ++y) { - p = &bitmap->data[(yDest + y) * bitmap->rowSize + xDest]; - sp = &src->data[(ySrc + y) * bitmap->rowSize + xSrc]; - for (x = 0; x < w; ++x) { - *p++ = *sp++; - } - } - break; - case splashModeRGB8: - case splashModeBGR8: - for (y = 0; y < h; ++y) { - p = &bitmap->data[(yDest + y) * bitmap->rowSize + 3 * xDest]; - sp = &src->data[(ySrc + y) * src->rowSize + 3 * xSrc]; - for (x = 0; x < w; ++x) { - *p++ = *sp++; - *p++ = *sp++; - *p++ = *sp++; - } - } - break; - case splashModeXBGR8: - for (y = 0; y < h; ++y) { - p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; - sp = &src->data[(ySrc + y) * src->rowSize + 4 * xSrc]; - for (x = 0; x < w; ++x) { - *p++ = *sp++; - *p++ = *sp++; - *p++ = *sp++; - *p++ = 255; - sp++; - } - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - for (y = 0; y < h; ++y) { - p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest]; - sp = &src->data[(ySrc + y) * src->rowSize + 4 * xSrc]; - for (x = 0; x < w; ++x) { - *p++ = *sp++; - *p++ = *sp++; - *p++ = *sp++; - *p++ = *sp++; - } - } - break; - case splashModeDeviceN8: - for (y = 0; y < h; ++y) { - p = &bitmap->data[(yDest + y) * bitmap->rowSize + (SPOT_NCOMPS+4) * xDest]; - sp = &src->data[(ySrc + y) * src->rowSize + (SPOT_NCOMPS+4) * xSrc]; - for (x = 0; x < w; ++x) { - for (int cp=0; cp < SPOT_NCOMPS+4; cp++) - *p++ = *sp++; - } - } - break; -#endif - } - - if (bitmap->alpha) { - for (y = 0; y < h; ++y) { - q = &bitmap->alpha[(yDest + y) * bitmap->width + xDest]; - memset(q, 0x00, w); - } - } - - return splashOk; -} - -SplashPath *Splash::makeStrokePath(SplashPath *path, SplashCoord w, - GBool flatten) { -SplashPath *pathIn, *dashPath, *pathOut; - SplashCoord d, dx, dy, wdx, wdy, dxNext, dyNext, wdxNext, wdyNext; - SplashCoord crossprod, dotprod, miter, m; - GBool first, last, closed, hasangle; - int subpathStart0, subpathStart1, seg, i0, i1, j0, j1, k0, k1; - int left0, left1, left2, right0, right1, right2, join0, join1, join2; - int leftFirst, rightFirst, firstPt; - - pathOut = new SplashPath(); - - if (path->length == 0) { - return pathOut; - } - - if (flatten) { - pathIn = flattenPath(path, state->matrix, state->flatness); - if (state->lineDashLength > 0) { - dashPath = makeDashedPath(pathIn); - delete pathIn; - pathIn = dashPath; - if (pathIn->length == 0) { - delete pathIn; - return pathOut; - } - } - } else { - pathIn = path; - } - - subpathStart0 = subpathStart1 = 0; // make gcc happy - seg = 0; // make gcc happy - closed = gFalse; // make gcc happy - left0 = left1 = right0 = right1 = join0 = join1 = 0; // make gcc happy - leftFirst = rightFirst = firstPt = 0; // make gcc happy - - i0 = 0; - for (i1 = i0; - !(pathIn->flags[i1] & splashPathLast) && - i1 + 1 < pathIn->length && - pathIn->pts[i1+1].x == pathIn->pts[i1].x && - pathIn->pts[i1+1].y == pathIn->pts[i1].y; - ++i1) ; - - while (i1 < pathIn->length) { - if ((first = pathIn->flags[i0] & splashPathFirst)) { - subpathStart0 = i0; - subpathStart1 = i1; - seg = 0; - closed = pathIn->flags[i0] & splashPathClosed; - } - j0 = i1 + 1; - if (j0 < pathIn->length) { - for (j1 = j0; - !(pathIn->flags[j1] & splashPathLast) && - j1 + 1 < pathIn->length && - pathIn->pts[j1+1].x == pathIn->pts[j1].x && - pathIn->pts[j1+1].y == pathIn->pts[j1].y; - ++j1) ; - } else { - j1 = j0; - } - if (pathIn->flags[i1] & splashPathLast) { - if (first && state->lineCap == splashLineCapRound) { - // special case: zero-length subpath with round line caps --> - // draw a circle - pathOut->moveTo(pathIn->pts[i0].x + (SplashCoord)0.5 * w, - pathIn->pts[i0].y); - pathOut->curveTo(pathIn->pts[i0].x + (SplashCoord)0.5 * w, - pathIn->pts[i0].y + bezierCircle2 * w, - pathIn->pts[i0].x + bezierCircle2 * w, - pathIn->pts[i0].y + (SplashCoord)0.5 * w, - pathIn->pts[i0].x, - pathIn->pts[i0].y + (SplashCoord)0.5 * w); - pathOut->curveTo(pathIn->pts[i0].x - bezierCircle2 * w, - pathIn->pts[i0].y + (SplashCoord)0.5 * w, - pathIn->pts[i0].x - (SplashCoord)0.5 * w, - pathIn->pts[i0].y + bezierCircle2 * w, - pathIn->pts[i0].x - (SplashCoord)0.5 * w, - pathIn->pts[i0].y); - pathOut->curveTo(pathIn->pts[i0].x - (SplashCoord)0.5 * w, - pathIn->pts[i0].y - bezierCircle2 * w, - pathIn->pts[i0].x - bezierCircle2 * w, - pathIn->pts[i0].y - (SplashCoord)0.5 * w, - pathIn->pts[i0].x, - pathIn->pts[i0].y - (SplashCoord)0.5 * w); - pathOut->curveTo(pathIn->pts[i0].x + bezierCircle2 * w, - pathIn->pts[i0].y - (SplashCoord)0.5 * w, - pathIn->pts[i0].x + (SplashCoord)0.5 * w, - pathIn->pts[i0].y - bezierCircle2 * w, - pathIn->pts[i0].x + (SplashCoord)0.5 * w, - pathIn->pts[i0].y); - pathOut->close(); - } - i0 = j0; - i1 = j1; - continue; - } - last = pathIn->flags[j1] & splashPathLast; - if (last) { - k0 = subpathStart1 + 1; - } else { - k0 = j1 + 1; - } - for (k1 = k0; - !(pathIn->flags[k1] & splashPathLast) && - k1 + 1 < pathIn->length && - pathIn->pts[k1+1].x == pathIn->pts[k1].x && - pathIn->pts[k1+1].y == pathIn->pts[k1].y; - ++k1) ; - - // compute the deltas for segment (i1, j0) -#if USE_FIXEDPOINT - // the 1/d value can be small, which introduces significant - // inaccuracies in fixed point mode - d = splashDist(pathIn->pts[i1].x, pathIn->pts[i1].y, - pathIn->pts[j0].x, pathIn->pts[j0].y); - dx = (pathIn->pts[j0].x - pathIn->pts[i1].x) / d; - dy = (pathIn->pts[j0].y - pathIn->pts[i1].y) / d; -#else - d = (SplashCoord)1 / splashDist(pathIn->pts[i1].x, pathIn->pts[i1].y, - pathIn->pts[j0].x, pathIn->pts[j0].y); - dx = d * (pathIn->pts[j0].x - pathIn->pts[i1].x); - dy = d * (pathIn->pts[j0].y - pathIn->pts[i1].y); -#endif - wdx = (SplashCoord)0.5 * w * dx; - wdy = (SplashCoord)0.5 * w * dy; - - // draw the start cap - pathOut->moveTo(pathIn->pts[i0].x - wdy, pathIn->pts[i0].y + wdx); - if (i0 == subpathStart0) { - firstPt = pathOut->length - 1; - } - if (first && !closed) { - switch (state->lineCap) { - case splashLineCapButt: - pathOut->lineTo(pathIn->pts[i0].x + wdy, pathIn->pts[i0].y - wdx); - break; - case splashLineCapRound: - pathOut->curveTo(pathIn->pts[i0].x - wdy - bezierCircle * wdx, - pathIn->pts[i0].y + wdx - bezierCircle * wdy, - pathIn->pts[i0].x - wdx - bezierCircle * wdy, - pathIn->pts[i0].y - wdy + bezierCircle * wdx, - pathIn->pts[i0].x - wdx, - pathIn->pts[i0].y - wdy); - pathOut->curveTo(pathIn->pts[i0].x - wdx + bezierCircle * wdy, - pathIn->pts[i0].y - wdy - bezierCircle * wdx, - pathIn->pts[i0].x + wdy - bezierCircle * wdx, - pathIn->pts[i0].y - wdx - bezierCircle * wdy, - pathIn->pts[i0].x + wdy, - pathIn->pts[i0].y - wdx); - break; - case splashLineCapProjecting: - pathOut->lineTo(pathIn->pts[i0].x - wdx - wdy, - pathIn->pts[i0].y + wdx - wdy); - pathOut->lineTo(pathIn->pts[i0].x - wdx + wdy, - pathIn->pts[i0].y - wdx - wdy); - pathOut->lineTo(pathIn->pts[i0].x + wdy, - pathIn->pts[i0].y - wdx); - break; - } - } else { - pathOut->lineTo(pathIn->pts[i0].x + wdy, pathIn->pts[i0].y - wdx); - } - - // draw the left side of the segment rectangle - left2 = pathOut->length - 1; - pathOut->lineTo(pathIn->pts[j0].x + wdy, pathIn->pts[j0].y - wdx); - - // draw the end cap - if (last && !closed) { - switch (state->lineCap) { - case splashLineCapButt: - pathOut->lineTo(pathIn->pts[j0].x - wdy, pathIn->pts[j0].y + wdx); - break; - case splashLineCapRound: - pathOut->curveTo(pathIn->pts[j0].x + wdy + bezierCircle * wdx, - pathIn->pts[j0].y - wdx + bezierCircle * wdy, - pathIn->pts[j0].x + wdx + bezierCircle * wdy, - pathIn->pts[j0].y + wdy - bezierCircle * wdx, - pathIn->pts[j0].x + wdx, - pathIn->pts[j0].y + wdy); - pathOut->curveTo(pathIn->pts[j0].x + wdx - bezierCircle * wdy, - pathIn->pts[j0].y + wdy + bezierCircle * wdx, - pathIn->pts[j0].x - wdy + bezierCircle * wdx, - pathIn->pts[j0].y + wdx + bezierCircle * wdy, - pathIn->pts[j0].x - wdy, - pathIn->pts[j0].y + wdx); - break; - case splashLineCapProjecting: - pathOut->lineTo(pathIn->pts[j0].x + wdy + wdx, - pathIn->pts[j0].y - wdx + wdy); - pathOut->lineTo(pathIn->pts[j0].x - wdy + wdx, - pathIn->pts[j0].y + wdx + wdy); - pathOut->lineTo(pathIn->pts[j0].x - wdy, - pathIn->pts[j0].y + wdx); - break; - } - } else { - pathOut->lineTo(pathIn->pts[j0].x - wdy, pathIn->pts[j0].y + wdx); - } - - // draw the right side of the segment rectangle - // (NB: if stroke adjustment is enabled, the closepath operation MUST - // add a segment because this segment is used for a hint) - right2 = pathOut->length - 1; - pathOut->close(state->strokeAdjust); - - // draw the join - join2 = pathOut->length; - if (!last || closed) { - - // compute the deltas for segment (j1, k0) -#if USE_FIXEDPOINT - // the 1/d value can be small, which introduces significant - // inaccuracies in fixed point mode - d = splashDist(pathIn->pts[j1].x, pathIn->pts[j1].y, - pathIn->pts[k0].x, pathIn->pts[k0].y); - dxNext = (pathIn->pts[k0].x - pathIn->pts[j1].x) / d; - dyNext = (pathIn->pts[k0].y - pathIn->pts[j1].y) / d; -#else - d = (SplashCoord)1 / splashDist(pathIn->pts[j1].x, pathIn->pts[j1].y, - pathIn->pts[k0].x, pathIn->pts[k0].y); - dxNext = d * (pathIn->pts[k0].x - pathIn->pts[j1].x); - dyNext = d * (pathIn->pts[k0].y - pathIn->pts[j1].y); -#endif - wdxNext = (SplashCoord)0.5 * w * dxNext; - wdyNext = (SplashCoord)0.5 * w * dyNext; - - // compute the join parameters - crossprod = dx * dyNext - dy * dxNext; - dotprod = -(dx * dxNext + dy * dyNext); - hasangle = crossprod != 0 || dx * dxNext < 0 || dy * dyNext < 0; - if (dotprod > 0.9999) { - // avoid a divide-by-zero -- set miter to something arbitrary - // such that sqrt(miter) will exceed miterLimit (and m is never - // used in that situation) - // (note: the comparison value (0.9999) has to be less than - // 1-epsilon, where epsilon is the smallest value - // representable in the fixed point format) - miter = (state->miterLimit + 1) * (state->miterLimit + 1); - m = 0; - } else { - miter = (SplashCoord)2 / ((SplashCoord)1 - dotprod); - if (miter < 1) { - // this can happen because of floating point inaccuracies - miter = 1; - } - m = splashSqrt(miter - 1); - } - - // round join - if (hasangle && state->lineJoin == splashLineJoinRound) { - pathOut->moveTo(pathIn->pts[j0].x + (SplashCoord)0.5 * w, - pathIn->pts[j0].y); - pathOut->curveTo(pathIn->pts[j0].x + (SplashCoord)0.5 * w, - pathIn->pts[j0].y + bezierCircle2 * w, - pathIn->pts[j0].x + bezierCircle2 * w, - pathIn->pts[j0].y + (SplashCoord)0.5 * w, - pathIn->pts[j0].x, - pathIn->pts[j0].y + (SplashCoord)0.5 * w); - pathOut->curveTo(pathIn->pts[j0].x - bezierCircle2 * w, - pathIn->pts[j0].y + (SplashCoord)0.5 * w, - pathIn->pts[j0].x - (SplashCoord)0.5 * w, - pathIn->pts[j0].y + bezierCircle2 * w, - pathIn->pts[j0].x - (SplashCoord)0.5 * w, - pathIn->pts[j0].y); - pathOut->curveTo(pathIn->pts[j0].x - (SplashCoord)0.5 * w, - pathIn->pts[j0].y - bezierCircle2 * w, - pathIn->pts[j0].x - bezierCircle2 * w, - pathIn->pts[j0].y - (SplashCoord)0.5 * w, - pathIn->pts[j0].x, - pathIn->pts[j0].y - (SplashCoord)0.5 * w); - pathOut->curveTo(pathIn->pts[j0].x + bezierCircle2 * w, - pathIn->pts[j0].y - (SplashCoord)0.5 * w, - pathIn->pts[j0].x + (SplashCoord)0.5 * w, - pathIn->pts[j0].y - bezierCircle2 * w, - pathIn->pts[j0].x + (SplashCoord)0.5 * w, - pathIn->pts[j0].y); - - } else if (hasangle) { - pathOut->moveTo(pathIn->pts[j0].x, pathIn->pts[j0].y); - - // angle < 180 - if (crossprod < 0) { - pathOut->lineTo(pathIn->pts[j0].x - wdyNext, - pathIn->pts[j0].y + wdxNext); - // miter join inside limit - if (state->lineJoin == splashLineJoinMiter && - splashSqrt(miter) <= state->miterLimit) { - pathOut->lineTo(pathIn->pts[j0].x - wdy + wdx * m, - pathIn->pts[j0].y + wdx + wdy * m); - pathOut->lineTo(pathIn->pts[j0].x - wdy, - pathIn->pts[j0].y + wdx); - // bevel join or miter join outside limit - } else { - pathOut->lineTo(pathIn->pts[j0].x - wdy, - pathIn->pts[j0].y + wdx); - } - - // angle >= 180 - } else { - pathOut->lineTo(pathIn->pts[j0].x + wdy, - pathIn->pts[j0].y - wdx); - // miter join inside limit - if (state->lineJoin == splashLineJoinMiter && - splashSqrt(miter) <= state->miterLimit) { - pathOut->lineTo(pathIn->pts[j0].x + wdy + wdx * m, - pathIn->pts[j0].y - wdx + wdy * m); - pathOut->lineTo(pathIn->pts[j0].x + wdyNext, - pathIn->pts[j0].y - wdxNext); - // bevel join or miter join outside limit - } else { - pathOut->lineTo(pathIn->pts[j0].x + wdyNext, - pathIn->pts[j0].y - wdxNext); - } - } - } - - pathOut->close(); - } - - // add stroke adjustment hints - if (state->strokeAdjust) { - if (seg == 0 && !closed) { - if (state->lineCap == splashLineCapButt) { - pathOut->addStrokeAdjustHint(firstPt, left2 + 1, - firstPt, firstPt + 1); - if (last) { - pathOut->addStrokeAdjustHint(firstPt, left2 + 1, - left2 + 1, left2 + 2); - } - } else if (state->lineCap == splashLineCapProjecting) { - if (last) { - pathOut->addStrokeAdjustHint(firstPt + 1, left2 + 2, - firstPt + 1, firstPt + 2); - pathOut->addStrokeAdjustHint(firstPt + 1, left2 + 2, - left2 + 2, left2 + 3); - } else { - pathOut->addStrokeAdjustHint(firstPt + 1, left2 + 1, - firstPt + 1, firstPt + 2); - } - } - } - if (seg >= 1) { - if (seg >= 2) { - pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); - pathOut->addStrokeAdjustHint(left1, right1, join0, left2); - } else { - pathOut->addStrokeAdjustHint(left1, right1, firstPt, left2); - } - pathOut->addStrokeAdjustHint(left1, right1, right2 + 1, right2 + 1); - } - left0 = left1; - left1 = left2; - right0 = right1; - right1 = right2; - join0 = join1; - join1 = join2; - if (seg == 0) { - leftFirst = left2; - rightFirst = right2; - } - if (last) { - if (seg >= 2) { - pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); - pathOut->addStrokeAdjustHint(left1, right1, - join0, pathOut->length - 1); - } else { - pathOut->addStrokeAdjustHint(left1, right1, - firstPt, pathOut->length - 1); - } - if (closed) { - pathOut->addStrokeAdjustHint(left1, right1, firstPt, leftFirst); - pathOut->addStrokeAdjustHint(left1, right1, - rightFirst + 1, rightFirst + 1); - pathOut->addStrokeAdjustHint(leftFirst, rightFirst, - left1 + 1, right1); - pathOut->addStrokeAdjustHint(leftFirst, rightFirst, - join1, pathOut->length - 1); - } - if (!closed && seg > 0) { - if (state->lineCap == splashLineCapButt) { - pathOut->addStrokeAdjustHint(left1 - 1, left1 + 1, - left1 + 1, left1 + 2); - } else if (state->lineCap == splashLineCapProjecting) { - pathOut->addStrokeAdjustHint(left1 - 1, left1 + 2, - left1 + 2, left1 + 3); - } - } - } - } - - i0 = j0; - i1 = j1; - ++seg; - } - - if (pathIn != path) { - delete pathIn; - } - - return pathOut; -} - -void Splash::dumpPath(SplashPath *path) { - int i; - - for (i = 0; i < path->length; ++i) { - printf(" %3d: x=%8.2f y=%8.2f%s%s%s%s\n", - i, (double)path->pts[i].x, (double)path->pts[i].y, - (path->flags[i] & splashPathFirst) ? " first" : "", - (path->flags[i] & splashPathLast) ? " last" : "", - (path->flags[i] & splashPathClosed) ? " closed" : "", - (path->flags[i] & splashPathCurve) ? " curve" : ""); - } -} - -void Splash::dumpXPath(SplashXPath *path) { - int i; - - for (i = 0; i < path->length; ++i) { - printf(" %4d: x0=%8.2f y0=%8.2f x1=%8.2f y1=%8.2f %s%s%s\n", - i, (double)path->segs[i].x0, (double)path->segs[i].y0, - (double)path->segs[i].x1, (double)path->segs[i].y1, - (path->segs[i].flags & splashXPathHoriz) ? "H" : " ", - (path->segs[i].flags & splashXPathVert) ? "V" : " ", - (path->segs[i].flags & splashXPathFlip) ? "P" : " "); - } -} - -SplashError Splash::shadedFill(SplashPath *path, GBool hasBBox, - SplashPattern *pattern) { - SplashPipe pipe; - SplashXPath *xPath; - SplashXPathScanner *scanner; - int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y; - SplashClipResult clipRes; - - if (vectorAntialias && aaBuf == NULL) { // should not happen, but to be secure - return splashErrGeneric; - } - if (path->length == 0) { - return splashErrEmptyPath; - } - xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue); - if (vectorAntialias) { - xPath->aaScale(); - } - xPath->sort(); - yMinI = state->clip->getYMinI(); - yMaxI = state->clip->getYMaxI(); - if (vectorAntialias && !inShading) { - yMinI = yMinI * splashAASize; - yMaxI = (yMaxI + 1) * splashAASize - 1; - } - scanner = new SplashXPathScanner(xPath, gFalse, yMinI, yMaxI); - - // get the min and max x and y values - if (vectorAntialias) { - scanner->getBBoxAA(&xMinI, &yMinI, &xMaxI, &yMaxI); - } else { - scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI); - } - - // check clipping - if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI)) != splashClipAllOutside) { - // limit the y range - if (yMinI < state->clip->getYMinI()) { - yMinI = state->clip->getYMinI(); - } - if (yMaxI > state->clip->getYMaxI()) { - yMaxI = state->clip->getYMaxI(); - } - - pipeInit(&pipe, 0, yMinI, pattern, NULL, (Guchar)splashRound(state->fillAlpha * 255), vectorAntialias && !hasBBox, gFalse); - - // draw the spans - if (vectorAntialias) { - for (y = yMinI; y <= yMaxI; ++y) { - scanner->renderAALine(aaBuf, &x0, &x1, y); - if (clipRes != splashClipAllInside) { - state->clip->clipAALine(aaBuf, &x0, &x1, y); - } -#if splashAASize == 4 - if (!hasBBox && y > yMinI && y < yMaxI) { - // correct shape on left side if clip is - // vertical through the middle of shading: - Guchar *p0, *p1, *p2, *p3; - Guchar c1, c2, c3, c4; - p0 = aaBuf->getDataPtr() + (x0 >> 1); - p1 = p0 + aaBuf->getRowSize(); - p2 = p1 + aaBuf->getRowSize(); - p3 = p2 + aaBuf->getRowSize(); - if (x0 & 1) { - c1 = (*p0 & 0x0f); c2 =(*p1 & 0x0f); c3 = (*p2 & 0x0f) ; c4 = (*p3 & 0x0f); - } else { - c1 = (*p0 >> 4); c2 = (*p1 >> 4); c3 = (*p2 >> 4); c4 = (*p3 >> 4); - } - if ( (c1 & 0x03) == 0x03 && (c2 & 0x03) == 0x03 && (c3 & 0x03) == 0x03 && (c4 & 0x03) == 0x03 - && c1 == c2 && c2 == c3 && c3 == c4 && - pattern->testPosition(x0 - 1, y) ) - { - Guchar shapeCorrection = (x0 & 1) ? 0x0f : 0xf0; - *p0 |= shapeCorrection; - *p1 |= shapeCorrection; - *p2 |= shapeCorrection; - *p3 |= shapeCorrection; - } - // correct shape on right side if clip is - // through the middle of shading: - p0 = aaBuf->getDataPtr() + (x1 >> 1); - p1 = p0 + aaBuf->getRowSize(); - p2 = p1 + aaBuf->getRowSize(); - p3 = p2 + aaBuf->getRowSize(); - if (x1 & 1) { - c1 = (*p0 & 0x0f); c2 =(*p1 & 0x0f); c3 = (*p2 & 0x0f) ; c4 = (*p3 & 0x0f); - } else { - c1 = (*p0 >> 4); c2 = (*p1 >> 4); c3 = (*p2 >> 4); c4 = (*p3 >> 4); - } - - if ( (c1 & 0xc) == 0x0c && (c2 & 0x0c) == 0x0c && (c3 & 0x0c) == 0x0c && (c4 & 0x0c) == 0x0c - && c1 == c2 && c2 == c3 && c3 == c4 && - pattern->testPosition(x1 + 1, y) ) - { - Guchar shapeCorrection = (x1 & 1) ? 0x0f : 0xf0; - *p0 |= shapeCorrection; - *p1 |= shapeCorrection; - *p2 |= shapeCorrection; - *p3 |= shapeCorrection; - } - } -#endif - drawAALine(&pipe, x0, x1, y); - } - } else { - SplashClipResult clipRes2; - for (y = yMinI; y <= yMaxI; ++y) { - while (scanner->getNextSpan(y, &x0, &x1)) { - if (clipRes == splashClipAllInside) { - drawSpan(&pipe, x0, x1, y, gTrue); - } else { - // limit the x range - if (x0 < state->clip->getXMinI()) { - x0 = state->clip->getXMinI(); - } - if (x1 > state->clip->getXMaxI()) { - x1 = state->clip->getXMaxI(); - } - clipRes2 = state->clip->testSpan(x0, x1, y); - drawSpan(&pipe, x0, x1, y, clipRes2 == splashClipAllInside); - } - } - } - } - } - opClipRes = clipRes; - - delete scanner; - delete xPath; - return splashOk; -} diff --git a/source/libs/poppler/poppler-src/splash/Splash.h b/source/libs/poppler/poppler-src/splash/Splash.h deleted file mode 100644 index 3ca15c38bce8a89c88b80d1698116ed7ebdedf5b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/Splash.h +++ /dev/null @@ -1,431 +0,0 @@ -//======================================================================== -// -// Splash.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> -// Copyright (C) 2007, 2011 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2010-2013, 2015 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> -// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com> -// -// 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 -// -//======================================================================== - -#ifndef SPLASH_H -#define SPLASH_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include <stddef.h> -#include "SplashTypes.h" -#include "SplashClip.h" -#include "SplashPattern.h" - -class SplashBitmap; -struct SplashGlyphBitmap; -class SplashState; -class SplashScreen; -class SplashPath; -class SplashXPath; -class SplashFont; -struct SplashPipe; - -//------------------------------------------------------------------------ - -// Retrieves the next line of pixels in an image mask. Normally, -// fills in *<line> and returns true. If the image stream is -// exhausted, returns false. -typedef GBool (*SplashImageMaskSource)(void *data, SplashColorPtr pixel); - -// Retrieves the next line of pixels in an image. Normally, fills in -// *<line> and returns true. If the image stream is exhausted, -// returns false. -typedef GBool (*SplashImageSource)(void *data, SplashColorPtr colorLine, - Guchar *alphaLine); - -// Use ICCColorSpace to transform a bitmap -typedef void (*SplashICCTransform)(void *data, SplashBitmap *bitmap); - -//------------------------------------------------------------------------ - -enum SplashPipeResultColorCtrl { -#if SPLASH_CMYK - splashPipeResultColorNoAlphaBlendCMYK, - splashPipeResultColorNoAlphaBlendDeviceN, -#endif - splashPipeResultColorNoAlphaBlendRGB, - splashPipeResultColorNoAlphaBlendMono, - splashPipeResultColorAlphaNoBlendMono, - splashPipeResultColorAlphaNoBlendRGB, -#if SPLASH_CMYK - splashPipeResultColorAlphaNoBlendCMYK, - splashPipeResultColorAlphaNoBlendDeviceN, -#endif - splashPipeResultColorAlphaBlendMono, - splashPipeResultColorAlphaBlendRGB -#if SPLASH_CMYK - , - splashPipeResultColorAlphaBlendCMYK, - splashPipeResultColorAlphaBlendDeviceN -#endif -}; - -//------------------------------------------------------------------------ -// Splash -//------------------------------------------------------------------------ - -class Splash { -public: - - // Create a new rasterizer object. - Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, - SplashScreenParams *screenParams = NULL); - Splash(SplashBitmap *bitmapA, GBool vectorAntialiasA, - SplashScreen *screenA); - - ~Splash(); - - //----- state read - - SplashCoord *getMatrix(); - SplashPattern *getStrokePattern(); - SplashPattern *getFillPattern(); - SplashScreen *getScreen(); - SplashBlendFunc getBlendFunc(); - SplashCoord getStrokeAlpha(); - SplashCoord getFillAlpha(); - SplashCoord getLineWidth(); - int getLineCap(); - int getLineJoin(); - SplashCoord getMiterLimit(); - SplashCoord getFlatness(); - SplashCoord *getLineDash(); - int getLineDashLength(); - SplashCoord getLineDashPhase(); - GBool getStrokeAdjust(); - SplashClip *getClip(); - SplashBitmap *getSoftMask(); - GBool getInNonIsolatedGroup(); - - //----- state write - - void setMatrix(SplashCoord *matrix); - void setStrokePattern(SplashPattern *strokeColor); - void setFillPattern(SplashPattern *fillColor); - void setScreen(SplashScreen *screen); - void setBlendFunc(SplashBlendFunc func); - void setStrokeAlpha(SplashCoord alpha); - void setFillAlpha(SplashCoord alpha); - void setPatternAlpha(SplashCoord strokeAlpha, SplashCoord fillAlpha); - void clearPatternAlpha(); - void setFillOverprint(GBool fop); - void setStrokeOverprint(GBool sop); - void setOverprintMode(int opm); - void setLineWidth(SplashCoord lineWidth); - void setLineCap(int lineCap); - void setLineJoin(int lineJoin); - void setMiterLimit(SplashCoord miterLimit); - void setFlatness(SplashCoord flatness); - // the <lineDash> array will be copied - void setLineDash(SplashCoord *lineDash, int lineDashLength, - SplashCoord lineDashPhase); - void setStrokeAdjust(GBool strokeAdjust); - // NB: uses transformed coordinates. - void clipResetToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1); - // NB: uses transformed coordinates. - SplashError clipToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1); - // NB: uses untransformed coordinates. - SplashError clipToPath(SplashPath *path, GBool eo); - void setSoftMask(SplashBitmap *softMask); - void setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA, - int alpha0XA, int alpha0YA); - void setTransfer(Guchar *red, Guchar *green, Guchar *blue, Guchar *gray); - void setOverprintMask(Guint overprintMask, GBool additive); - - //----- state save/restore - - void saveState(); - SplashError restoreState(); - - //----- drawing operations - - // Fill the bitmap with <color>. This is not subject to clipping. - void clear(SplashColorPtr color, Guchar alpha = 0x00); - - // Stroke a path using the current stroke pattern. - SplashError stroke(SplashPath *path); - - // Fill a path using the current fill pattern. - SplashError fill(SplashPath *path, GBool eo); - - // Fill a path, XORing with the current fill pattern. - SplashError xorFill(SplashPath *path, GBool eo); - - // Draw a character, using the current fill pattern. - SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font); - - // Draw a glyph, using the current fill pattern. This function does - // not free any data, i.e., it ignores glyph->freeData. - void fillGlyph(SplashCoord x, SplashCoord y, - SplashGlyphBitmap *glyph); - - // Draws an image mask using the fill color. This will read <h> - // lines of <w> pixels from <src>, starting with the top line. "1" - // pixels will be drawn with the current fill color; "0" pixels are - // transparent. The matrix: - // [ mat[0] mat[1] 0 ] - // [ mat[2] mat[3] 0 ] - // [ mat[4] mat[5] 1 ] - // maps a unit square to the desired destination for the image, in - // PostScript style: - // [x' y' 1] = [x y 1] * mat - // Note that the Splash y axis points downward, and the image source - // is assumed to produce pixels in raster order, starting from the - // top line. - SplashError fillImageMask(SplashImageMaskSource src, void *srcData, - int w, int h, SplashCoord *mat, - GBool glyphMode); - - // Draw an image. This will read <h> lines of <w> pixels from - // <src>, starting with the top line. These pixels are assumed to - // be in the source mode, <srcMode>. If <srcAlpha> is true, the - // alpha values returned by <src> are used; otherwise they are - // ignored. The following combinations of source and target modes - // are supported: - // source target - // ------ ------ - // Mono1 Mono1 - // Mono8 Mono1 -- with dithering - // Mono8 Mono8 - // RGB8 RGB8 - // BGR8 BGR8 - // CMYK8 CMYK8 - // The matrix behaves as for fillImageMask. - SplashError drawImage(SplashImageSource src, SplashICCTransform tf, void *srcData, - SplashColorMode srcMode, GBool srcAlpha, - int w, int h, SplashCoord *mat, GBool interpolate, - GBool tilingPattern = gFalse); - - // Composite a rectangular region from <src> onto this Splash - // object. - SplashError composite(SplashBitmap *src, int xSrc, int ySrc, - int xDest, int yDest, int w, int h, - GBool noClip, GBool nonIsolated, - GBool knockout = gFalse, SplashCoord knockoutOpacity = 1.0); - - // Composite this Splash object onto a background color. The - // background alpha is assumed to be 1. - void compositeBackground(SplashColorPtr color); - - // Copy a rectangular region from <src> onto the bitmap belonging to - // this Splash object. The destination alpha values are all set to - // zero. - SplashError blitTransparent(SplashBitmap *src, int xSrc, int ySrc, - int xDest, int yDest, int w, int h); - void blitImage(SplashBitmap *src, GBool srcAlpha, int xDest, int yDest); - - //----- misc - - // Construct a path for a stroke, given the path to be stroked and - // the line width <w>. All other stroke parameters are taken from - // the current state. If <flatten> is true, this function will - // first flatten the path and handle the linedash. - SplashPath *makeStrokePath(SplashPath *path, SplashCoord w, - GBool flatten = gTrue); - - // Return the associated bitmap. - SplashBitmap *getBitmap() { return bitmap; } - - // Set the minimum line width. - void setMinLineWidth(SplashCoord w) { minLineWidth = w; } - - // Setter/Getter for thin line mode - void setThinLineMode(SplashThinLineMode thinLineModeA) { thinLineMode = thinLineModeA; } - SplashThinLineMode getThinLineMode() { return thinLineMode; } - - // Get a bounding box which includes all modifications since the - // last call to clearModRegion. - void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax) - { *xMin = modXMin; *yMin = modYMin; *xMax = modXMax; *yMax = modYMax; } - - // Clear the modified region bounding box. - void clearModRegion(); - - // Get clipping status for the last drawing operation subject to - // clipping. - SplashClipResult getClipRes() { return opClipRes; } - - // Toggle debug mode on or off. - void setDebugMode(GBool debugModeA) { debugMode = debugModeA; } - -#if 1 //~tmp: turn off anti-aliasing temporarily - void setInShading(GBool sh) { inShading = sh; } - GBool getVectorAntialias() { return vectorAntialias; } - void setVectorAntialias(GBool vaa) { vectorAntialias = vaa; } -#endif - - // Do shaded fills with dynamic patterns - SplashError shadedFill(SplashPath *path, GBool hasBBox, - SplashPattern *pattern); - // Draw a gouraud triangle shading. - GBool gouraudTriangleShadedFill(SplashGouraudColor *shading); - -private: - - void pipeInit(SplashPipe *pipe, int x, int y, - SplashPattern *pattern, SplashColorPtr cSrc, - Guchar aInput, GBool usesShape, - GBool nonIsolatedGroup, - GBool knockout = gFalse, Guchar knockoutOpacity = 255); - void pipeRun(SplashPipe *pipe); - void pipeRunSimpleMono1(SplashPipe *pipe); - void pipeRunSimpleMono8(SplashPipe *pipe); - void pipeRunSimpleRGB8(SplashPipe *pipe); - void pipeRunSimpleXBGR8(SplashPipe *pipe); - void pipeRunSimpleBGR8(SplashPipe *pipe); -#if SPLASH_CMYK - void pipeRunSimpleCMYK8(SplashPipe *pipe); - void pipeRunSimpleDeviceN8(SplashPipe *pipe); -#endif - void pipeRunAAMono1(SplashPipe *pipe); - void pipeRunAAMono8(SplashPipe *pipe); - void pipeRunAARGB8(SplashPipe *pipe); - void pipeRunAAXBGR8(SplashPipe *pipe); - void pipeRunAABGR8(SplashPipe *pipe); -#if SPLASH_CMYK - void pipeRunAACMYK8(SplashPipe *pipe); - void pipeRunAADeviceN8(SplashPipe *pipe); -#endif - void pipeSetXY(SplashPipe *pipe, int x, int y); - void pipeIncX(SplashPipe *pipe); - void drawPixel(SplashPipe *pipe, int x, int y, GBool noClip); - void drawAAPixelInit(); - void drawAAPixel(SplashPipe *pipe, int x, int y); - void drawSpan(SplashPipe *pipe, int x0, int x1, int y, GBool noClip); - void drawAALine(SplashPipe *pipe, int x0, int x1, int y, GBool adjustLine = gFalse, Guchar lineOpacity = 0); - void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi, - SplashCoord *xo, SplashCoord *yo); - void updateModX(int x); - void updateModY(int y); - void strokeNarrow(SplashPath *path); - void strokeWide(SplashPath *path, SplashCoord w); - SplashPath *flattenPath(SplashPath *path, SplashCoord *matrix, - SplashCoord flatness); - void flattenCurve(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1, - SplashCoord x2, SplashCoord y2, - SplashCoord x3, SplashCoord y3, - SplashCoord *matrix, SplashCoord flatness2, - SplashPath *fPath); - SplashPath *makeDashedPath(SplashPath *xPath); - void getBBoxFP(SplashPath *path, SplashCoord *xMinA, SplashCoord *yMinA, SplashCoord *xMaxA, SplashCoord *yMaxA); - SplashError fillWithPattern(SplashPath *path, GBool eo, - SplashPattern *pattern, SplashCoord alpha); - GBool pathAllOutside(SplashPath *path); - void fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noclip); - void arbitraryTransformMask(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - SplashCoord *mat, GBool glyphMode); - SplashBitmap *scaleMask(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight); - void scaleMaskYdXd(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void scaleMaskYdXu(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void scaleMaskYuXd(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void scaleMaskYuXu(SplashImageMaskSource src, void *srcData, - int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void blitMask(SplashBitmap *src, int xDest, int yDest, - SplashClipResult clipRes); - SplashError arbitraryTransformImage(SplashImageSource src, SplashICCTransform tf, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, - int srcWidth, int srcHeight, - SplashCoord *mat, GBool interpolate, GBool tilingPattern = gFalse); - SplashBitmap *scaleImage(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, GBool interpolate, GBool tilingPattern = gFalse); - void scaleImageYdXd(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void scaleImageYdXu(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void scaleImageYuXd(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void scaleImageYuXu(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void scaleImageYuXuBilinear(SplashImageSource src, void *srcData, - SplashColorMode srcMode, int nComps, - GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, - SplashBitmap *dest); - void vertFlipImage(SplashBitmap *img, int width, int height, - int nComps); - void blitImage(SplashBitmap *src, GBool srcAlpha, int xDest, int yDest, - SplashClipResult clipRes); - void blitImageClipped(SplashBitmap *src, GBool srcAlpha, - int xSrc, int ySrc, int xDest, int yDest, - int w, int h); - void dumpPath(SplashPath *path); - void dumpXPath(SplashXPath *path); - - static SplashPipeResultColorCtrl pipeResultColorNoAlphaBlend[]; - static SplashPipeResultColorCtrl pipeResultColorAlphaNoBlend[]; - static SplashPipeResultColorCtrl pipeResultColorAlphaBlend[]; - static int pipeNonIsoGroupCorrection[]; - - SplashBitmap *bitmap; - SplashState *state; - SplashBitmap *aaBuf; - int aaBufY; - SplashBitmap *alpha0Bitmap; // for non-isolated groups, this is the - // bitmap containing the alpha0 values - int alpha0X, alpha0Y; // offset within alpha0Bitmap - SplashCoord aaGamma[splashAASize * splashAASize + 1]; - SplashCoord minLineWidth; - SplashThinLineMode thinLineMode; - int modXMin, modYMin, modXMax, modYMax; - SplashClipResult opClipRes; - GBool vectorAntialias; - GBool inShading; - GBool debugMode; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashBitmap.cc b/source/libs/poppler/poppler-src/splash/SplashBitmap.cc deleted file mode 100644 index 060a858eeea02f071b148e49f59d4fdcacc353c9..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashBitmap.cc +++ /dev/null @@ -1,853 +0,0 @@ -//======================================================================== -// -// SplashBitmap.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006, 2009, 2010, 2012, 2015 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> -// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> -// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010, 2012, 2017 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org> -// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> -// Copyright (C) 2010, 2015 William Bader <williambader@hotmail.com> -// Copyright (C) 2011-2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2012 Anthony Wesley <awesley@smartnetworks.com.au> -// Copyright (C) 2015 Adam Reichold <adamreichold@myopera.com> -// Copyright (C) 2016 Kenji Uno <ku@digitaldolphins.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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <limits.h> -#include "goo/gmem.h" -#include "SplashErrorCodes.h" -#include "SplashBitmap.h" -#include "poppler/Error.h" -#include "goo/JpegWriter.h" -#include "goo/PNGWriter.h" -#include "goo/TiffWriter.h" -#include "goo/ImgWriter.h" -#include "goo/GooList.h" - -//------------------------------------------------------------------------ -// SplashBitmap -//------------------------------------------------------------------------ - -SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPadA, - SplashColorMode modeA, GBool alphaA, - GBool topDown, GooList *separationListA) { - width = widthA; - height = heightA; - mode = modeA; - rowPad = rowPadA; - switch (mode) { - case splashModeMono1: - if (width > 0) { - rowSize = (width + 7) >> 3; - } else { - rowSize = -1; - } - break; - case splashModeMono8: - if (width > 0) { - rowSize = width; - } else { - rowSize = -1; - } - break; - case splashModeRGB8: - case splashModeBGR8: - if (width > 0 && width <= INT_MAX / 3) { - rowSize = width * 3; - } else { - rowSize = -1; - } - break; - case splashModeXBGR8: - if (width > 0 && width <= INT_MAX / 4) { - rowSize = width * 4; - } else { - rowSize = -1; - } - break; -#if SPLASH_CMYK - case splashModeCMYK8: - if (width > 0 && width <= INT_MAX / 4) { - rowSize = width * 4; - } else { - rowSize = -1; - } - break; - case splashModeDeviceN8: - if (width > 0 && width <= INT_MAX / 4) { - rowSize = width * (SPOT_NCOMPS + 4); - } else { - rowSize = -1; - } - break; -#endif - } - if (rowSize > 0) { - rowSize += rowPad - 1; - rowSize -= rowSize % rowPad; - } - data = (SplashColorPtr)gmallocn_checkoverflow(rowSize, height); - if (data != NULL) { - if (!topDown) { - data += (height - 1) * rowSize; - rowSize = -rowSize; - } - if (alphaA) { - alpha = (Guchar *)gmallocn(width, height); - } else { - alpha = NULL; - } - } else { - alpha = NULL; - } - separationList = new GooList(); - if (separationListA != NULL) - for (int i = 0; i < separationListA->getLength(); i++) - separationList->append(((GfxSeparationColorSpace *) separationListA->get(i))->copy()); -} - -SplashBitmap *SplashBitmap::copy(SplashBitmap *src) { - SplashBitmap *result = new SplashBitmap(src->getWidth(), src->getHeight(), src->getRowPad(), - src->getMode(), src->getAlphaPtr() != NULL, src->getRowSize() >= 0, src->getSeparationList()); - Guchar *dataSource = src->getDataPtr(); - Guchar *dataDest = result->getDataPtr(); - int amount = src->getRowSize(); - if (amount < 0) { - dataSource = dataSource + (src->getHeight() - 1) * amount; - dataDest = dataDest + (src->getHeight() - 1) * amount; - amount *= -src->getHeight(); - } else { - amount *= src->getHeight(); - } - memcpy(dataDest, dataSource, amount); - if (src->getAlphaPtr() != NULL) { - memcpy(result->getAlphaPtr(), src->getAlphaPtr(), src->getWidth() * src->getHeight()); - } - return result; -} - -SplashBitmap::~SplashBitmap() { - if (data) { - if (rowSize < 0) { - gfree(data + (height - 1) * rowSize); - } else { - gfree(data); - } - } - gfree(alpha); - deleteGooList(separationList, GfxSeparationColorSpace); -} - - -SplashError SplashBitmap::writePNMFile(char *fileName) { - FILE *f; - SplashError e; - - if (!(f = fopen(fileName, "wb"))) { - return splashErrOpenFile; - } - - e = this->writePNMFile(f); - - fclose(f); - return e; -} - - -SplashError SplashBitmap::writePNMFile(FILE *f) { - SplashColorPtr row, p; - int x, y; - - switch (mode) { - - case splashModeMono1: - fprintf(f, "P4\n%d %d\n", width, height); - row = data; - for (y = 0; y < height; ++y) { - p = row; - for (x = 0; x < width; x += 8) { - fputc(*p ^ 0xff, f); - ++p; - } - row += rowSize; - } - break; - - case splashModeMono8: - fprintf(f, "P5\n%d %d\n255\n", width, height); - row = data; - for (y = 0; y < height; ++y) { - fwrite(row, 1, width, f); - row += rowSize; - } - break; - - case splashModeRGB8: - fprintf(f, "P6\n%d %d\n255\n", width, height); - row = data; - for (y = 0; y < height; ++y) { - fwrite(row, 1, 3 * width, f); - row += rowSize; - } - break; - - case splashModeXBGR8: - fprintf(f, "P6\n%d %d\n255\n", width, height); - row = data; - for (y = 0; y < height; ++y) { - p = row; - for (x = 0; x < width; ++x) { - fputc(splashBGR8R(p), f); - fputc(splashBGR8G(p), f); - fputc(splashBGR8B(p), f); - p += 4; - } - row += rowSize; - } - break; - - - case splashModeBGR8: - fprintf(f, "P6\n%d %d\n255\n", width, height); - row = data; - for (y = 0; y < height; ++y) { - p = row; - for (x = 0; x < width; ++x) { - fputc(splashBGR8R(p), f); - fputc(splashBGR8G(p), f); - fputc(splashBGR8B(p), f); - p += 3; - } - row += rowSize; - } - break; - -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - // PNM doesn't support CMYK - error(errInternal, -1, "unsupported SplashBitmap mode"); - return splashErrGeneric; - break; -#endif - } - return splashOk; -} - -SplashError SplashBitmap::writeAlphaPGMFile(char *fileName) { - FILE *f; - - if (!alpha) { - return splashErrModeMismatch; - } - if (!(f = fopen(fileName, "wb"))) { - return splashErrOpenFile; - } - fprintf(f, "P5\n%d %d\n255\n", width, height); - fwrite(alpha, 1, width * height, f); - fclose(f); - return splashOk; -} - -void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) { - SplashColorPtr p; - - if (y < 0 || y >= height || x < 0 || x >= width || !data) { - return; - } - switch (mode) { - case splashModeMono1: - p = &data[y * rowSize + (x >> 3)]; - pixel[0] = (p[0] & (0x80 >> (x & 7))) ? 0xff : 0x00; - break; - case splashModeMono8: - p = &data[y * rowSize + x]; - pixel[0] = p[0]; - break; - case splashModeRGB8: - p = &data[y * rowSize + 3 * x]; - pixel[0] = p[0]; - pixel[1] = p[1]; - pixel[2] = p[2]; - break; - case splashModeXBGR8: - p = &data[y * rowSize + 4 * x]; - pixel[0] = p[2]; - pixel[1] = p[1]; - pixel[2] = p[0]; - pixel[3] = p[3]; - break; - case splashModeBGR8: - p = &data[y * rowSize + 3 * x]; - pixel[0] = p[2]; - pixel[1] = p[1]; - pixel[2] = p[0]; - break; -#if SPLASH_CMYK - case splashModeCMYK8: - p = &data[y * rowSize + 4 * x]; - pixel[0] = p[0]; - pixel[1] = p[1]; - pixel[2] = p[2]; - pixel[3] = p[3]; - break; - case splashModeDeviceN8: - p = &data[y * rowSize + (SPOT_NCOMPS + 4) * x]; - for (int cp = 0; cp < SPOT_NCOMPS + 4; cp++) - pixel[cp] = p[cp]; - break; -#endif - } -} - -Guchar SplashBitmap::getAlpha(int x, int y) { - return alpha[y * width + x]; -} - -SplashColorPtr SplashBitmap::takeData() { - SplashColorPtr data2; - - data2 = data; - data = NULL; - return data2; -} - -SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, WriteImgParams* params) { - FILE *f; - SplashError e; - - if (!(f = fopen(fileName, "wb"))) { - return splashErrOpenFile; - } - - e = writeImgFile(format, f, hDPI, vDPI, params); - - fclose(f); - return e; -} - -void SplashBitmap::setJpegParams(ImgWriter *writer, WriteImgParams* params) -{ -#ifdef ENABLE_LIBJPEG - if (params) { - static_cast<JpegWriter*>(writer)->setProgressive(params->jpegProgressive); - if (params->jpegQuality >= 0) - static_cast<JpegWriter*>(writer)->setQuality(params->jpegQuality); - } -#endif -} - -SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, WriteImgParams* params) { - ImgWriter *writer; - SplashError e; - - SplashColorMode imageWriterFormat = splashModeRGB8; - - switch (format) { - #ifdef ENABLE_LIBPNG - case splashFormatPng: - writer = new PNGWriter(); - break; - #endif - - #ifdef ENABLE_LIBJPEG - #if SPLASH_CMYK - case splashFormatJpegCMYK: - writer = new JpegWriter(JpegWriter::CMYK); - setJpegParams(writer, params); - break; - #endif - case splashFormatJpeg: - writer = new JpegWriter(); - setJpegParams(writer, params); - break; - #endif - - #ifdef ENABLE_LIBTIFF - case splashFormatTiff: - switch (mode) { - case splashModeMono1: - writer = new TiffWriter(TiffWriter::MONOCHROME); - imageWriterFormat = splashModeMono1; - break; - case splashModeMono8: - writer = new TiffWriter(TiffWriter::GRAY); - imageWriterFormat = splashModeMono8; - break; - case splashModeRGB8: - case splashModeBGR8: - writer = new TiffWriter(TiffWriter::RGB); - break; -#if SPLASH_CMYK - case splashModeCMYK8: - case splashModeDeviceN8: - writer = new TiffWriter(TiffWriter::CMYK); - break; -#endif - default: - fprintf(stderr, "TiffWriter: Mode %d not supported\n", mode); - writer = new TiffWriter(); - } - if (writer && params) { - ((TiffWriter *)writer)->setCompressionString(params->tiffCompression.getCString()); - } - break; - #endif - - default: - // Not the greatest error message, but users of this function should - // have already checked whether their desired format is compiled in. - error(errInternal, -1, "Support for this image type not compiled in"); - return splashErrGeneric; - } - - e = writeImgFile(writer, f, hDPI, vDPI, imageWriterFormat); - delete writer; - return e; -} - -#include "poppler/GfxState_helpers.h" - -void SplashBitmap::getRGBLine(int yl, SplashColorPtr line) { - SplashColor col; - double c, m, y, k, c1, m1, y1, k1, r, g, b; - - for (int x = 0; x < width; x++) { - getPixel(x, yl, col); - c = byteToDbl(col[0]); - m = byteToDbl(col[1]); - y = byteToDbl(col[2]); - k = byteToDbl(col[3]); -#if SPLASH_CMYK - if (separationList->getLength() > 0) { - for (int i = 0; i < separationList->getLength(); i++) { - if (col[i+4] > 0) { - GfxCMYK cmyk; - GfxColor input; - input.c[0] = byteToCol(col[i+4]); - GfxSeparationColorSpace *sepCS = (GfxSeparationColorSpace *)separationList->get(i); - sepCS->getCMYK(&input, &cmyk); - col[0] = colToByte(cmyk.c); - col[1] = colToByte(cmyk.m); - col[2] = colToByte(cmyk.y); - col[3] = colToByte(cmyk.k); - c += byteToDbl(col[0]); - m += byteToDbl(col[1]); - y += byteToDbl(col[2]); - k += byteToDbl(col[3]); - } - } - if (c > 1) c = 1; - if (m > 1) m = 1; - if (y > 1) y = 1; - if (k > 1) k = 1; - } -#endif - c1 = 1 - c; - m1 = 1 - m; - y1 = 1 - y; - k1 = 1 - k; - cmykToRGBMatrixMultiplication(c, m, y, k, c1, m1, y1, k1, r, g, b); - *line++ = dblToByte(clip01(r)); - *line++ = dblToByte(clip01(g)); - *line++ = dblToByte(clip01(b)); - } -} - -void SplashBitmap::getXBGRLine(int yl, SplashColorPtr line, ConversionMode conversionMode) { - SplashColor col; - double c, m, y, k, c1, m1, y1, k1, r, g, b; - - for (int x = 0; x < width; x++) { - getPixel(x, yl, col); - c = byteToDbl(col[0]); - m = byteToDbl(col[1]); - y = byteToDbl(col[2]); - k = byteToDbl(col[3]); -#if SPLASH_CMYK - if (separationList->getLength() > 0) { - for (int i = 0; i < separationList->getLength(); i++) { - if (col[i+4] > 0) { - GfxCMYK cmyk; - GfxColor input; - input.c[0] = byteToCol(col[i+4]); - GfxSeparationColorSpace *sepCS = (GfxSeparationColorSpace *)separationList->get(i); - sepCS->getCMYK(&input, &cmyk); - col[0] = colToByte(cmyk.c); - col[1] = colToByte(cmyk.m); - col[2] = colToByte(cmyk.y); - col[3] = colToByte(cmyk.k); - c += byteToDbl(col[0]); - m += byteToDbl(col[1]); - y += byteToDbl(col[2]); - k += byteToDbl(col[3]); - } - } - if (c > 1) c = 1; - if (m > 1) m = 1; - if (y > 1) y = 1; - if (k > 1) k = 1; - } -#endif - c1 = 1 - c; - m1 = 1 - m; - y1 = 1 - y; - k1 = 1 - k; - cmykToRGBMatrixMultiplication(c, m, y, k, c1, m1, y1, k1, r, g, b); - - if (conversionMode == conversionAlphaPremultiplied) { - const double a = getAlpha(x, yl) / 255.0; - - *line++ = dblToByte(clip01(b * a)); - *line++ = dblToByte(clip01(g * a)); - *line++ = dblToByte(clip01(r * a)); - } else { - *line++ = dblToByte(clip01(b)); - *line++ = dblToByte(clip01(g)); - *line++ = dblToByte(clip01(r)); - } - - if (conversionMode != conversionOpaque) { - *line++ = getAlpha(x, yl); - } else { - *line++ = 255; - } - } -} - -static inline Guchar div255(int x) { - return (Guchar)((x + (x >> 8) + 0x80) >> 8); -} - -GBool SplashBitmap::convertToXBGR(ConversionMode conversionMode) { - if (mode == splashModeXBGR8) { - if (conversionMode != conversionOpaque) { - // Copy the alpha channel into the fourth component so that XBGR becomes ABGR. - const SplashColorPtr dbegin = data; - const SplashColorPtr dend = data + rowSize * height; - - Guchar *const abegin = alpha; - Guchar *const aend = alpha + width * height; - - SplashColorPtr d = dbegin; - Guchar *a = abegin; - - if (conversionMode == conversionAlphaPremultiplied) { - for (; d < dend && a < aend; d += 4, a += 1) { - d[0] = div255(d[0] * *a); - d[1] = div255(d[1] * *a); - d[2] = div255(d[2] * *a); - d[3] = *a; - } - } else { - for (d += 3; d < dend && a < aend; d += 4, a += 1) { - *d = *a; - } - } - } - - return gTrue; - } - - int newrowSize = width * 4; - SplashColorPtr newdata = (SplashColorPtr)gmallocn_checkoverflow(newrowSize, height); - if (newdata != NULL) { - for (int y = 0; y < height; y++) { - unsigned char *row = newdata + y * newrowSize; - getXBGRLine(y, row, conversionMode); - } - if (rowSize < 0) { - gfree(data + (height - 1) * rowSize); - } else { - gfree(data); - } - data = newdata; - rowSize = newrowSize; - mode = splashModeXBGR8; - } - return newdata != NULL; -} - -#if SPLASH_CMYK -void SplashBitmap::getCMYKLine(int yl, SplashColorPtr line) { - SplashColor col; - - for (int x = 0; x < width; x++) { - getPixel(x, yl, col); - if (separationList->getLength() > 0) { - double c, m, y, k; - c = byteToDbl(col[0]); - m = byteToDbl(col[1]); - y = byteToDbl(col[2]); - k = byteToDbl(col[3]); - for (int i = 0; i < separationList->getLength(); i++) { - if (col[i+4] > 0) { - GfxCMYK cmyk; - GfxColor input; - input.c[0] = byteToCol(col[i+4]); - GfxSeparationColorSpace *sepCS = (GfxSeparationColorSpace *)separationList->get(i); - sepCS->getCMYK(&input, &cmyk); - col[0] = colToByte(cmyk.c); - col[1] = colToByte(cmyk.m); - col[2] = colToByte(cmyk.y); - col[3] = colToByte(cmyk.k); - c += byteToDbl(col[0]); - m += byteToDbl(col[1]); - y += byteToDbl(col[2]); - k += byteToDbl(col[3]); - } - } - col[0] = dblToByte(clip01(c)); - col[1] = dblToByte(clip01(m)); - col[2] = dblToByte(clip01(y)); - col[3] = dblToByte(clip01(k)); - } - *line++ = col[0]; - *line++ = col[1]; - *line++ = col[2]; - *line++ = col[3]; - } -} -#endif - -SplashError SplashBitmap::writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI, SplashColorMode imageWriterFormat) { - if (mode != splashModeRGB8 && mode != splashModeMono8 && mode != splashModeMono1 && mode != splashModeXBGR8 && mode != splashModeBGR8 -#if SPLASH_CMYK - && mode != splashModeCMYK8 && mode != splashModeDeviceN8 -#endif - ) { - error(errInternal, -1, "unsupported SplashBitmap mode"); - return splashErrGeneric; - } - - if (!writer->init(f, width, height, hDPI, vDPI)) { - return splashErrGeneric; - } - - switch (mode) { -#if SPLASH_CMYK - case splashModeCMYK8: - if (writer->supportCMYK()) { - SplashColorPtr row; - unsigned char **row_pointers = new unsigned char*[height]; - row = data; - - for (int y = 0; y < height; ++y) { - row_pointers[y] = row; - row += rowSize; - } - if (!writer->writePointers(row_pointers, height)) { - delete[] row_pointers; - return splashErrGeneric; - } - delete[] row_pointers; - } else { - unsigned char *row = new unsigned char[3 * width]; - for (int y = 0; y < height; y++) { - getRGBLine(y, row); - if (!writer->writeRow(&row)) { - delete[] row; - return splashErrGeneric; - } - } - delete[] row; - } - break; - case splashModeDeviceN8: - if (writer->supportCMYK()) { - unsigned char *row = new unsigned char[4 * width]; - for (int y = 0; y < height; y++) { - getCMYKLine(y, row); - if (!writer->writeRow(&row)) { - delete[] row; - return splashErrGeneric; - } - } - delete[] row; - } else { - unsigned char *row = new unsigned char[3 * width]; - for (int y = 0; y < height; y++) { - getRGBLine(y, row); - if (!writer->writeRow(&row)) { - delete[] row; - return splashErrGeneric; - } - } - delete[] row; - } - break; -#endif - case splashModeRGB8: - { - SplashColorPtr row; - unsigned char **row_pointers = new unsigned char*[height]; - row = data; - - for (int y = 0; y < height; ++y) { - row_pointers[y] = row; - row += rowSize; - } - if (!writer->writePointers(row_pointers, height)) { - delete[] row_pointers; - return splashErrGeneric; - } - delete[] row_pointers; - } - break; - - case splashModeBGR8: - { - unsigned char *row = new unsigned char[3 * width]; - for (int y = 0; y < height; y++) { - // Convert into a PNG row - for (int x = 0; x < width; x++) { - row[3*x] = data[y * rowSize + x * 3 + 2]; - row[3*x+1] = data[y * rowSize + x * 3 + 1]; - row[3*x+2] = data[y * rowSize + x * 3]; - } - - if (!writer->writeRow(&row)) { - delete[] row; - return splashErrGeneric; - } - } - delete[] row; - } - break; - - case splashModeXBGR8: - { - unsigned char *row = new unsigned char[3 * width]; - for (int y = 0; y < height; y++) { - // Convert into a PNG row - for (int x = 0; x < width; x++) { - row[3*x] = data[y * rowSize + x * 4 + 2]; - row[3*x+1] = data[y * rowSize + x * 4 + 1]; - row[3*x+2] = data[y * rowSize + x * 4]; - } - - if (!writer->writeRow(&row)) { - delete[] row; - return splashErrGeneric; - } - } - delete[] row; - } - break; - - case splashModeMono8: - { - if (imageWriterFormat == splashModeMono8) { - SplashColorPtr row; - unsigned char **row_pointers = new unsigned char*[height]; - row = data; - - for (int y = 0; y < height; ++y) { - row_pointers[y] = row; - row += rowSize; - } - if (!writer->writePointers(row_pointers, height)) { - delete[] row_pointers; - return splashErrGeneric; - } - delete[] row_pointers; - } else if (imageWriterFormat == splashModeRGB8) { - unsigned char *row = new unsigned char[3 * width]; - for (int y = 0; y < height; y++) { - // Convert into a PNG row - for (int x = 0; x < width; x++) { - row[3*x] = data[y * rowSize + x]; - row[3*x+1] = data[y * rowSize + x]; - row[3*x+2] = data[y * rowSize + x]; - } - - if (!writer->writeRow(&row)) { - delete[] row; - return splashErrGeneric; - } - } - delete[] row; - } - else { - // only splashModeMono8 or splashModeRGB8 - return splashErrGeneric; - } - } - break; - - case splashModeMono1: - { - if (imageWriterFormat == splashModeMono1) { - SplashColorPtr row; - unsigned char **row_pointers = new unsigned char*[height]; - row = data; - - for (int y = 0; y < height; ++y) { - row_pointers[y] = row; - row += rowSize; - } - if (!writer->writePointers(row_pointers, height)) { - delete[] row_pointers; - return splashErrGeneric; - } - delete[] row_pointers; - } else if (imageWriterFormat == splashModeRGB8) { - unsigned char *row = new unsigned char[3 * width]; - for (int y = 0; y < height; y++) { - // Convert into a PNG row - for (int x = 0; x < width; x++) { - getPixel(x, y, &row[3*x]); - row[3*x+1] = row[3*x]; - row[3*x+2] = row[3*x]; - } - - if (!writer->writeRow(&row)) { - delete[] row; - return splashErrGeneric; - } - } - delete[] row; - } - else { - // only splashModeMono1 or splashModeRGB8 - return splashErrGeneric; - } - } - break; - - default: - // can't happen - break; - } - - if (!writer->close()) { - return splashErrGeneric; - } - - return splashOk; -} diff --git a/source/libs/poppler/poppler-src/splash/SplashBitmap.h b/source/libs/poppler/poppler-src/splash/SplashBitmap.h deleted file mode 100644 index deb65c120b23c56d717f0ac86af1bd6aba868b4f..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashBitmap.h +++ /dev/null @@ -1,126 +0,0 @@ -//======================================================================== -// -// SplashBitmap.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> -// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> -// Copyright (C) 2009, 2012 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com> -// Copyright (C) 2010, 2017 Adrian Johnson <ajohnson@redneon.com> -// Copyright (C) 2010 Harry Roberts <harry.roberts@midnight-labs.org> -// Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com> -// Copyright (C) 2010 William Bader <williambader@hotmail.com> -// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2015 Adam Reichold <adamreichold@myopera.com> -// Copyright (C) 2016 Kenji Uno <ku@digitaldolphins.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 -// -//======================================================================== - -#ifndef SPLASHBITMAP_H -#define SPLASHBITMAP_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" -#include "poppler/GfxState.h" -#include <stdio.h> - -class ImgWriter; - -//------------------------------------------------------------------------ -// SplashBitmap -//------------------------------------------------------------------------ - -class SplashBitmap { -public: - - // Create a new bitmap. It will have <widthA> x <heightA> pixels in - // color mode <modeA>. Rows will be padded out to a multiple of - // <rowPad> bytes. If <topDown> is false, the bitmap will be stored - // upside-down, i.e., with the last row first in memory. - SplashBitmap(int widthA, int heightA, int rowPad, - SplashColorMode modeA, GBool alphaA, - GBool topDown = gTrue, GooList *separationList = NULL); - static SplashBitmap *copy(SplashBitmap *src); - - ~SplashBitmap(); - - int getWidth() { return width; } - int getHeight() { return height; } - int getRowSize() { return rowSize; } - int getAlphaRowSize() { return width; } - int getRowPad() { return rowPad; } - SplashColorMode getMode() { return mode; } - SplashColorPtr getDataPtr() { return data; } - Guchar *getAlphaPtr() { return alpha; } - GooList *getSeparationList() { return separationList; } - - SplashError writePNMFile(char *fileName); - SplashError writePNMFile(FILE *f); - SplashError writeAlphaPGMFile(char *fileName); - - struct WriteImgParams - { - int jpegQuality = -1; - GBool jpegProgressive = gFalse; - GooString tiffCompression; - }; - - SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, WriteImgParams* params = nullptr); - SplashError writeImgFile(SplashImageFileFormat format, FILE *f, int hDPI, int vDPI, WriteImgParams* params = nullptr); - SplashError writeImgFile(ImgWriter *writer, FILE *f, int hDPI, int vDPI, SplashColorMode imageWriterFormat); - - enum ConversionMode - { - conversionOpaque, - conversionAlpha, - conversionAlphaPremultiplied - }; - - GBool convertToXBGR(ConversionMode conversionMode = conversionOpaque); - - void getPixel(int x, int y, SplashColorPtr pixel); - void getRGBLine(int y, SplashColorPtr line); - void getXBGRLine(int y, SplashColorPtr line, ConversionMode conversionMode = conversionOpaque); -#if SPLASH_CMYK - void getCMYKLine(int y, SplashColorPtr line); -#endif - Guchar getAlpha(int x, int y); - - // Caller takes ownership of the bitmap data. The SplashBitmap - // object is no longer valid -- the next call should be to the - // destructor. - SplashColorPtr takeData(); - -private: - - int width, height; // size of bitmap - int rowPad; - int rowSize; // size of one row of data, in bytes - // - negative for bottom-up bitmaps - SplashColorMode mode; // color mode - SplashColorPtr data; // pointer to row zero of the color data - Guchar *alpha; // pointer to row zero of the alpha data - // (always top-down) - GooList *separationList; // list of spot colorants and their mapping functions - - friend class Splash; - - void setJpegParams(ImgWriter *writer, WriteImgParams* params); -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashClip.cc b/source/libs/poppler/poppler-src/splash/SplashClip.cc deleted file mode 100644 index 85c6b11473da8b8d1ec80f286253b2416cdfdd1b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashClip.cc +++ /dev/null @@ -1,411 +0,0 @@ -//======================================================================== -// -// SplashClip.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <string.h> -#include "goo/gmem.h" -#include "SplashErrorCodes.h" -#include "SplashPath.h" -#include "SplashXPath.h" -#include "SplashXPathScanner.h" -#include "SplashBitmap.h" -#include "SplashClip.h" - -//------------------------------------------------------------------------ -// SplashClip.flags -//------------------------------------------------------------------------ - -#define splashClipEO 0x01 // use even-odd rule - -//------------------------------------------------------------------------ -// SplashClip -//------------------------------------------------------------------------ - -SplashClip::SplashClip(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1, - GBool antialiasA) { - antialias = antialiasA; - if (x0 < x1) { - xMin = x0; - xMax = x1; - } else { - xMin = x1; - xMax = x0; - } - if (y0 < y1) { - yMin = y0; - yMax = y1; - } else { - yMin = y1; - yMax = y0; - } - xMinI = splashFloor(xMin); - yMinI = splashFloor(yMin); - xMaxI = splashCeil(xMax) - 1; - yMaxI = splashCeil(yMax) - 1; - paths = NULL; - flags = NULL; - scanners = NULL; - length = size = 0; -} - -SplashClip::SplashClip(SplashClip *clip) { - int yMinAA, yMaxAA; - int i; - - antialias = clip->antialias; - xMin = clip->xMin; - yMin = clip->yMin; - xMax = clip->xMax; - yMax = clip->yMax; - xMinI = clip->xMinI; - yMinI = clip->yMinI; - xMaxI = clip->xMaxI; - yMaxI = clip->yMaxI; - length = clip->length; - size = clip->size; - paths = (SplashXPath **)gmallocn(size, sizeof(SplashXPath *)); - flags = (Guchar *)gmallocn(size, sizeof(Guchar)); - scanners = (SplashXPathScanner **) - gmallocn(size, sizeof(SplashXPathScanner *)); - for (i = 0; i < length; ++i) { - paths[i] = clip->paths[i]->copy(); - flags[i] = clip->flags[i]; - if (antialias) { - yMinAA = yMinI * splashAASize; - yMaxAA = (yMaxI + 1) * splashAASize - 1; - } else { - yMinAA = yMinI; - yMaxAA = yMaxI; - } - scanners[i] = new SplashXPathScanner(paths[i], flags[i] & splashClipEO, - yMinAA, yMaxAA); - } -} - -SplashClip::~SplashClip() { - int i; - - for (i = 0; i < length; ++i) { - delete paths[i]; - delete scanners[i]; - } - gfree(paths); - gfree(flags); - gfree(scanners); -} - -void SplashClip::grow(int nPaths) { - if (length + nPaths > size) { - if (size == 0) { - size = 32; - } - while (size < length + nPaths) { - size *= 2; - } - paths = (SplashXPath **)greallocn(paths, size, sizeof(SplashXPath *)); - flags = (Guchar *)greallocn(flags, size, sizeof(Guchar)); - scanners = (SplashXPathScanner **) - greallocn(scanners, size, sizeof(SplashXPathScanner *)); - } -} - -void SplashClip::resetToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1) { - int i; - - for (i = 0; i < length; ++i) { - delete paths[i]; - delete scanners[i]; - } - gfree(paths); - gfree(flags); - gfree(scanners); - paths = NULL; - flags = NULL; - scanners = NULL; - length = size = 0; - - if (x0 < x1) { - xMin = x0; - xMax = x1; - } else { - xMin = x1; - xMax = x0; - } - if (y0 < y1) { - yMin = y0; - yMax = y1; - } else { - yMin = y1; - yMax = y0; - } - xMinI = splashFloor(xMin); - yMinI = splashFloor(yMin); - xMaxI = splashCeil(xMax) - 1; - yMaxI = splashCeil(yMax) - 1; -} - -SplashError SplashClip::clipToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1) { - if (x0 < x1) { - if (x0 > xMin) { - xMin = x0; - xMinI = splashFloor(xMin); - } - if (x1 < xMax) { - xMax = x1; - xMaxI = splashCeil(xMax) - 1; - } - } else { - if (x1 > xMin) { - xMin = x1; - xMinI = splashFloor(xMin); - } - if (x0 < xMax) { - xMax = x0; - xMaxI = splashCeil(xMax) - 1; - } - } - if (y0 < y1) { - if (y0 > yMin) { - yMin = y0; - yMinI = splashFloor(yMin); - } - if (y1 < yMax) { - yMax = y1; - yMaxI = splashCeil(yMax) - 1; - } - } else { - if (y1 > yMin) { - yMin = y1; - yMinI = splashFloor(yMin); - } - if (y0 < yMax) { - yMax = y0; - yMaxI = splashCeil(yMax) - 1; - } - } - return splashOk; -} - -SplashError SplashClip::clipToPath(SplashPath *path, SplashCoord *matrix, - SplashCoord flatness, GBool eo) { - SplashXPath *xPath; - int yMinAA, yMaxAA; - - xPath = new SplashXPath(path, matrix, flatness, gTrue); - - // check for an empty path - if (xPath->length == 0) { - xMax = xMin - 1; - yMax = yMin - 1; - xMaxI = splashCeil(xMax) - 1; - yMaxI = splashCeil(yMax) - 1; - delete xPath; - - // check for a rectangle - } else if (xPath->length == 4 && - ((xPath->segs[0].x0 == xPath->segs[0].x1 && - xPath->segs[0].x0 == xPath->segs[1].x0 && - xPath->segs[0].x0 == xPath->segs[3].x1 && - xPath->segs[2].x0 == xPath->segs[2].x1 && - xPath->segs[2].x0 == xPath->segs[1].x1 && - xPath->segs[2].x0 == xPath->segs[3].x0 && - xPath->segs[1].y0 == xPath->segs[1].y1 && - xPath->segs[1].y0 == xPath->segs[0].y1 && - xPath->segs[1].y0 == xPath->segs[2].y0 && - xPath->segs[3].y0 == xPath->segs[3].y1 && - xPath->segs[3].y0 == xPath->segs[0].y0 && - xPath->segs[3].y0 == xPath->segs[2].y1) || - (xPath->segs[0].y0 == xPath->segs[0].y1 && - xPath->segs[0].y0 == xPath->segs[1].y0 && - xPath->segs[0].y0 == xPath->segs[3].y1 && - xPath->segs[2].y0 == xPath->segs[2].y1 && - xPath->segs[2].y0 == xPath->segs[1].y1 && - xPath->segs[2].y0 == xPath->segs[3].y0 && - xPath->segs[1].x0 == xPath->segs[1].x1 && - xPath->segs[1].x0 == xPath->segs[0].x1 && - xPath->segs[1].x0 == xPath->segs[2].x0 && - xPath->segs[3].x0 == xPath->segs[3].x1 && - xPath->segs[3].x0 == xPath->segs[0].x0 && - xPath->segs[3].x0 == xPath->segs[2].x1))) { - clipToRect(xPath->segs[0].x0, xPath->segs[0].y0, - xPath->segs[2].x0, xPath->segs[2].y0); - delete xPath; - - } else { - grow(1); - if (antialias) { - xPath->aaScale(); - } - xPath->sort(); - paths[length] = xPath; - flags[length] = eo ? splashClipEO : 0; - if (antialias) { - yMinAA = yMinI * splashAASize; - yMaxAA = (yMaxI + 1) * splashAASize - 1; - } else { - yMinAA = yMinI; - yMaxAA = yMaxI; - } - scanners[length] = new SplashXPathScanner(xPath, eo, yMinAA, yMaxAA); - ++length; - } - - return splashOk; -} - -SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin, - int rectXMax, int rectYMax) { - // This tests the rectangle: - // x = [rectXMin, rectXMax + 1) (note: rect coords are ints) - // y = [rectYMin, rectYMax + 1) - // against the clipping region: - // x = [xMin, xMax) (note: clipping coords are fp) - // y = [yMin, yMax) - if ((SplashCoord)(rectXMax + 1) <= xMin || (SplashCoord)rectXMin >= xMax || - (SplashCoord)(rectYMax + 1) <= yMin || (SplashCoord)rectYMin >= yMax) { - return splashClipAllOutside; - } - if ((SplashCoord)rectXMin >= xMin && (SplashCoord)(rectXMax + 1) <= xMax && - (SplashCoord)rectYMin >= yMin && (SplashCoord)(rectYMax + 1) <= yMax && - length == 0) { - return splashClipAllInside; - } - return splashClipPartial; -} - -SplashClipResult SplashClip::testSpan(int spanXMin, int spanXMax, int spanY) { - int i; - - // This tests the rectangle: - // x = [spanXMin, spanXMax + 1) (note: span coords are ints) - // y = [spanY, spanY + 1) - // against the clipping region: - // x = [xMin, xMax) (note: clipping coords are fp) - // y = [yMin, yMax) - if ((SplashCoord)(spanXMax + 1) <= xMin || (SplashCoord)spanXMin >= xMax || - (SplashCoord)(spanY + 1) <= yMin || (SplashCoord)spanY >= yMax) { - return splashClipAllOutside; - } - if (!((SplashCoord)spanXMin >= xMin && (SplashCoord)(spanXMax + 1) <= xMax && - (SplashCoord)spanY >= yMin && (SplashCoord)(spanY + 1) <= yMax)) { - return splashClipPartial; - } - if (antialias) { - for (i = 0; i < length; ++i) { - if (!scanners[i]->testSpan(spanXMin * splashAASize, - spanXMax * splashAASize + (splashAASize - 1), - spanY * splashAASize)) { - return splashClipPartial; - } - } - } else { - for (i = 0; i < length; ++i) { - if (!scanners[i]->testSpan(spanXMin, spanXMax, spanY)) { - return splashClipPartial; - } - } - } - return splashClipAllInside; -} - -void SplashClip::clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y, GBool adjustVertLine) { - int xx0, xx1, xx, yy, i; - SplashColorPtr p; - - // zero out pixels with x < xMin - xx0 = *x0 * splashAASize; - xx1 = splashFloor(xMin * splashAASize); - if (xx1 > aaBuf->getWidth()) { - xx1 = aaBuf->getWidth(); - } - if (xx0 < xx1) { - xx0 &= ~7; - for (yy = 0; yy < splashAASize; ++yy) { - p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + (xx0 >> 3); - for (xx = xx0; xx + 7 < xx1; xx += 8) { - *p++ = 0; - } - if (xx < xx1 && !adjustVertLine) { - *p &= 0xff >> (xx1 & 7); - } - } - *x0 = splashFloor(xMin); - } - - // zero out pixels with x > xMax - xx0 = splashFloor(xMax * splashAASize) + 1; - if (xx0 < 0) { - xx0 = 0; - } - xx1 = (*x1 + 1) * splashAASize; - if (xx0 < xx1 && !adjustVertLine) { - for (yy = 0; yy < splashAASize; ++yy) { - p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + (xx0 >> 3); - xx = xx0; - if (xx & 7) { - *p &= 0xff00 >> (xx & 7); - xx = (xx & ~7) + 8; - ++p; - } - for (; xx < xx1; xx += 8) { - *p++ = 0; - } - } - *x1 = splashFloor(xMax); - } - - // check the paths - for (i = 0; i < length; ++i) { - scanners[i]->clipAALine(aaBuf, x0, x1, y); - } - if (*x0 > *x1) { - *x0 = *x1; - } - if (*x0 < 0) { - *x0 = 0; - } - if ((*x0>>1) >= aaBuf->getRowSize()) { - xx0 = *x0; - *x0 = (aaBuf->getRowSize() - 1) << 1; - if (xx0 & 1) { - *x0 = *x0 + 1; - } - } - if (*x1 < *x0) { - *x1 = *x0; - } - if ((*x1>>1) >= aaBuf->getRowSize()) { - xx0 = *x1; - *x1 = (aaBuf->getRowSize() - 1) << 1; - if (xx0 & 1) { - *x1 = *x1 + 1; - } - } -} diff --git a/source/libs/poppler/poppler-src/splash/SplashClip.h b/source/libs/poppler/poppler-src/splash/SplashClip.h deleted file mode 100644 index 5c0fdba99a7de36fc51fcd34407f2d453e7fb143..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashClip.h +++ /dev/null @@ -1,152 +0,0 @@ -//======================================================================== -// -// SplashClip.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHCLIP_H -#define SPLASHCLIP_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" -#include "SplashMath.h" -#include "SplashXPathScanner.h" - -class SplashPath; -class SplashXPath; -class SplashBitmap; - -//------------------------------------------------------------------------ - -enum SplashClipResult { - splashClipAllInside, - splashClipAllOutside, - splashClipPartial -}; - -//------------------------------------------------------------------------ -// SplashClip -//------------------------------------------------------------------------ - -class SplashClip { -public: - - // Create a clip, for the given rectangle. - SplashClip(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1, - GBool antialiasA); - - // Copy a clip. - SplashClip *copy() { return new SplashClip(this); } - - ~SplashClip(); - - // Reset the clip to a rectangle. - void resetToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1); - - // Intersect the clip with a rectangle. - SplashError clipToRect(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1); - - // Interesect the clip with <path>. - SplashError clipToPath(SplashPath *path, SplashCoord *matrix, - SplashCoord flatness, GBool eo); - - // Returns true if (<x>,<y>) is inside the clip. - GBool test(int x, int y) - { - int i; - - // check the rectangle - if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) { - return gFalse; - } - - // check the paths - if (antialias) { - for (i = 0; i < length; ++i) { - if (!scanners[i]->test(x * splashAASize, y * splashAASize)) { - return gFalse; - } - } - } else { - for (i = 0; i < length; ++i) { - if (!scanners[i]->test(x, y)) { - return gFalse; - } - } - } - - return gTrue; - } - - // Tests a rectangle against the clipping region. Returns one of: - // - splashClipAllInside if the entire rectangle is inside the - // clipping region, i.e., all pixels in the rectangle are - // visible - // - splashClipAllOutside if the entire rectangle is outside the - // clipping region, i.e., all the pixels in the rectangle are - // clipped - // - splashClipPartial if the rectangle is part inside and part - // outside the clipping region - SplashClipResult testRect(int rectXMin, int rectYMin, - int rectXMax, int rectYMax); - - // Similar to testRect, but tests a horizontal span. - SplashClipResult testSpan(int spanXMin, int spanXMax, int spanY); - - // Clips an anti-aliased line by setting pixels to zero. On entry, - // all non-zero pixels are between <x0> and <x1>. This function - // will update <x0> and <x1>. - void clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y, - GBool adjustVertLine = gFalse); - - // Get the rectangle part of the clip region. - SplashCoord getXMin() { return xMin; } - SplashCoord getXMax() { return xMax; } - SplashCoord getYMin() { return yMin; } - SplashCoord getYMax() { return yMax; } - - // Get the rectangle part of the clip region, in integer coordinates. - int getXMinI() { return xMinI; } - int getXMaxI() { return xMaxI; } - int getYMinI() { return yMinI; } - int getYMaxI() { return yMaxI; } - - // Get the number of arbitrary paths used by the clip region. - int getNumPaths() { return length; } - -protected: - - SplashClip(SplashClip *clip); - void grow(int nPaths); - - GBool antialias; - SplashCoord xMin, yMin, xMax, yMax; - int xMinI, yMinI, xMaxI, yMaxI; - SplashXPath **paths; - Guchar *flags; - SplashXPathScanner **scanners; - int length, size; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashErrorCodes.h b/source/libs/poppler/poppler-src/splash/SplashErrorCodes.h deleted file mode 100644 index d1f81f85dd878c4a4c945e8a87b52d379091eff6..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashErrorCodes.h +++ /dev/null @@ -1,50 +0,0 @@ -//======================================================================== -// -// SplashErrorCodes.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006, 2009 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHERRORCODES_H -#define SPLASHERRORCODES_H - -//------------------------------------------------------------------------ - -#define splashOk 0 // no error - -#define splashErrNoCurPt 1 // no current point - -#define splashErrEmptyPath 2 // zero points in path - -#define splashErrBogusPath 3 // only one point in subpath - -#define splashErrNoSave 4 // state stack is empty - -#define splashErrOpenFile 5 // couldn't open file - -#define splashErrNoGlyph 6 // couldn't get the requested glyph - -#define splashErrModeMismatch 7 // invalid combination of color modes - -#define splashErrSingularMatrix 8 // matrix is singular - -#define splashErrBadArg 9 // bad argument - -#define splashErrZeroImage 254 // image of 0x0 - -#define splashErrGeneric 255 - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashFTFont.cc b/source/libs/poppler/poppler-src/splash/SplashFTFont.cc deleted file mode 100644 index b785826d66ba1c4bd73b699b053346c8b8032a3a..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFTFont.cc +++ /dev/null @@ -1,513 +0,0 @@ -//======================================================================== -// -// SplashFTFont.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2005, 2007-2011, 2014 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2006 Kristian Høgsberg <krh@bitplanet.net> -// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> -// Copyright (C) 2010 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp> -// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> -// Copyright (C) 2012 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <ft2build.h> -#include FT_OUTLINE_H -#include FT_SIZES_H -#include FT_GLYPH_H -#include "goo/gmem.h" -#include "SplashMath.h" -#include "SplashGlyphBitmap.h" -#include "SplashPath.h" -#include "SplashFTFontEngine.h" -#include "SplashFTFontFile.h" -#include "SplashFTFont.h" - -//------------------------------------------------------------------------ - -static int glyphPathMoveTo(const FT_Vector *pt, void *path); -static int glyphPathLineTo(const FT_Vector *pt, void *path); -static int glyphPathConicTo(const FT_Vector *ctrl, const FT_Vector *pt, - void *path); -static int glyphPathCubicTo(const FT_Vector *ctrl1, const FT_Vector *ctrl2, - const FT_Vector *pt, void *path); - -//------------------------------------------------------------------------ -// SplashFTFont -//------------------------------------------------------------------------ - -SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA): - SplashFont(fontFileA, matA, textMatA, fontFileA->engine->aa), - enableFreeTypeHinting(fontFileA->engine->enableFreeTypeHinting), - enableSlightHinting(fontFileA->engine->enableSlightHinting) -{ - FT_Face face; - int div; - int x, y; -#if USE_FIXEDPOINT - SplashCoord scale; -#endif - - face = fontFileA->face; - if (FT_New_Size(face, &sizeObj)) { - return; - } - face->size = sizeObj; - size = splashRound(splashDist(0, 0, mat[2], mat[3])); - if (size < 1) { - size = 1; - } - if (FT_Set_Pixel_Sizes(face, 0, size)) { - return; - } - // if the textMat values are too small, FreeType's fixed point - // arithmetic doesn't work so well - textScale = splashDist(0, 0, textMat[2], textMat[3]) / size; - - div = face->bbox.xMax > 20000 ? 65536 : 1; - -#if USE_FIXEDPOINT - scale = (SplashCoord)1 / (SplashCoord)face->units_per_EM; - - // transform the four corners of the font bounding box -- the min - // and max values form the bounding box of the transformed font - x = (int)(mat[0] * (scale * (face->bbox.xMin / div)) + - mat[2] * (scale * (face->bbox.yMin / div))); - xMin = xMax = x; - y = (int)(mat[1] * (scale * (face->bbox.xMin / div)) + - mat[3] * (scale * (face->bbox.yMin / div))); - yMin = yMax = y; - x = (int)(mat[0] * (scale * (face->bbox.xMin / div)) + - mat[2] * (scale * (face->bbox.yMax / div))); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * (scale * (face->bbox.xMin / div)) + - mat[3] * (scale * (face->bbox.yMax / div))); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)(mat[0] * (scale * (face->bbox.xMax / div)) + - mat[2] * (scale * (face->bbox.yMin / div))); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * (scale * (face->bbox.xMax / div)) + - mat[3] * (scale * (face->bbox.yMin / div))); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)(mat[0] * (scale * (face->bbox.xMax / div)) + - mat[2] * (scale * (face->bbox.yMax / div))); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * (scale * (face->bbox.xMax / div)) + - mat[3] * (scale * (face->bbox.yMax / div))); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } -#else // USE_FIXEDPOINT - // transform the four corners of the font bounding box -- the min - // and max values form the bounding box of the transformed font - x = (int)((mat[0] * face->bbox.xMin + mat[2] * face->bbox.yMin) / - (div * face->units_per_EM)); - xMin = xMax = x; - y = (int)((mat[1] * face->bbox.xMin + mat[3] * face->bbox.yMin) / - (div * face->units_per_EM)); - yMin = yMax = y; - x = (int)((mat[0] * face->bbox.xMin + mat[2] * face->bbox.yMax) / - (div * face->units_per_EM)); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)((mat[1] * face->bbox.xMin + mat[3] * face->bbox.yMax) / - (div * face->units_per_EM)); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)((mat[0] * face->bbox.xMax + mat[2] * face->bbox.yMin) / - (div * face->units_per_EM)); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)((mat[1] * face->bbox.xMax + mat[3] * face->bbox.yMin) / - (div * face->units_per_EM)); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)((mat[0] * face->bbox.xMax + mat[2] * face->bbox.yMax) / - (div * face->units_per_EM)); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)((mat[1] * face->bbox.xMax + mat[3] * face->bbox.yMax) / - (div * face->units_per_EM)); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } -#endif // USE_FIXEDPOINT - // This is a kludge: some buggy PDF generators embed fonts with - // zero bounding boxes. - if (xMax == xMin) { - xMin = 0; - xMax = size; - } - if (yMax == yMin) { - yMin = 0; - yMax = (int)((SplashCoord)1.2 * size); - } - - // compute the transform matrix -#if USE_FIXEDPOINT - matrix.xx = (FT_Fixed)((mat[0] / size).get16Dot16()); - matrix.yx = (FT_Fixed)((mat[1] / size).get16Dot16()); - matrix.xy = (FT_Fixed)((mat[2] / size).get16Dot16()); - matrix.yy = (FT_Fixed)((mat[3] / size).get16Dot16()); - textMatrix.xx = (FT_Fixed)((textMat[0] / (textScale * size)).get16Dot16()); - textMatrix.yx = (FT_Fixed)((textMat[1] / (textScale * size)).get16Dot16()); - textMatrix.xy = (FT_Fixed)((textMat[2] / (textScale * size)).get16Dot16()); - textMatrix.yy = (FT_Fixed)((textMat[3] / (textScale * size)).get16Dot16()); -#else - matrix.xx = (FT_Fixed)((mat[0] / size) * 65536); - matrix.yx = (FT_Fixed)((mat[1] / size) * 65536); - matrix.xy = (FT_Fixed)((mat[2] / size) * 65536); - matrix.yy = (FT_Fixed)((mat[3] / size) * 65536); - textMatrix.xx = (FT_Fixed)((textMat[0] / (textScale * size)) * 65536); - textMatrix.yx = (FT_Fixed)((textMat[1] / (textScale * size)) * 65536); - textMatrix.xy = (FT_Fixed)((textMat[2] / (textScale * size)) * 65536); - textMatrix.yy = (FT_Fixed)((textMat[3] / (textScale * size)) * 65536); -#endif -} - -SplashFTFont::~SplashFTFont() { -} - -GBool SplashFTFont::getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { - return SplashFont::getGlyph(c, xFrac, 0, bitmap, x0, y0, clip, clipRes); -} - -static FT_Int32 getFTLoadFlags(GBool type1, GBool trueType, GBool aa, GBool enableFreeTypeHinting, GBool enableSlightHinting) -{ - int ret = FT_LOAD_DEFAULT; - if (aa) - ret |= FT_LOAD_NO_BITMAP; - - if (enableFreeTypeHinting) { - if (enableSlightHinting) { - ret |= FT_LOAD_TARGET_LIGHT; - } else { - if (trueType) { - // FT2's autohinting doesn't always work very well (especially with - // font subsets), so turn it off if anti-aliasing is enabled; if - // anti-aliasing is disabled, this seems to be a tossup - some fonts - // look better with hinting, some without, so leave hinting on - if (aa) { - ret |= FT_LOAD_NO_AUTOHINT; - } - } else if (type1) { - // Type 1 fonts seem to look better with 'light' hinting mode - ret |= FT_LOAD_TARGET_LIGHT; - } - } - } else { - ret |= FT_LOAD_NO_HINTING; - } - return ret; -} - -GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { - SplashFTFontFile *ff; - FT_Vector offset; - FT_GlyphSlot slot; - FT_UInt gid; - int rowSize; - Guchar *p, *q; - int i; - - ff = (SplashFTFontFile *)fontFile; - - ff->face->size = sizeObj; - offset.x = (FT_Pos)(int)((SplashCoord)xFrac * splashFontFractionMul * 64); - offset.y = 0; - FT_Set_Transform(ff->face, &matrix, &offset); - slot = ff->face->glyph; - - if (ff->codeToGID && c < ff->codeToGIDLen && c >= 0) { - gid = (FT_UInt)ff->codeToGID[c]; - } else { - gid = (FT_UInt)c; - } - - if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(ff->type1, ff->trueType, aa, enableFreeTypeHinting, enableSlightHinting))) { - return gFalse; - } - - // prelimirary values based on FT_Outline_Get_CBox - // we add two pixels to each side to be in the safe side - FT_BBox cbox; - FT_Outline_Get_CBox(&ff->face->glyph->outline, &cbox); - bitmap->x = -(cbox.xMin / 64) + 2; - bitmap->y = (cbox.yMax / 64) + 2; - bitmap->w = ((cbox.xMax - cbox.xMin) / 64) + 4; - bitmap->h = ((cbox.yMax - cbox.yMin) / 64) + 4; - - *clipRes = clip->testRect(x0 - bitmap->x, - y0 - bitmap->y, - x0 - bitmap->x + bitmap->w, - y0 - bitmap->y + bitmap->h); - if (*clipRes == splashClipAllOutside) { - bitmap->freeData = gFalse; - return gTrue; - } - - if (FT_Render_Glyph(slot, aa ? ft_render_mode_normal - : ft_render_mode_mono)) { - return gFalse; - } - - if (slot->bitmap.width == 0 || slot->bitmap.rows == 0) { - // this can happen if (a) the glyph is really tiny or (b) the - // metrics in the TrueType file are broken - return gFalse; - } - - bitmap->x = -slot->bitmap_left; - bitmap->y = slot->bitmap_top; - bitmap->w = slot->bitmap.width; - bitmap->h = slot->bitmap.rows; - bitmap->aa = aa; - if (aa) { - rowSize = bitmap->w; - } else { - rowSize = (bitmap->w + 7) >> 3; - } - bitmap->data = (Guchar *)gmallocn_checkoverflow(rowSize, bitmap->h); - if (!bitmap->data) { - return gFalse; - } - bitmap->freeData = gTrue; - for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; - i < bitmap->h; - ++i, p += rowSize, q += slot->bitmap.pitch) { - memcpy(p, q, rowSize); - } - - return gTrue; -} - -double SplashFTFont::getGlyphAdvance(int c) -{ - SplashFTFontFile *ff; - FT_Vector offset; - FT_UInt gid; - FT_Matrix identityMatrix; - - ff = (SplashFTFontFile *)fontFile; - - // init the matrix - identityMatrix.xx = 65536; // 1 in 16.16 format - identityMatrix.xy = 0; - identityMatrix.yx = 0; - identityMatrix.yy = 65536; // 1 in 16.16 format - - // init the offset - offset.x = 0; - offset.y = 0; - - ff->face->size = sizeObj; - FT_Set_Transform(ff->face, &identityMatrix, &offset); - - if (ff->codeToGID && c < ff->codeToGIDLen) { - gid = (FT_UInt)ff->codeToGID[c]; - } else { - gid = (FT_UInt)c; - } - - if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(ff->type1, ff->trueType, aa, enableFreeTypeHinting, enableSlightHinting))) { - return -1; - } - - // 64.0 is 1 in 26.6 format - return ff->face->glyph->metrics.horiAdvance / 64.0 / size; -} - -struct SplashFTFontPath { - SplashPath *path; - SplashCoord textScale; - GBool needClose; -}; - -SplashPath *SplashFTFont::getGlyphPath(int c) { - static FT_Outline_Funcs outlineFuncs = { -#if FREETYPE_MINOR <= 1 - (int (*)(FT_Vector *, void *))&glyphPathMoveTo, - (int (*)(FT_Vector *, void *))&glyphPathLineTo, - (int (*)(FT_Vector *, FT_Vector *, void *))&glyphPathConicTo, - (int (*)(FT_Vector *, FT_Vector *, FT_Vector *, void *))&glyphPathCubicTo, -#else - &glyphPathMoveTo, - &glyphPathLineTo, - &glyphPathConicTo, - &glyphPathCubicTo, -#endif - 0, 0 - }; - SplashFTFontFile *ff; - SplashFTFontPath path; - FT_GlyphSlot slot; - FT_UInt gid; - FT_Glyph glyph; - - ff = (SplashFTFontFile *)fontFile; - ff->face->size = sizeObj; - FT_Set_Transform(ff->face, &textMatrix, NULL); - slot = ff->face->glyph; - if (ff->codeToGID && c < ff->codeToGIDLen && c >= 0) { - gid = ff->codeToGID[c]; - } else { - gid = (FT_UInt)c; - } - if (FT_Load_Glyph(ff->face, gid, getFTLoadFlags(ff->type1, ff->trueType, aa, enableFreeTypeHinting, enableSlightHinting))) { - return NULL; - } - if (FT_Get_Glyph(slot, &glyph)) { - return NULL; - } - if (FT_Outline_Check(&((FT_OutlineGlyph)glyph)->outline)) { - return NULL; - } - path.path = new SplashPath(); - path.textScale = textScale; - path.needClose = gFalse; - FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline, - &outlineFuncs, &path); - if (path.needClose) { - path.path->close(); - } - FT_Done_Glyph(glyph); - return path.path; -} - -static int glyphPathMoveTo(const FT_Vector *pt, void *path) { - SplashFTFontPath *p = (SplashFTFontPath *)path; - - if (p->needClose) { - p->path->close(); - p->needClose = gFalse; - } - p->path->moveTo((SplashCoord)pt->x * p->textScale / 64.0, - (SplashCoord)pt->y * p->textScale / 64.0); - return 0; -} - -static int glyphPathLineTo(const FT_Vector *pt, void *path) { - SplashFTFontPath *p = (SplashFTFontPath *)path; - - p->path->lineTo((SplashCoord)pt->x * p->textScale / 64.0, - (SplashCoord)pt->y * p->textScale / 64.0); - p->needClose = gTrue; - return 0; -} - -static int glyphPathConicTo(const FT_Vector *ctrl, const FT_Vector *pt, - void *path) { - SplashFTFontPath *p = (SplashFTFontPath *)path; - SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xc, yc; - - if (!p->path->getCurPt(&x0, &y0)) { - return 0; - } - xc = (SplashCoord)ctrl->x * p->textScale / 64.0; - yc = (SplashCoord)ctrl->y * p->textScale / 64.0; - x3 = (SplashCoord)pt->x * p->textScale / 64.0; - y3 = (SplashCoord)pt->y * p->textScale / 64.0; - - // A second-order Bezier curve is defined by two endpoints, p0 and - // p3, and one control point, pc: - // - // p(t) = (1-t)^2*p0 + t*(1-t)*pc + t^2*p3 - // - // A third-order Bezier curve is defined by the same two endpoints, - // p0 and p3, and two control points, p1 and p2: - // - // p(t) = (1-t)^3*p0 + 3t*(1-t)^2*p1 + 3t^2*(1-t)*p2 + t^3*p3 - // - // Applying some algebra, we can convert a second-order curve to a - // third-order curve: - // - // p1 = (1/3) * (p0 + 2pc) - // p2 = (1/3) * (2pc + p3) - - x1 = (SplashCoord)(1.0 / 3.0) * (x0 + (SplashCoord)2 * xc); - y1 = (SplashCoord)(1.0 / 3.0) * (y0 + (SplashCoord)2 * yc); - x2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * xc + x3); - y2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * yc + y3); - - p->path->curveTo(x1, y1, x2, y2, x3, y3); - p->needClose = gTrue; - return 0; -} - -static int glyphPathCubicTo(const FT_Vector *ctrl1, const FT_Vector *ctrl2, - const FT_Vector *pt, void *path) { - SplashFTFontPath *p = (SplashFTFontPath *)path; - - p->path->curveTo((SplashCoord)ctrl1->x * p->textScale / 64.0, - (SplashCoord)ctrl1->y * p->textScale / 64.0, - (SplashCoord)ctrl2->x * p->textScale / 64.0, - (SplashCoord)ctrl2->y * p->textScale / 64.0, - (SplashCoord)pt->x * p->textScale / 64.0, - (SplashCoord)pt->y * p->textScale / 64.0); - p->needClose = gTrue; - return 0; -} - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H diff --git a/source/libs/poppler/poppler-src/splash/SplashFTFont.h b/source/libs/poppler/poppler-src/splash/SplashFTFont.h deleted file mode 100644 index 7d5c1e32b30b16aa6bc0c04c1623380a8e9772c7..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFTFont.h +++ /dev/null @@ -1,80 +0,0 @@ -//======================================================================== -// -// SplashFTFont.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2007-2009, 2011 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> -// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHFTFONT_H -#define SPLASHFTFONT_H - -#include "poppler-config.h" - -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include <ft2build.h> -#include FT_FREETYPE_H -#include "SplashFont.h" - -class SplashFTFontFile; - -//------------------------------------------------------------------------ -// SplashFTFont -//------------------------------------------------------------------------ - -class SplashFTFont: public SplashFont { -public: - - SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA); - - virtual ~SplashFTFont(); - - // Munge xFrac and yFrac before calling SplashFont::getGlyph. - GBool getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) override; - - // Rasterize a glyph. The <xFrac> and <yFrac> values are the same - // as described for getGlyph. - GBool makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) override; - - // Return the path for a glyph. - SplashPath *getGlyphPath(int c) override; - - // Return the advance of a glyph. (in 0..1 range) - double getGlyphAdvance(int c) override; - -private: - - FT_Size sizeObj; - FT_Matrix matrix; - FT_Matrix textMatrix; - SplashCoord textScale; - int size; - GBool enableFreeTypeHinting; - GBool enableSlightHinting; -}; - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.cc b/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.cc deleted file mode 100644 index 9fef8f007d11650e4c58b6f2008d8d23cabe027e..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.cc +++ /dev/null @@ -1,180 +0,0 @@ -//======================================================================== -// -// SplashFTFontEngine.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009, 2011, 2012 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> -// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdio.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include "goo/gmem.h" -#include "goo/GooString.h" -#include "goo/gfile.h" -#include "fofi/FoFiTrueType.h" -#include "fofi/FoFiType1C.h" -#include "SplashFTFontFile.h" -#include "SplashFTFontEngine.h" - -#ifdef VMS -#if (__VMS_VER < 70000000) -extern "C" int unlink(char *filename); -#endif -#endif - -//------------------------------------------------------------------------ -// SplashFTFontEngine -//------------------------------------------------------------------------ - -SplashFTFontEngine::SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, - GBool enableSlightHintingA, FT_Library libA) { - FT_Int major, minor, patch; - - aa = aaA; - enableFreeTypeHinting = enableFreeTypeHintingA; - enableSlightHinting = enableSlightHintingA; - lib = libA; - - // as of FT 2.1.8, CID fonts are indexed by CID instead of GID - FT_Library_Version(lib, &major, &minor, &patch); - useCIDs = major > 2 || - (major == 2 && (minor > 1 || (minor == 1 && patch > 7))); -} - -SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA, GBool enableFreeTypeHintingA, - GBool enableSlightHintingA) { - FT_Library libA; - - if (FT_Init_FreeType(&libA)) { - return NULL; - } - return new SplashFTFontEngine(aaA, enableFreeTypeHintingA, enableSlightHintingA, libA); -} - -SplashFTFontEngine::~SplashFTFontEngine() { - FT_Done_FreeType(lib); -} - -SplashFontFile *SplashFTFontEngine::loadType1Font(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - return SplashFTFontFile::loadType1Font(this, idA, src, enc); -} - -SplashFontFile *SplashFTFontEngine::loadType1CFont(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - return SplashFTFontFile::loadType1Font(this, idA, src, enc); -} - -SplashFontFile *SplashFTFontEngine::loadOpenTypeT1CFont(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - return SplashFTFontFile::loadType1Font(this, idA, src, enc); -} - -SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA, - SplashFontSrc *src) { - FoFiType1C *ff; - int *cidToGIDMap; - int nCIDs; - SplashFontFile *ret; - - // check for a CFF font - if (useCIDs) { - cidToGIDMap = NULL; - nCIDs = 0; - } else { - if (src->isFile) { - ff = FoFiType1C::load(src->fileName->getCString()); - } else { - ff = FoFiType1C::make(src->buf, src->bufLen); - } - if (ff) { - cidToGIDMap = ff->getCIDToGIDMap(&nCIDs); - delete ff; - } else { - cidToGIDMap = NULL; - nCIDs = 0; - } - } - ret = SplashFTFontFile::loadCIDFont(this, idA, src, cidToGIDMap, nCIDs); - if (!ret) { - gfree(cidToGIDMap); - } - return ret; -} - -SplashFontFile *SplashFTFontEngine::loadOpenTypeCFFFont(SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToGID, - int codeToGIDLen) { - FoFiTrueType *ff; - int *cidToGIDMap; - int nCIDs; - SplashFontFile *ret; - - cidToGIDMap = NULL; - nCIDs = 0; - if (!codeToGID) { - if (!useCIDs) { - if (src->isFile) { - ff = FoFiTrueType::load(src->fileName->getCString()); - } else { - ff = FoFiTrueType::make(src->buf, src->bufLen); - } - if (ff) { - if (ff->isOpenTypeCFF()) { - cidToGIDMap = ff->getCIDToGIDMap(&nCIDs); - } - delete ff; - } - } - } - ret = SplashFTFontFile::loadCIDFont(this, idA, src, - codeToGID ? codeToGID : cidToGIDMap, - codeToGID ? codeToGIDLen : nCIDs); - if (!ret) { - gfree(cidToGIDMap); - } - return ret; -} - -SplashFontFile *SplashFTFontEngine::loadTrueTypeFont(SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToGID, - int codeToGIDLen, - int faceIndex) { - SplashFontFile *ret; - ret = SplashFTFontFile::loadTrueTypeFont(this, idA, src, - codeToGID, codeToGIDLen, - faceIndex); - return ret; -} - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H diff --git a/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.h b/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.h deleted file mode 100644 index 11bbea74a8058b7addfda46dbfccb99327ebe65e..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFTFontEngine.h +++ /dev/null @@ -1,81 +0,0 @@ -//======================================================================== -// -// SplashFTFontEngine.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> -// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHFTFONTENGINE_H -#define SPLASHFTFONTENGINE_H - -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include <ft2build.h> -#include FT_FREETYPE_H -#include "goo/gtypes.h" - -class SplashFontFile; -class SplashFontFileID; -class SplashFontSrc; - -//------------------------------------------------------------------------ -// SplashFTFontEngine -//------------------------------------------------------------------------ - -class SplashFTFontEngine { -public: - - static SplashFTFontEngine *init(GBool aaA, GBool enableFreeTypeHintingA, GBool enableSlightHinting); - - ~SplashFTFontEngine(); - - // Load fonts. - SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadOpenTypeT1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src); - SplashFontFile *loadOpenTypeCFFFont(SplashFontFileID *idA, SplashFontSrc *src, - int *codeToGID, int codeToGIDLen); - SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src, - int *codeToGID, int codeToGIDLen, int faceIndex = 0); - GBool getAA() { return aa; } - void setAA(GBool aaA) { aa = aaA; } - -private: - - SplashFTFontEngine(GBool aaA, GBool enableFreeTypeHintingA, GBool enableSlightHintingA, FT_Library libA); - - GBool aa; - GBool enableFreeTypeHinting; - GBool enableSlightHinting; - FT_Library lib; - GBool useCIDs; - - friend class SplashFTFontFile; - friend class SplashFTFont; -}; - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashFTFontFile.cc b/source/libs/poppler/poppler-src/splash/SplashFTFontFile.cc deleted file mode 100644 index f0dcf50384bf22b9e4f133fe4b090f765253f161..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFTFontFile.cc +++ /dev/null @@ -1,148 +0,0 @@ -//======================================================================== -// -// SplashFTFontFile.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2014 Adrian Johnson <ajohnson@redneon.com> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include "goo/gmem.h" -#include "goo/GooString.h" -#include "poppler/GfxFont.h" -#include "SplashFTFontEngine.h" -#include "SplashFTFont.h" -#include "SplashFTFontFile.h" - -//------------------------------------------------------------------------ -// SplashFTFontFile -//------------------------------------------------------------------------ - -SplashFontFile *SplashFTFontFile::loadType1Font(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - const char **encA) { - FT_Face faceA; - int *codeToGIDA; - const char *name; - int i; - - if (src->isFile) { - if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA)) - return NULL; - } else { - if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA)) - return NULL; - } - codeToGIDA = (int *)gmallocn(256, sizeof(int)); - for (i = 0; i < 256; ++i) { - codeToGIDA[i] = 0; - if ((name = encA[i])) { - codeToGIDA[i] = (int)FT_Get_Name_Index(faceA, (char *)name); - if (codeToGIDA[i] == 0) { - name = GfxFont::getAlternateName(name); - if (name) { - codeToGIDA[i] = FT_Get_Name_Index(faceA, (char *)name); - } - } - } - } - - return new SplashFTFontFile(engineA, idA, src, - faceA, codeToGIDA, 256, gFalse, gTrue); -} - -SplashFontFile *SplashFTFontFile::loadCIDFont(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToGIDA, - int codeToGIDLenA) { - FT_Face faceA; - - if (src->isFile) { - if (FT_New_Face(engineA->lib, src->fileName->getCString(), 0, &faceA)) - return NULL; - } else { - if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, 0, &faceA)) - return NULL; - } - - return new SplashFTFontFile(engineA, idA, src, - faceA, codeToGIDA, codeToGIDLenA, gFalse, gFalse); -} - -SplashFontFile *SplashFTFontFile::loadTrueTypeFont(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToGIDA, - int codeToGIDLenA, - int faceIndexA) { - FT_Face faceA; - - if (src->isFile) { - if (FT_New_Face(engineA->lib, src->fileName->getCString(), faceIndexA, &faceA)) - return NULL; - } else { - if (FT_New_Memory_Face(engineA->lib, (const FT_Byte *)src->buf, src->bufLen, faceIndexA, &faceA)) - return NULL; - } - - return new SplashFTFontFile(engineA, idA, src, - faceA, codeToGIDA, codeToGIDLenA, gTrue, gFalse); -} - -SplashFTFontFile::SplashFTFontFile(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - FT_Face faceA, - int *codeToGIDA, int codeToGIDLenA, - GBool trueTypeA, GBool type1A): - SplashFontFile(idA, src) -{ - engine = engineA; - face = faceA; - codeToGID = codeToGIDA; - codeToGIDLen = codeToGIDLenA; - trueType = trueTypeA; - type1 = type1A; -} - -SplashFTFontFile::~SplashFTFontFile() { - if (face) { - FT_Done_Face(face); - } - if (codeToGID) { - gfree(codeToGID); - } -} - -SplashFont *SplashFTFontFile::makeFont(SplashCoord *mat, - SplashCoord *textMat) { - SplashFont *font; - - font = new SplashFTFont(this, mat, textMat); - font->initCache(); - return font; -} - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H diff --git a/source/libs/poppler/poppler-src/splash/SplashFTFontFile.h b/source/libs/poppler/poppler-src/splash/SplashFTFontFile.h deleted file mode 100644 index 7a7bb218e635e860e311ffc5649fd88ef6882ba3..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFTFontFile.h +++ /dev/null @@ -1,86 +0,0 @@ -//======================================================================== -// -// SplashFTFontFile.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHFTFONTFILE_H -#define SPLASHFTFONTFILE_H - -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include <ft2build.h> -#include FT_FREETYPE_H -#include "SplashFontFile.h" - -class SplashFontFileID; -class SplashFTFontEngine; - -//------------------------------------------------------------------------ -// SplashFTFontFile -//------------------------------------------------------------------------ - -class SplashFTFontFile: public SplashFontFile { -public: - - static SplashFontFile *loadType1Font(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, const char **encA); - static SplashFontFile *loadCIDFont(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToCIDA, int codeToGIDLenA); - static SplashFontFile *loadTrueTypeFont(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToGIDA, - int codeToGIDLenA, - int faceIndexA=0); - - ~SplashFTFontFile(); - - // Create a new SplashFTFont, i.e., a scaled instance of this font - // file. - SplashFont *makeFont(SplashCoord *mat, - SplashCoord *textMat) override; - -private: - - SplashFTFontFile(SplashFTFontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - FT_Face faceA, - int *codeToGIDA, int codeToGIDLenA, - GBool trueTypeA, GBool type1A); - - SplashFTFontEngine *engine; - FT_Face face; - int *codeToGID; - int codeToGIDLen; - GBool trueType; - GBool type1; - - friend class SplashFTFont; -}; - -#endif // HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashFont.cc b/source/libs/poppler/poppler-src/splash/SplashFont.cc deleted file mode 100644 index 3d6d6b2343e379c6c2ce8c9dd294a1c9ae7c0e13..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFont.cc +++ /dev/null @@ -1,224 +0,0 @@ -//======================================================================== -// -// SplashFont.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2007-2008, 2010, 2014 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <limits.h> -#include <string.h> -#include "goo/gmem.h" -#include "SplashMath.h" -#include "SplashGlyphBitmap.h" -#include "SplashFontFile.h" -#include "SplashFont.h" - -//------------------------------------------------------------------------ - -struct SplashFontCacheTag { - int c; - short xFrac, yFrac; // x and y fractions - int mru; // valid bit (0x80000000) and MRU index - int x, y, w, h; // offset and size of glyph -}; - -//------------------------------------------------------------------------ -// SplashFont -//------------------------------------------------------------------------ - -SplashFont::SplashFont(SplashFontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA, GBool aaA) { - fontFile = fontFileA; - fontFile->incRefCnt(); - mat[0] = matA[0]; - mat[1] = matA[1]; - mat[2] = matA[2]; - mat[3] = matA[3]; - textMat[0] = textMatA[0]; - textMat[1] = textMatA[1]; - textMat[2] = textMatA[2]; - textMat[3] = textMatA[3]; - aa = aaA; - - cache = NULL; - cacheTags = NULL; - - xMin = yMin = xMax = yMax = 0; -} - -void SplashFont::initCache() { - int i; - - // this should be (max - min + 1), but we add some padding to - // deal with rounding errors - glyphW = xMax - xMin + 3; - glyphH = yMax - yMin + 3; - if (glyphW > INT_MAX / glyphH) { - glyphSize = -1; - } else { - if (aa) { - glyphSize = glyphW * glyphH; - } else { - glyphSize = ((glyphW + 7) >> 3) * glyphH; - } - } - - // set up the glyph pixmap cache - cacheAssoc = 8; - if (glyphSize <= 64) { - cacheSets = 32; - } else if (glyphSize <= 128) { - cacheSets = 16; - } else if (glyphSize <= 256) { - cacheSets = 8; - } else if (glyphSize <= 512) { - cacheSets = 4; - } else if (glyphSize <= 1024) { - cacheSets = 2; - } else { - cacheSets = 1; - } - cache = (Guchar *)gmallocn_checkoverflow(cacheSets* cacheAssoc, glyphSize); - if (cache != NULL) { - cacheTags = (SplashFontCacheTag *)gmallocn(cacheSets * cacheAssoc, - sizeof(SplashFontCacheTag)); - for (i = 0; i < cacheSets * cacheAssoc; ++i) { - cacheTags[i].mru = i & (cacheAssoc - 1); - } - } else { - cacheAssoc = 0; - } -} - -SplashFont::~SplashFont() { - fontFile->decRefCnt(); - if (cache) { - gfree(cache); - } - if (cacheTags) { - gfree(cacheTags); - } -} - -GBool SplashFont::getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { - SplashGlyphBitmap bitmap2; - int size; - Guchar *p; - int i, j, k; - - // no fractional coordinates for large glyphs or non-anti-aliased - // glyphs - if (!aa || glyphH > 50) { - xFrac = yFrac = 0; - } - - // check the cache - i = (c & (cacheSets - 1)) * cacheAssoc; - for (j = 0; j < cacheAssoc; ++j) { - if ((cacheTags[i+j].mru & 0x80000000) && - cacheTags[i+j].c == c && - (int)cacheTags[i+j].xFrac == xFrac && - (int)cacheTags[i+j].yFrac == yFrac) { - bitmap->x = cacheTags[i+j].x; - bitmap->y = cacheTags[i+j].y; - bitmap->w = cacheTags[i+j].w; - bitmap->h = cacheTags[i+j].h; - for (k = 0; k < cacheAssoc; ++k) { - if (k != j && - (cacheTags[i+k].mru & 0x7fffffff) < - (cacheTags[i+j].mru & 0x7fffffff)) { - ++cacheTags[i+k].mru; - } - } - cacheTags[i+j].mru = 0x80000000; - bitmap->aa = aa; - bitmap->data = cache + (i+j) * glyphSize; - bitmap->freeData = gFalse; - - *clipRes = clip->testRect(x0 - bitmap->x, - y0 - bitmap->y, - x0 - bitmap->x + bitmap->w - 1, - y0 - bitmap->y + bitmap->h - 1); - - return gTrue; - } - } - - // generate the glyph bitmap - if (!makeGlyph(c, xFrac, yFrac, &bitmap2, x0, y0, clip, clipRes)) { - return gFalse; - } - - if (*clipRes == splashClipAllOutside) - { - bitmap->freeData = gFalse; - if (bitmap2.freeData) gfree(bitmap2.data); - return gTrue; - } - - // if the glyph doesn't fit in the bounding box, return a temporary - // uncached bitmap - if (bitmap2.w > glyphW || bitmap2.h > glyphH) { - *bitmap = bitmap2; - return gTrue; - } - - // insert glyph pixmap in cache - if (aa) { - size = bitmap2.w * bitmap2.h; - } else { - size = ((bitmap2.w + 7) >> 3) * bitmap2.h; - } - p = NULL; // make gcc happy - if (cacheAssoc == 0) - { - // we had problems on the malloc of the cache, so ignore it - *bitmap = bitmap2; - } - else - { - for (j = 0; j < cacheAssoc; ++j) { - if ((cacheTags[i+j].mru & 0x7fffffff) == cacheAssoc - 1) { - cacheTags[i+j].mru = 0x80000000; - cacheTags[i+j].c = c; - cacheTags[i+j].xFrac = (short)xFrac; - cacheTags[i+j].yFrac = (short)yFrac; - cacheTags[i+j].x = bitmap2.x; - cacheTags[i+j].y = bitmap2.y; - cacheTags[i+j].w = bitmap2.w; - cacheTags[i+j].h = bitmap2.h; - p = cache + (i+j) * glyphSize; - memcpy(p, bitmap2.data, size); - } else { - ++cacheTags[i+j].mru; - } - } - *bitmap = bitmap2; - bitmap->data = p; - bitmap->freeData = gFalse; - if (bitmap2.freeData) { - gfree(bitmap2.data); - } - } - return gTrue; -} diff --git a/source/libs/poppler/poppler-src/splash/SplashFont.h b/source/libs/poppler/poppler-src/splash/SplashFont.h deleted file mode 100644 index 78b00d2dcaf008bf9a874326a4b94adeb715dc5c..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFont.h +++ /dev/null @@ -1,121 +0,0 @@ -//======================================================================== -// -// SplashFont.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2007-2008 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHFONT_H -#define SPLASHFONT_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "goo/gtypes.h" -#include "SplashTypes.h" -#include "SplashClip.h" - -struct SplashGlyphBitmap; -struct SplashFontCacheTag; -class SplashFontFile; -class SplashPath; - -//------------------------------------------------------------------------ - -// Fractional positioning uses this many bits to the right of the -// decimal points. -#define splashFontFractionBits 2 -#define splashFontFraction (1 << splashFontFractionBits) -#define splashFontFractionMul \ - ((SplashCoord)1 / (SplashCoord)splashFontFraction) - -//------------------------------------------------------------------------ -// SplashFont -//------------------------------------------------------------------------ - -class SplashFont { -public: - - SplashFont(SplashFontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA, GBool aaA); - - // This must be called after the constructor, so that the subclass - // constructor has a chance to compute the bbox. - void initCache(); - - virtual ~SplashFont(); - - SplashFontFile *getFontFile() { return fontFile; } - - // Return true if <this> matches the specified font file and matrix. - GBool matches(SplashFontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA) { - return fontFileA == fontFile && - matA[0] == mat[0] && matA[1] == mat[1] && - matA[2] == mat[2] && matA[3] == mat[3] && - textMatA[0] == textMat[0] && textMatA[1] == textMat[1] && - textMatA[2] == textMat[2] && textMatA[3] == textMat[3]; - } - - // Get a glyph - this does a cache lookup first, and if not found, - // creates a new bitmap and adds it to the cache. The <xFrac> and - // <yFrac> values are splashFontFractionBits bits each, representing - // the numerators of fractions in [0, 1), where the denominator is - // splashFontFraction = 1 << splashFontFractionBits. Subclasses - // should override this to zero out xFrac and/or yFrac if they don't - // support fractional coordinates. - virtual GBool getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); - - // Rasterize a glyph. The <xFrac> and <yFrac> values are the same - // as described for getGlyph. - virtual GBool makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) = 0; - - // Return the path for a glyph. - virtual SplashPath *getGlyphPath(int c) = 0; - - // Return the advance of a glyph. (in 0..1 range) - // < 0 means not known - virtual double getGlyphAdvance(int c) { return -1; } - - // Return the font transform matrix. - SplashCoord *getMatrix() { return mat; } - - // Return the glyph bounding box. - void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA) - { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } - -protected: - - SplashFontFile *fontFile; - SplashCoord mat[4]; // font transform matrix - // (text space -> device space) - SplashCoord textMat[4]; // text transform matrix - // (text space -> user space) - GBool aa; // anti-aliasing - int xMin, yMin, xMax, yMax; // glyph bounding box - Guchar *cache; // glyph bitmap cache - SplashFontCacheTag * // cache tags - cacheTags; - int glyphW, glyphH; // size of glyph bitmaps - int glyphSize; // size of glyph bitmaps, in bytes - int cacheSets; // number of sets in cache - int cacheAssoc; // cache associativity (glyphs per set) -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashFontEngine.cc b/source/libs/poppler/poppler-src/splash/SplashFontEngine.cc deleted file mode 100644 index 73ef8de087797cea7899b426203d6e6b1a23c33b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFontEngine.cc +++ /dev/null @@ -1,337 +0,0 @@ -//======================================================================== -// -// SplashFontEngine.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> -// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> -// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// Copyright (C) 2015 Dmytro Morgun <lztoad@gmail.com> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#if HAVE_T1LIB_H -#include <t1lib.h> -#endif - -#include <stdlib.h> -#include <stdio.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif -#include "goo/gmem.h" -#include "goo/GooString.h" -#include "SplashMath.h" -#include "SplashT1FontEngine.h" -#include "SplashFTFontEngine.h" -#include "SplashFontFile.h" -#include "SplashFontFileID.h" -#include "SplashFont.h" -#include "SplashFontEngine.h" - -#ifdef VMS -#if (__VMS_VER < 70000000) -extern "C" int unlink(char *filename); -#endif -#endif - -#ifdef VMS -#if (__VMS_VER < 70000000) -extern "C" int unlink(char *filename); -#endif -#endif - -//------------------------------------------------------------------------ -// SplashFontEngine -//------------------------------------------------------------------------ - -SplashFontEngine::SplashFontEngine( -#if HAVE_T1LIB_H - GBool enableT1lib, -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - GBool enableFreeType, - GBool enableFreeTypeHinting, - GBool enableSlightHinting, -#endif - GBool aa) { - int i; - - for (i = 0; i < splashFontCacheSize; ++i) { - fontCache[i] = NULL; - } - -#if HAVE_T1LIB_H - if (enableT1lib) { - t1Engine = SplashT1FontEngine::init(aa); - } else { - t1Engine = NULL; - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (enableFreeType) { - ftEngine = SplashFTFontEngine::init(aa, enableFreeTypeHinting, enableSlightHinting); - } else { - ftEngine = NULL; - } -#endif -} - -SplashFontEngine::~SplashFontEngine() { - int i; - - for (i = 0; i < splashFontCacheSize; ++i) { - if (fontCache[i]) { - delete fontCache[i]; - } - } - -#if HAVE_T1LIB_H - if (t1Engine) { - delete t1Engine; - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (ftEngine) { - delete ftEngine; - } -#endif -} - -SplashFontFile *SplashFontEngine::getFontFile(SplashFontFileID *id) { - SplashFontFile *fontFile; - int i; - - for (i = 0; i < splashFontCacheSize; ++i) { - if (fontCache[i]) { - fontFile = fontCache[i]->getFontFile(); - if (fontFile && fontFile->getID()->matches(id)) { - return fontFile; - } - } - } - return NULL; -} - -SplashFontFile *SplashFontEngine::loadType1Font(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - SplashFontFile *fontFile; - - fontFile = NULL; -#if HAVE_T1LIB_H - if (!fontFile && t1Engine) { - fontFile = t1Engine->loadType1Font(idA, src, enc); - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (!fontFile && ftEngine) { - fontFile = ftEngine->loadType1Font(idA, src, enc); - } -#endif - - // delete the (temporary) font file -- with Unix hard link - // semantics, this will remove the last link; otherwise it will - // return an error, leaving the file to be deleted later (if - // loadXYZFont failed, the file will always be deleted) - if (src->isFile) - src->unref(); - - return fontFile; -} - -SplashFontFile *SplashFontEngine::loadType1CFont(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - SplashFontFile *fontFile; - - fontFile = NULL; -#if HAVE_T1LIB_H - if (!fontFile && t1Engine) { - fontFile = t1Engine->loadType1CFont(idA, src, enc); - } -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (!fontFile && ftEngine) { - fontFile = ftEngine->loadType1CFont(idA, src, enc); - } -#endif - - // delete the (temporary) font file -- with Unix hard link - // semantics, this will remove the last link; otherwise it will - // return an error, leaving the file to be deleted later (if - // loadXYZFont failed, the file will always be deleted) - if (src->isFile) - src->unref(); - - return fontFile; -} - -SplashFontFile *SplashFontEngine::loadOpenTypeT1CFont(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - SplashFontFile *fontFile; - - fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (!fontFile && ftEngine) { - fontFile = ftEngine->loadOpenTypeT1CFont(idA, src, enc); - } -#endif - - // delete the (temporary) font file -- with Unix hard link - // semantics, this will remove the last link; otherwise it will - // return an error, leaving the file to be deleted later (if - // loadXYZFont failed, the file will always be deleted) - if (src->isFile) - src->unref(); - - return fontFile; -} - -SplashFontFile *SplashFontEngine::loadCIDFont(SplashFontFileID *idA, - SplashFontSrc *src) { - SplashFontFile *fontFile; - - fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (!fontFile && ftEngine) { - fontFile = ftEngine->loadCIDFont(idA, src); - } -#endif - - // delete the (temporary) font file -- with Unix hard link - // semantics, this will remove the last link; otherwise it will - // return an error, leaving the file to be deleted later (if - // loadXYZFont failed, the file will always be deleted) - if (src->isFile) - src->unref(); - - return fontFile; -} - -SplashFontFile *SplashFontEngine::loadOpenTypeCFFFont(SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToGID, - int codeToGIDLen) { - SplashFontFile *fontFile; - - fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (!fontFile && ftEngine) { - fontFile = ftEngine->loadOpenTypeCFFFont(idA, src, codeToGID, codeToGIDLen); - } -#endif - - // delete the (temporary) font file -- with Unix hard link - // semantics, this will remove the last link; otherwise it will - // return an error, leaving the file to be deleted later (if - // loadXYZFont failed, the file will always be deleted) - if (src->isFile) - src->unref(); - - return fontFile; -} - -SplashFontFile *SplashFontEngine::loadTrueTypeFont(SplashFontFileID *idA, - SplashFontSrc *src, - int *codeToGID, - int codeToGIDLen, - int faceIndex) { - SplashFontFile *fontFile; - - fontFile = NULL; -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - if (!fontFile && ftEngine) { - fontFile = ftEngine->loadTrueTypeFont(idA, src, - codeToGID, codeToGIDLen, faceIndex); - } -#endif - - if (!fontFile) { - gfree(codeToGID); - } - - // delete the (temporary) font file -- with Unix hard link - // semantics, this will remove the last link; otherwise it will - // return an error, leaving the file to be deleted later (if - // loadXYZFont failed, the file will always be deleted) - if (src->isFile) - src->unref(); - - return fontFile; -} - -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H -GBool SplashFontEngine::getAA() { - return (ftEngine == NULL) ? gFalse : ftEngine->getAA(); -} - -void SplashFontEngine::setAA(GBool aa) { - if (ftEngine != NULL) { - ftEngine->setAA(aa); - } -} -#endif - -SplashFont *SplashFontEngine::getFont(SplashFontFile *fontFile, - SplashCoord *textMat, - SplashCoord *ctm) { - SplashCoord mat[4]; - SplashFont *font; - int i, j; - - mat[0] = textMat[0] * ctm[0] + textMat[1] * ctm[2]; - mat[1] = -(textMat[0] * ctm[1] + textMat[1] * ctm[3]); - mat[2] = textMat[2] * ctm[0] + textMat[3] * ctm[2]; - mat[3] = -(textMat[2] * ctm[1] + textMat[3] * ctm[3]); - if (!splashCheckDet(mat[0], mat[1], mat[2], mat[3], 0.01)) { - // avoid a singular (or close-to-singular) matrix - mat[0] = 0.01; mat[1] = 0; - mat[2] = 0; mat[3] = 0.01; - } - - font = fontCache[0]; - if (font && font->matches(fontFile, mat, textMat)) { - return font; - } - for (i = 1; i < splashFontCacheSize; ++i) { - font = fontCache[i]; - if (font && font->matches(fontFile, mat, textMat)) { - for (j = i; j > 0; --j) { - fontCache[j] = fontCache[j-1]; - } - fontCache[0] = font; - return font; - } - } - font = fontFile->makeFont(mat, textMat); - if (fontCache[splashFontCacheSize - 1]) { - delete fontCache[splashFontCacheSize - 1]; - } - for (j = splashFontCacheSize - 1; j > 0; --j) { - fontCache[j] = fontCache[j-1]; - } - fontCache[0] = font; - return font; -} diff --git a/source/libs/poppler/poppler-src/splash/SplashFontEngine.h b/source/libs/poppler/poppler-src/splash/SplashFontEngine.h deleted file mode 100644 index 6502ea5a7fad3c7f8ec655be68e61a0652d8cf63..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFontEngine.h +++ /dev/null @@ -1,110 +0,0 @@ -//======================================================================== -// -// SplashFontEngine.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009 Petr Gajdos <pgajdos@novell.com> -// Copyright (C) 2009, 2011 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHFONTENGINE_H -#define SPLASHFONTENGINE_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "goo/gtypes.h" -#include "SplashTypes.h" - -class SplashT1FontEngine; -class SplashFTFontEngine; -class SplashDTFontEngine; -class SplashDT4FontEngine; -class SplashFontFile; -class SplashFontFileID; -class SplashFont; -class SplashFontSrc; - -//------------------------------------------------------------------------ - -#define splashFontCacheSize 16 - -//------------------------------------------------------------------------ -// SplashFontEngine -//------------------------------------------------------------------------ - -class SplashFontEngine { -public: - - // Create a font engine. - SplashFontEngine( -#if HAVE_T1LIB_H - GBool enableT1lib, -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - GBool enableFreeType, - GBool enableFreeTypeHinting, - GBool enableSlightHinting, -#endif - GBool aa); - - ~SplashFontEngine(); - - // Get a font file from the cache. Returns NULL if there is no - // matching entry in the cache. - SplashFontFile *getFontFile(SplashFontFileID *id); - - // Load fonts - these create new SplashFontFile objects. - SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadOpenTypeT1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadCIDFont(SplashFontFileID *idA, SplashFontSrc *src); - SplashFontFile *loadOpenTypeCFFFont(SplashFontFileID *idA, SplashFontSrc *src, - int *codeToGID, int codeToGIDLen); - SplashFontFile *loadTrueTypeFont(SplashFontFileID *idA, SplashFontSrc *src, - int *codeToGID, int codeToGIDLen, int faceIndex = 0); - - // Get a font - this does a cache lookup first, and if not found, - // creates a new SplashFont object and adds it to the cache. The - // matrix, mat = textMat * ctm: - // [ mat[0] mat[1] ] - // [ mat[2] mat[3] ] - // specifies the font transform in PostScript style: - // [x' y'] = [x y] * mat - // Note that the Splash y axis points downward. - SplashFont *getFont(SplashFontFile *fontFile, - SplashCoord *textMat, SplashCoord *ctm); -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - GBool getAA(); - void setAA(GBool aa); -#endif - -private: - - SplashFont *fontCache[splashFontCacheSize]; - -#if HAVE_T1LIB_H - SplashT1FontEngine *t1Engine; -#endif -#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H - SplashFTFontEngine *ftEngine; -#endif -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashFontFile.cc b/source/libs/poppler/poppler-src/splash/SplashFontFile.cc deleted file mode 100644 index 68e8608b6a70a0e1d003862906111406ff233b50..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFontFile.cc +++ /dev/null @@ -1,124 +0,0 @@ -//======================================================================== -// -// SplashFontFile.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdio.h> -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif -#include "goo/gmem.h" -#include "goo/GooString.h" -#include "SplashFontFile.h" -#include "SplashFontFileID.h" - -#ifdef VMS -#if (__VMS_VER < 70000000) -extern "C" int unlink(char *filename); -#endif -#endif - -//------------------------------------------------------------------------ -// SplashFontFile -//------------------------------------------------------------------------ - -SplashFontFile::SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA) { - id = idA; - src = srcA; - src->ref(); - refCnt = 0; - doAdjustMatrix = gFalse; -} - -SplashFontFile::~SplashFontFile() { - src->unref(); - delete id; -} - -void SplashFontFile::incRefCnt() { - ++refCnt; -} - -void SplashFontFile::decRefCnt() { - if (!--refCnt) { - delete this; - } -} - -// - -SplashFontSrc::SplashFontSrc() { - isFile = gFalse; - deleteSrc = gFalse; - fileName = NULL; - buf = NULL; - refcnt = 1; -} - -SplashFontSrc::~SplashFontSrc() { - if (deleteSrc) { - if (isFile) { - if (fileName) - unlink(fileName->getCString()); - } else { - if (buf) - gfree(buf); - } - } - - if (isFile && fileName) - delete fileName; -} - -void SplashFontSrc::ref() { - refcnt++; -} - -void SplashFontSrc::unref() { - if (! --refcnt) - delete this; -} - -void SplashFontSrc::setFile(GooString *file, GBool del) -{ - isFile = gTrue; - fileName = file->copy(); - deleteSrc = del; -} - -void SplashFontSrc::setFile(const char *file, GBool del) -{ - isFile = gTrue; - fileName = new GooString(file); - deleteSrc = del; -} - -void SplashFontSrc::setBuf(char *bufA, int bufLenA, GBool del) -{ - isFile = gFalse; - buf = bufA; - bufLen = bufLenA; - deleteSrc = del; -} diff --git a/source/libs/poppler/poppler-src/splash/SplashFontFile.h b/source/libs/poppler/poppler-src/splash/SplashFontFile.h deleted file mode 100644 index ec87504b9bc593d602b68828f92d28154e8f73e4..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFontFile.h +++ /dev/null @@ -1,95 +0,0 @@ -//======================================================================== -// -// SplashFontFile.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2008, 2010 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHFONTFILE_H -#define SPLASHFONTFILE_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "goo/gtypes.h" -#include "SplashTypes.h" - -class GooString; -class SplashFontEngine; -class SplashFont; -class SplashFontFileID; - -//------------------------------------------------------------------------ -// SplashFontFile -//------------------------------------------------------------------------ - -class SplashFontSrc { -public: - SplashFontSrc(); - - void setFile(GooString *file, GBool del); - void setFile(const char *file, GBool del); - void setBuf(char *bufA, int buflenA, GBool del); - - void ref(); - void unref(); - - GBool isFile; - GooString *fileName; - char *buf; - int bufLen; - -private: - ~SplashFontSrc(); - int refcnt; - GBool deleteSrc; -}; - -class SplashFontFile { -public: - - virtual ~SplashFontFile(); - - // Create a new SplashFont, i.e., a scaled instance of this font - // file. - virtual SplashFont *makeFont(SplashCoord *mat, SplashCoord *textMat) = 0; - - // Get the font file ID. - SplashFontFileID *getID() { return id; } - - // Increment the reference count. - void incRefCnt(); - - // Decrement the reference count. If the new value is zero, delete - // the SplashFontFile object. - void decRefCnt(); - - GBool doAdjustMatrix; - -protected: - - SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA); - - SplashFontFileID *id; - SplashFontSrc *src; - int refCnt; - - friend class SplashFontEngine; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashFontFileID.cc b/source/libs/poppler/poppler-src/splash/SplashFontFileID.cc deleted file mode 100644 index a66dabf61e3173b9543f935182905fba2ded796d..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFontFileID.cc +++ /dev/null @@ -1,23 +0,0 @@ -//======================================================================== -// -// SplashFontFileID.cc -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include "SplashFontFileID.h" - -//------------------------------------------------------------------------ -// SplashFontFileID -//------------------------------------------------------------------------ - -SplashFontFileID::SplashFontFileID() { -} - -SplashFontFileID::~SplashFontFileID() { -} diff --git a/source/libs/poppler/poppler-src/splash/SplashFontFileID.h b/source/libs/poppler/poppler-src/splash/SplashFontFileID.h deleted file mode 100644 index cfd89ebb56aa4492f5ab9094fb7a3c5a3aa4b987..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashFontFileID.h +++ /dev/null @@ -1,28 +0,0 @@ -//======================================================================== -// -// SplashFontFileID.h -// -//======================================================================== - -#ifndef SPLASHFONTFILEID_H -#define SPLASHFONTFILEID_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "goo/gtypes.h" - -//------------------------------------------------------------------------ -// SplashFontFileID -//------------------------------------------------------------------------ - -class SplashFontFileID { -public: - - SplashFontFileID(); - virtual ~SplashFontFileID(); - virtual GBool matches(SplashFontFileID *id) = 0; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashGlyphBitmap.h b/source/libs/poppler/poppler-src/splash/SplashGlyphBitmap.h deleted file mode 100644 index c062c106e6a42b5d48290d90f46aa826d528193b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashGlyphBitmap.h +++ /dev/null @@ -1,24 +0,0 @@ -//======================================================================== -// -// SplashGlyphBitmap.h -// -//======================================================================== - -#ifndef SPLASHGLYPHBITMAP_H -#define SPLASHGLYPHBITMAP_H - -#include "goo/gtypes.h" - -//------------------------------------------------------------------------ -// SplashGlyphBitmap -//------------------------------------------------------------------------ - -struct SplashGlyphBitmap { - int x, y, w, h; // offset and size of glyph - GBool aa; // anti-aliased: true means 8-bit alpha - // bitmap; false means 1-bit - Guchar *data; // bitmap data - GBool freeData; // true if data memory should be freed -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashMath.h b/source/libs/poppler/poppler-src/splash/SplashMath.h deleted file mode 100644 index ca73c2bd1f3169ed854d2a97da8008ca3168e68b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashMath.h +++ /dev/null @@ -1,245 +0,0 @@ -//======================================================================== -// -// SplashMath.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2009-2011 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHMATH_H -#define SPLASHMATH_H - -#include "poppler-config.h" - -#if USE_FIXEDPOINT -#include "goo/FixedPoint.h" -#else -#include <math.h> -#endif -#include "SplashTypes.h" - -static inline SplashCoord splashAbs(SplashCoord x) { -#if USE_FIXEDPOINT - return FixedPoint::abs(x); -#elif USE_FLOAT - return fabsf(x); -#else - return fabs(x); -#endif -} - -static inline int splashFloor(SplashCoord x) { - #if USE_FIXEDPOINT - return FixedPoint::floor(x); - #elif USE_FLOAT - return (int)floorf(x); - #elif __GNUC__ && __i386__ - // floor() and (int)() are implemented separately, which results - // in changing the FPCW multiple times - so we optimize it with - // some inline assembly - Gushort oldCW, newCW, t; - int result; - - __asm__ volatile("fldl %4\n" - "fnstcw %0\n" - "movw %0, %3\n" - "andw $0xf3ff, %3\n" - "orw $0x0400, %3\n" - "movw %3, %1\n" // round down - "fldcw %1\n" - "fistpl %2\n" - "fldcw %0\n" - : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) - : "m" (x)); - return result; - #elif defined(WIN32) && defined(_M_IX86) - // floor() and (int)() are implemented separately, which results - // in changing the FPCW multiple times - so we optimize it with - // some inline assembly - Gushort oldCW, newCW; - int result; - - __asm fld QWORD PTR x - __asm fnstcw WORD PTR oldCW - __asm mov ax, WORD PTR oldCW - __asm and ax, 0xf3ff - __asm or ax, 0x0400 - __asm mov WORD PTR newCW, ax // round down - __asm fldcw WORD PTR newCW - __asm fistp DWORD PTR result - __asm fldcw WORD PTR oldCW - return result; - #else - if (x > 0) return (int)x; - else return (int)floor(x); - #endif -} - -static inline int splashCeil(SplashCoord x) { -#if USE_FIXEDPOINT - return FixedPoint::ceil(x); -#elif USE_FLOAT - return (int)ceilf(x); -#elif __GNUC__ && __i386__ - // ceil() and (int)() are implemented separately, which results - // in changing the FPCW multiple times - so we optimize it with - // some inline assembly - Gushort oldCW, newCW, t; - int result; - - __asm__ volatile("fldl %4\n" - "fnstcw %0\n" - "movw %0, %3\n" - "andw $0xf3ff, %3\n" - "orw $0x0800, %3\n" - "movw %3, %1\n" // round up - "fldcw %1\n" - "fistpl %2\n" - "fldcw %0\n" - : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) - : "m" (x)); - return result; -#elif defined(WIN32) && defined(_M_IX86) - // ceil() and (int)() are implemented separately, which results - // in changing the FPCW multiple times - so we optimize it with - // some inline assembly - Gushort oldCW, newCW; - int result; - - __asm fld QWORD PTR x - __asm fnstcw WORD PTR oldCW - __asm mov ax, WORD PTR oldCW - __asm and ax, 0xf3ff - __asm or ax, 0x0800 - __asm mov WORD PTR newCW, ax // round up - __asm fldcw WORD PTR newCW - __asm fistp DWORD PTR result - __asm fldcw WORD PTR oldCW - return result; -#else - return (int)ceil(x); -#endif -} - -static inline int splashRound(SplashCoord x) { -#if USE_FIXEDPOINT - return FixedPoint::round(x); -#elif __GNUC__ && __i386__ - // this could use round-to-nearest mode and avoid the "+0.5", - // but that produces slightly different results (because i+0.5 - // sometimes rounds up and sometimes down using the even rule) - Gushort oldCW, newCW, t; - int result; - - x += 0.5; - __asm__ volatile("fldl %4\n" - "fnstcw %0\n" - "movw %0, %3\n" - "andw $0xf3ff, %3\n" - "orw $0x0400, %3\n" - "movw %3, %1\n" // round down - "fldcw %1\n" - "fistpl %2\n" - "fldcw %0\n" - : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) - : "m" (x)); - return result; -#elif defined(WIN32) && defined(_M_IX86) - // this could use round-to-nearest mode and avoid the "+0.5", - // but that produces slightly different results (because i+0.5 - // sometimes rounds up and sometimes down using the even rule) - Gushort oldCW, newCW; - int result; - - x += 0.5; - __asm fld QWORD PTR x - __asm fnstcw WORD PTR oldCW - __asm mov ax, WORD PTR oldCW - __asm and ax, 0xf3ff - __asm or ax, 0x0400 - __asm mov WORD PTR newCW, ax // round down - __asm fldcw WORD PTR newCW - __asm fistp DWORD PTR result - __asm fldcw WORD PTR oldCW - return result; -#else - return (int)splashFloor(x + 0.5); -#endif -} - -static inline SplashCoord splashAvg(SplashCoord x, SplashCoord y) { -#if USE_FIXEDPOINT - return FixedPoint::avg(x, y); -#else - return 0.5 * (x + y); -#endif -} - -static inline SplashCoord splashSqrt(SplashCoord x) { -#if USE_FIXEDPOINT - return FixedPoint::sqrt(x); -#elif USE_FLOAT - return sqrtf(x); -#else - return sqrt(x); -#endif -} - -static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) { -#if USE_FIXEDPOINT - return FixedPoint::pow(x, y); -#elif USE_FLOAT - return powf(x, y); -#else - return pow(x, y); -#endif -} - -static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1) { - SplashCoord dx, dy; - dx = x1 - x0; - dy = y1 - y0; -#if USE_FIXEDPOINT - // this handles the situation where dx*dx or dy*dy is too large to - // fit in the 16.16 fixed point format - SplashCoord dxa, dya, d; - dxa = splashAbs(dx); - dya = splashAbs(dy); - if (dxa == 0 && dya == 0) { - return 0; - } else if (dxa > dya) { - d = dya / dxa; - return dxa * FixedPoint::sqrt(d*d + 1); - } else { - d = dxa / dya; - return dya * FixedPoint::sqrt(d*d + 1); - } -#else - return splashSqrt(dx * dx + dy * dy); -#endif -} - -static inline GBool splashCheckDet(SplashCoord m11, SplashCoord m12, - SplashCoord m21, SplashCoord m22, - SplashCoord epsilon) { -#if USE_FIXEDPOINT - return FixedPoint::checkDet(m11, m12, m21, m22, epsilon); -#else - return fabs(m11 * m22 - m12 * m21) >= epsilon; -#endif -} - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashPath.cc b/source/libs/poppler/poppler-src/splash/SplashPath.cc deleted file mode 100644 index bc4ccd524a49c1003098110ec1eea93c7e79451d..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashPath.cc +++ /dev/null @@ -1,185 +0,0 @@ -//======================================================================== -// -// SplashPath.cc -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <string.h> -#include "goo/gmem.h" -#include "SplashErrorCodes.h" -#include "SplashPath.h" - -//------------------------------------------------------------------------ -// SplashPath -//------------------------------------------------------------------------ - -// A path can be in three possible states: -// -// 1. no current point -- zero or more finished subpaths -// [curSubpath == length] -// -// 2. one point in subpath -// [curSubpath == length - 1] -// -// 3. open subpath with two or more points -// [curSubpath < length - 1] - -SplashPath::SplashPath() { - pts = NULL; - flags = NULL; - length = size = 0; - curSubpath = 0; - hints = NULL; - hintsLength = hintsSize = 0; -} - -SplashPath::SplashPath(SplashPath *path) { - length = path->length; - size = path->size; - pts = (SplashPathPoint *)gmallocn(size, sizeof(SplashPathPoint)); - flags = (Guchar *)gmallocn(size, sizeof(Guchar)); - memcpy(pts, path->pts, length * sizeof(SplashPathPoint)); - memcpy(flags, path->flags, length * sizeof(Guchar)); - curSubpath = path->curSubpath; - if (path->hints) { - hintsLength = hintsSize = path->hintsLength; - hints = (SplashPathHint *)gmallocn(hintsSize, sizeof(SplashPathHint)); - memcpy(hints, path->hints, hintsLength * sizeof(SplashPathHint)); - } else { - hints = NULL; - } -} - -SplashPath::~SplashPath() { - gfree(pts); - gfree(flags); - gfree(hints); -} - -// Add space for <nPts> more points. -void SplashPath::grow(int nPts) { - if (length + nPts > size) { - if (size == 0) { - size = 32; - } - while (size < length + nPts) { - size *= 2; - } - pts = (SplashPathPoint *)greallocn(pts, size, sizeof(SplashPathPoint)); - flags = (Guchar *)greallocn(flags, size, sizeof(Guchar)); - } -} - -void SplashPath::append(SplashPath *path) { - int i; - - curSubpath = length + path->curSubpath; - grow(path->length); - for (i = 0; i < path->length; ++i) { - pts[length] = path->pts[i]; - flags[length] = path->flags[i]; - ++length; - } -} - -SplashError SplashPath::moveTo(SplashCoord x, SplashCoord y) { - if (onePointSubpath()) { - return splashErrBogusPath; - } - grow(1); - pts[length].x = x; - pts[length].y = y; - flags[length] = splashPathFirst | splashPathLast; - curSubpath = length++; - return splashOk; -} - -SplashError SplashPath::lineTo(SplashCoord x, SplashCoord y) { - if (noCurrentPoint()) { - return splashErrNoCurPt; - } - flags[length-1] &= ~splashPathLast; - grow(1); - pts[length].x = x; - pts[length].y = y; - flags[length] = splashPathLast; - ++length; - return splashOk; -} - -SplashError SplashPath::curveTo(SplashCoord x1, SplashCoord y1, - SplashCoord x2, SplashCoord y2, - SplashCoord x3, SplashCoord y3) { - if (noCurrentPoint()) { - return splashErrNoCurPt; - } - flags[length-1] &= ~splashPathLast; - grow(3); - pts[length].x = x1; - pts[length].y = y1; - flags[length] = splashPathCurve; - ++length; - pts[length].x = x2; - pts[length].y = y2; - flags[length] = splashPathCurve; - ++length; - pts[length].x = x3; - pts[length].y = y3; - flags[length] = splashPathLast; - ++length; - return splashOk; -} - -SplashError SplashPath::close(GBool force) { - if (noCurrentPoint()) { - return splashErrNoCurPt; - } - if (force || - curSubpath == length - 1 || - pts[length - 1].x != pts[curSubpath].x || - pts[length - 1].y != pts[curSubpath].y) { - lineTo(pts[curSubpath].x, pts[curSubpath].y); - } - flags[curSubpath] |= splashPathClosed; - flags[length - 1] |= splashPathClosed; - curSubpath = length; - return splashOk; -} - -void SplashPath::addStrokeAdjustHint(int ctrl0, int ctrl1, - int firstPt, int lastPt) { - if (hintsLength == hintsSize) { - hintsSize = hintsLength ? 2 * hintsLength : 8; - hints = (SplashPathHint *)greallocn(hints, hintsSize, - sizeof(SplashPathHint)); - } - hints[hintsLength].ctrl0 = ctrl0; - hints[hintsLength].ctrl1 = ctrl1; - hints[hintsLength].firstPt = firstPt; - hints[hintsLength].lastPt = lastPt; - ++hintsLength; -} - -void SplashPath::offset(SplashCoord dx, SplashCoord dy) { - int i; - - for (i = 0; i < length; ++i) { - pts[i].x += dx; - pts[i].y += dy; - } -} - -GBool SplashPath::getCurPt(SplashCoord *x, SplashCoord *y) { - if (noCurrentPoint()) { - return gFalse; - } - *x = pts[length - 1].x; - *y = pts[length - 1].y; - return gTrue; -} diff --git a/source/libs/poppler/poppler-src/splash/SplashPath.h b/source/libs/poppler/poppler-src/splash/SplashPath.h deleted file mode 100644 index 81273c613e57bc432d78d0ea26e69585ee521fbc..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashPath.h +++ /dev/null @@ -1,123 +0,0 @@ -//======================================================================== -// -// SplashPath.h -// -//======================================================================== - -#ifndef SPLASHPATH_H -#define SPLASHPATH_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" - -//------------------------------------------------------------------------ -// SplashPathPoint -//------------------------------------------------------------------------ - -struct SplashPathPoint { - SplashCoord x, y; -}; - -//------------------------------------------------------------------------ -// SplashPath.flags -//------------------------------------------------------------------------ - -// first point on each subpath sets this flag -#define splashPathFirst 0x01 - -// last point on each subpath sets this flag -#define splashPathLast 0x02 - -// if the subpath is closed, its first and last points must be -// identical, and must set this flag -#define splashPathClosed 0x04 - -// curve control points set this flag -#define splashPathCurve 0x08 - -//------------------------------------------------------------------------ -// SplashPathHint -//------------------------------------------------------------------------ - -struct SplashPathHint { - int ctrl0, ctrl1; - int firstPt, lastPt; -}; - -//------------------------------------------------------------------------ -// SplashPath -//------------------------------------------------------------------------ - -class SplashPath { -public: - - // Create an empty path. - SplashPath(); - - // Copy a path. - SplashPath *copy() { return new SplashPath(this); } - - ~SplashPath(); - - // Append <path> to <this>. - void append(SplashPath *path); - - // Start a new subpath. - SplashError moveTo(SplashCoord x, SplashCoord y); - - // Add a line segment to the last subpath. - SplashError lineTo(SplashCoord x, SplashCoord y); - - // Add a third-order (cubic) Bezier curve segment to the last - // subpath. - SplashError curveTo(SplashCoord x1, SplashCoord y1, - SplashCoord x2, SplashCoord y2, - SplashCoord x3, SplashCoord y3); - - // Close the last subpath, adding a line segment if necessary. If - // <force> is true, this adds a line segment even if the current - // point is equal to the first point in the subpath. - SplashError close(GBool force = gFalse); - - // Add a stroke adjustment hint. The controlling segments are - // <ctrl0> and <ctrl1> (where segments are identified by their first - // point), and the points to be adjusted are <firstPt> .. <lastPt>. - void addStrokeAdjustHint(int ctrl0, int ctrl1, int firstPt, int lastPt); - - // Add (<dx>, <dy>) to every point on this path. - void offset(SplashCoord dx, SplashCoord dy); - - // Get the points on the path. - int getLength() { return length; } - void getPoint(int i, double *x, double *y, Guchar *f) - { *x = pts[i].x; *y = pts[i].y; *f = flags[i]; } - - // Get the current point. - GBool getCurPt(SplashCoord *x, SplashCoord *y); - -protected: - - SplashPath(SplashPath *path); - void grow(int nPts); - GBool noCurrentPoint() { return curSubpath == length; } - GBool onePointSubpath() { return curSubpath == length - 1; } - GBool openSubpath() { return curSubpath < length - 1; } - - SplashPathPoint *pts; // array of points - Guchar *flags; // array of flags - int length, size; // length/size of the pts and flags arrays - int curSubpath; // index of first point in last subpath - - SplashPathHint *hints; // list of hints - int hintsLength, hintsSize; - - friend class SplashXPath; - friend class Splash; - // this is a temporary hack, until we read FreeType paths directly - friend class ArthurOutputDev; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashPattern.cc b/source/libs/poppler/poppler-src/splash/SplashPattern.cc deleted file mode 100644 index 28ca4995882a51f4e92674983c855a9c0e412ec3..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashPattern.cc +++ /dev/null @@ -1,55 +0,0 @@ -//======================================================================== -// -// SplashPattern.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2010, 2011 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include "SplashMath.h" -#include "SplashScreen.h" -#include "SplashPattern.h" - -//------------------------------------------------------------------------ -// SplashPattern -//------------------------------------------------------------------------ - -SplashPattern::SplashPattern() { -} - -SplashPattern::~SplashPattern() { -} - -//------------------------------------------------------------------------ -// SplashSolidColor -//------------------------------------------------------------------------ - -SplashSolidColor::SplashSolidColor(SplashColorPtr colorA) { - splashColorCopy(color, colorA); -} - -SplashSolidColor::~SplashSolidColor() { -} - -GBool SplashSolidColor::getColor(int x, int y, SplashColorPtr c) { - splashColorCopy(c, color); - return gTrue; -} diff --git a/source/libs/poppler/poppler-src/splash/SplashPattern.h b/source/libs/poppler/poppler-src/splash/SplashPattern.h deleted file mode 100644 index 1e2881c812e748b254729959ea875ca4a8a502c8..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashPattern.h +++ /dev/null @@ -1,104 +0,0 @@ -//======================================================================== -// -// SplashPattern.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2010, 2011, 2014 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHPATTERN_H -#define SPLASHPATTERN_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" - -class SplashScreen; - -//------------------------------------------------------------------------ -// SplashPattern -//------------------------------------------------------------------------ - -class SplashPattern { -public: - - SplashPattern(); - - virtual SplashPattern *copy() = 0; - - virtual ~SplashPattern(); - - // Return the color value for a specific pixel. - virtual GBool getColor(int x, int y, SplashColorPtr c) = 0; - - // Test if x,y-position is inside pattern. - virtual GBool testPosition(int x, int y) = 0; - - // Returns true if this pattern object will return the same color - // value for all pixels. - virtual GBool isStatic() = 0; - - // Returns true if this pattern colorspace is CMYK. - virtual GBool isCMYK() = 0; -private: -}; - -//------------------------------------------------------------------------ -// SplashSolidColor -//------------------------------------------------------------------------ - -class SplashSolidColor: public SplashPattern { -public: - - SplashSolidColor(SplashColorPtr colorA); - - SplashPattern *copy() override { return new SplashSolidColor(color); } - - ~SplashSolidColor(); - - GBool getColor(int x, int y, SplashColorPtr c) override; - - GBool testPosition(int x, int y) override { return gFalse; } - - GBool isStatic() override { return gTrue; } - - GBool isCMYK() override { return gFalse; } - -private: - - SplashColor color; -}; - -//------------------------------------------------------------------------ -// SplashGouraudColor (needed for gouraudTriangleShadedFill) -//------------------------------------------------------------------------ - -class SplashGouraudColor: public SplashPattern { -public: - - virtual GBool isParameterized() = 0; - - virtual int getNTriangles() = 0; - - virtual void getTriangle(int i, double *x0, double *y0, double *color0, - double *x1, double *y1, double *color1, - double *x2, double *y2, double *color2) = 0; - - virtual void getParameterizedColor(double t, SplashColorMode mode, SplashColorPtr c) = 0; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashScreen.cc b/source/libs/poppler/poppler-src/splash/SplashScreen.cc deleted file mode 100644 index 28b1e7997e266ccefc94be6c4a22ab2dabb76c8b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashScreen.cc +++ /dev/null @@ -1,390 +0,0 @@ -//======================================================================== -// -// SplashScreen.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2009, 2016 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <string.h> -#include <algorithm> -#include "goo/gmem.h" -#include "goo/grandom.h" -#include "goo/GooLikely.h" -#include "SplashMath.h" -#include "SplashScreen.h" - -static SplashScreenParams defaultParams = { - splashScreenDispersed, // type - 2, // size - 2, // dotRadius - 1.0, // gamma - 0.0, // blackThreshold - 1.0 // whiteThreshold -}; - -//------------------------------------------------------------------------ - -struct SplashScreenPoint { - int x, y; - int dist; -}; - - -struct cmpDistancesFunctor { - bool operator()(const SplashScreenPoint &p0, const SplashScreenPoint &p1) { - return p0.dist < p1.dist; - } -}; - -//------------------------------------------------------------------------ -// SplashScreen -//------------------------------------------------------------------------ - -// If <clustered> is true, this generates a 45 degree screen using a -// circular dot spot function. DPI = resolution / ((size / 2) * -// sqrt(2)). If <clustered> is false, this generates an optimal -// threshold matrix using recursive tesselation. Gamma correction -// (gamma = 1 / 1.33) is also computed here. -SplashScreen::SplashScreen(SplashScreenParams *params) { - - if (!params) { - params = &defaultParams; - } - - screenParams = params; - mat = NULL; - size = 0; - maxVal = 0; - minVal = 0; -} - -void SplashScreen::createMatrix() -{ - Guchar u; - int black, white, i; - - SplashScreenParams *params = screenParams; - - // size must be a power of 2, and at least 2 - for (size = 2, log2Size = 1; size < params->size; size <<= 1, ++log2Size) ; - - switch (params->type) { - - case splashScreenDispersed: - mat = (Guchar *)gmallocn(size * size, sizeof(Guchar)); - buildDispersedMatrix(size/2, size/2, 1, size/2, 1); - break; - - case splashScreenClustered: - mat = (Guchar *)gmallocn(size * size, sizeof(Guchar)); - buildClusteredMatrix(); - break; - - case splashScreenStochasticClustered: - // size must be at least 2*r - while (size < (params->dotRadius << 1)) { - size <<= 1; - ++log2Size; - } - mat = (Guchar *)gmallocn(size * size, sizeof(Guchar)); - buildSCDMatrix(params->dotRadius); - break; - } - - sizeM1 = size - 1; - - // do gamma correction and compute minVal/maxVal - minVal = 255; - maxVal = 0; - black = splashRound((SplashCoord)255.0 * params->blackThreshold); - if (black < 1) { - black = 1; - } - int whiteAux = splashRound((SplashCoord)255.0 * params->whiteThreshold); - if (whiteAux > 255) { - white = 255; - } else { - white = whiteAux; - } - for (i = 0; i < size * size; ++i) { - u = splashRound((SplashCoord)255.0 * - splashPow((SplashCoord)mat[i] / 255.0, params->gamma)); - if (u < black) { - u = (Guchar)black; - } else if (u >= white) { - u = (Guchar)white; - } - mat[i] = u; - if (u < minVal) { - minVal = u; - } else if (u > maxVal) { - maxVal = u; - } - } -} - -void SplashScreen::buildDispersedMatrix(int i, int j, int val, - int delta, int offset) { - if (delta == 0) { - // map values in [1, size^2] --> [1, 255] - mat[(i << log2Size) + j] = 1 + (254 * (val - 1)) / (size * size - 1); - } else { - buildDispersedMatrix(i, j, - val, delta / 2, 4*offset); - buildDispersedMatrix((i + delta) % size, (j + delta) % size, - val + offset, delta / 2, 4*offset); - buildDispersedMatrix((i + delta) % size, j, - val + 2*offset, delta / 2, 4*offset); - buildDispersedMatrix((i + 2*delta) % size, (j + delta) % size, - val + 3*offset, delta / 2, 4*offset); - } -} - -void SplashScreen::buildClusteredMatrix() { - SplashCoord *dist; - SplashCoord u, v, d; - Guchar val; - int size2, x, y, x1, y1, i; - - size2 = size >> 1; - - // initialize the threshold matrix - for (y = 0; y < size; ++y) { - for (x = 0; x < size; ++x) { - mat[(y << log2Size) + x] = 0; - } - } - - // build the distance matrix - dist = (SplashCoord *)gmallocn(size * size2, sizeof(SplashCoord)); - for (y = 0; y < size2; ++y) { - for (x = 0; x < size2; ++x) { - if (x + y < size2 - 1) { - u = (SplashCoord)x + 0.5 - 0; - v = (SplashCoord)y + 0.5 - 0; - } else { - u = (SplashCoord)x + 0.5 - (SplashCoord)size2; - v = (SplashCoord)y + 0.5 - (SplashCoord)size2; - } - dist[y * size2 + x] = u*u + v*v; - } - } - for (y = 0; y < size2; ++y) { - for (x = 0; x < size2; ++x) { - if (x < y) { - u = (SplashCoord)x + 0.5 - 0; - v = (SplashCoord)y + 0.5 - (SplashCoord)size2; - } else { - u = (SplashCoord)x + 0.5 - (SplashCoord)size2; - v = (SplashCoord)y + 0.5 - 0; - } - dist[(size2 + y) * size2 + x] = u*u + v*v; - } - } - - // build the threshold matrix - x1 = y1 = 0; // make gcc happy - for (i = 0; i < size * size2; ++i) { - d = -1; - for (y = 0; y < size; ++y) { - for (x = 0; x < size2; ++x) { - if (mat[(y << log2Size) + x] == 0 && - dist[y * size2 + x] > d) { - x1 = x; - y1 = y; - d = dist[y1 * size2 + x1]; - } - } - } - // map values in [0, 2*size*size2-1] --> [1, 255] - val = 1 + (254 * (2*i)) / (2*size*size2 - 1); - mat[(y1 << log2Size) + x1] = val; - val = 1 + (254 * (2*i+1)) / (2*size*size2 - 1); - if (y1 < size2) { - mat[((y1 + size2) << log2Size) + x1 + size2] = val; - } else { - mat[((y1 - size2) << log2Size) + x1 + size2] = val; - } - } - - gfree(dist); -} - -// Compute the distance between two points on a toroid. -int SplashScreen::distance(int x0, int y0, int x1, int y1) { - int dx0, dx1, dx, dy0, dy1, dy; - - dx0 = abs(x0 - x1); - dx1 = size - dx0; - dx = dx0 < dx1 ? dx0 : dx1; - dy0 = abs(y0 - y1); - dy1 = size - dy0; - dy = dy0 < dy1 ? dy0 : dy1; - return dx * dx + dy * dy; -} - -// Algorithm taken from: -// Victor Ostromoukhov and Roger D. Hersch, "Stochastic Clustered-Dot -// Dithering" in Color Imaging: Device-Independent Color, Color -// Hardcopy, and Graphic Arts IV, SPIE Vol. 3648, pp. 496-505, 1999. -void SplashScreen::buildSCDMatrix(int r) { - SplashScreenPoint *dots, *pts; - int dotsLen, dotsSize; - char *tmpl; - char *grid; - int *region, *dist; - int x, y, xx, yy, x0, x1, y0, y1, i, j, d, iMin, dMin, n; - - // generate the random space-filling curve - pts = (SplashScreenPoint *)gmallocn(size * size, sizeof(SplashScreenPoint)); - i = 0; - for (y = 0; y < size; ++y) { - for (x = 0; x < size; ++x) { - pts[i].x = x; - pts[i].y = y; - ++i; - } - } - for (i = 0; i < size * size; ++i) { - j = i + (int)((double)(size * size - i) * grandom_double()); - x = pts[i].x; - y = pts[i].y; - pts[i].x = pts[j].x; - pts[i].y = pts[j].y; - pts[j].x = x; - pts[j].y = y; - } - - // construct the circle template - tmpl = (char *)gmallocn((r+1)*(r+1), sizeof(char)); - for (y = 0; y <= r; ++y) { - for (x = 0; x <= r; ++x) { - tmpl[y*(r+1) + x] = (x * y <= r * r) ? 1 : 0; - } - } - - // mark all grid cells as free - grid = (char *)gmallocn(size * size, sizeof(char)); - for (y = 0; y < size; ++y) { - for (x = 0; x < size; ++x) { - grid[(y << log2Size) + x] = 0; - } - } - - // walk the space-filling curve, adding dots - dotsLen = 0; - dotsSize = 32; - dots = (SplashScreenPoint *)gmallocn(dotsSize, sizeof(SplashScreenPoint)); - for (i = 0; i < size * size; ++i) { - x = pts[i].x; - y = pts[i].y; - if (!grid[(y << log2Size) + x]) { - if (dotsLen == dotsSize) { - dotsSize *= 2; - dots = (SplashScreenPoint *)greallocn(dots, dotsSize, - sizeof(SplashScreenPoint)); - } - dots[dotsLen++] = pts[i]; - for (yy = 0; yy <= r; ++yy) { - y0 = (y + yy) % size; - y1 = (y - yy + size) % size; - for (xx = 0; xx <= r; ++xx) { - if (tmpl[yy*(r+1) + xx]) { - x0 = (x + xx) % size; - x1 = (x - xx + size) % size; - grid[(y0 << log2Size) + x0] = 1; - grid[(y0 << log2Size) + x1] = 1; - grid[(y1 << log2Size) + x0] = 1; - grid[(y1 << log2Size) + x1] = 1; - } - } - } - } - } - - gfree(tmpl); - gfree(grid); - - // assign each cell to a dot, compute distance to center of dot - region = (int *)gmallocn(size * size, sizeof(int)); - dist = (int *)gmallocn(size * size, sizeof(int)); - for (y = 0; y < size; ++y) { - for (x = 0; x < size; ++x) { - iMin = 0; - dMin = distance(dots[0].x, dots[0].y, x, y); - for (i = 1; i < dotsLen; ++i) { - d = distance(dots[i].x, dots[i].y, x, y); - if (d < dMin) { - iMin = i; - dMin = d; - } - } - region[(y << log2Size) + x] = iMin; - dist[(y << log2Size) + x] = dMin; - } - } - - // compute threshold values - for (i = 0; i < dotsLen; ++i) { - n = 0; - for (y = 0; y < size; ++y) { - for (x = 0; x < size; ++x) { - if (region[(y << log2Size) + x] == i) { - pts[n].x = x; - pts[n].y = y; - pts[n].dist = distance(dots[i].x, dots[i].y, x, y); - ++n; - } - } - } - std::sort(pts, pts + n, cmpDistancesFunctor()); - for (j = 0; j < n; ++j) { - // map values in [0 .. n-1] --> [255 .. 1] - mat[(pts[j].y << log2Size) + pts[j].x] = 255 - (254 * j) / (n - 1); - } - } - - gfree(pts); - gfree(region); - gfree(dist); - - gfree(dots); -} - -SplashScreen::SplashScreen(SplashScreen *screen) { - screenParams = screen->screenParams; - size = screen->size; - sizeM1 = screen->sizeM1; - log2Size = screen->log2Size; - mat = (Guchar *)gmallocn(size * size, sizeof(Guchar)); - if (likely(mat != NULL)) { - memcpy(mat, screen->mat, size * size * sizeof(Guchar)); - } - minVal = screen->minVal; - maxVal = screen->maxVal; -} - -SplashScreen::~SplashScreen() { - gfree(mat); -} diff --git a/source/libs/poppler/poppler-src/splash/SplashScreen.h b/source/libs/poppler/poppler-src/splash/SplashScreen.h deleted file mode 100644 index a7fc45591489ec686439af872671582c8fffda16..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashScreen.h +++ /dev/null @@ -1,80 +0,0 @@ -//======================================================================== -// -// SplashScreen.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHSCREEN_H -#define SPLASHSCREEN_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" - -#include <stdlib.h> - -//------------------------------------------------------------------------ -// SplashScreen -//------------------------------------------------------------------------ - -class SplashScreen { -public: - - SplashScreen(SplashScreenParams *params); - SplashScreen(SplashScreen *screen); - ~SplashScreen(); - - SplashScreen *copy() { return new SplashScreen(this); } - - // Return the computed pixel value (0=black, 1=white) for the gray - // level <value> at (<x>, <y>). - int test(int x, int y, Guchar value) { - int xx, yy; - if (mat == NULL) createMatrix(); - xx = x & sizeM1; - yy = y & sizeM1; - return value < mat[(yy << log2Size) + xx] ? 0 : 1; - } - - // Returns true if value is above the white threshold or below the - // black threshold, i.e., if the corresponding halftone will be - // solid white or black. - GBool isStatic(Guchar value) { if (mat == NULL) createMatrix(); return value < minVal || value >= maxVal; } - -private: - void createMatrix(); - - void buildDispersedMatrix(int i, int j, int val, - int delta, int offset); - void buildClusteredMatrix(); - int distance(int x0, int y0, int x1, int y1); - void buildSCDMatrix(int r); - - SplashScreenParams *screenParams; // params to create the other members - Guchar *mat; // threshold matrix - int size; // size of the threshold matrix - int sizeM1; // size - 1 - int log2Size; // log2(size) - Guchar minVal; // any pixel value below minVal generates - // solid black - Guchar maxVal; // any pixel value above maxVal generates - // solid white -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashState.cc b/source/libs/poppler/poppler-src/splash/SplashState.cc deleted file mode 100644 index f0c98c5eff79dad1be03d0c395bb94b4f716de14..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashState.cc +++ /dev/null @@ -1,272 +0,0 @@ -//======================================================================== -// -// SplashState.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2009, 2011, 2012, 2015 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <string.h> -#include "goo/gmem.h" -#include "SplashPattern.h" -#include "SplashScreen.h" -#include "SplashClip.h" -#include "SplashBitmap.h" -#include "SplashState.h" - -//------------------------------------------------------------------------ -// SplashState -//------------------------------------------------------------------------ - -// number of components in each color mode -int splashColorModeNComps[] = { - 1, 1, 3, 3, 4 -#if SPLASH_CMYK - , 4, 4 + SPOT_NCOMPS -#endif -}; - -SplashState::SplashState(int width, int height, GBool vectorAntialias, - SplashScreenParams *screenParams) { - SplashColor color; - int i; - - matrix[0] = 1; matrix[1] = 0; - matrix[2] = 0; matrix[3] = 1; - matrix[4] = 0; matrix[5] = 0; - memset(&color, 0, sizeof(SplashColor)); - strokePattern = new SplashSolidColor(color); - fillPattern = new SplashSolidColor(color); - screen = new SplashScreen(screenParams); - blendFunc = NULL; - strokeAlpha = 1; - fillAlpha = 1; - multiplyPatternAlpha = gFalse; - patternStrokeAlpha = 1; - patternFillAlpha = 1; - lineWidth = 0; - lineCap = splashLineCapButt; - lineJoin = splashLineJoinMiter; - miterLimit = 10; - flatness = 1; - lineDash = NULL; - lineDashLength = 0; - lineDashPhase = 0; - strokeAdjust = gFalse; - clip = new SplashClip(0, 0, width - 0.001, height - 0.001, vectorAntialias); - softMask = NULL; - deleteSoftMask = gFalse; - inNonIsolatedGroup = gFalse; - fillOverprint = gFalse; - strokeOverprint = gFalse; - overprintMode = 0; - for (i = 0; i < 256; ++i) { - rgbTransferR[i] = (Guchar)i; - rgbTransferG[i] = (Guchar)i; - rgbTransferB[i] = (Guchar)i; - grayTransfer[i] = (Guchar)i; -#if SPLASH_CMYK - cmykTransferC[i] = (Guchar)i; - cmykTransferM[i] = (Guchar)i; - cmykTransferY[i] = (Guchar)i; - cmykTransferK[i] = (Guchar)i; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - deviceNTransfer[cp][i] = (Guchar)i; -#endif - } - overprintMask = 0xffffffff; - overprintAdditive = gFalse; - next = NULL; -} - -SplashState::SplashState(int width, int height, GBool vectorAntialias, - SplashScreen *screenA) { - SplashColor color; - int i; - - matrix[0] = 1; matrix[1] = 0; - matrix[2] = 0; matrix[3] = 1; - matrix[4] = 0; matrix[5] = 0; - memset(&color, 0, sizeof(SplashColor)); - strokePattern = new SplashSolidColor(color); - fillPattern = new SplashSolidColor(color); - screen = screenA->copy(); - blendFunc = NULL; - strokeAlpha = 1; - fillAlpha = 1; - multiplyPatternAlpha = gFalse; - patternStrokeAlpha = 1; - patternFillAlpha = 1; - lineWidth = 0; - lineCap = splashLineCapButt; - lineJoin = splashLineJoinMiter; - miterLimit = 10; - flatness = 1; - lineDash = NULL; - lineDashLength = 0; - lineDashPhase = 0; - strokeAdjust = gFalse; - clip = new SplashClip(0, 0, width - 0.001, height - 0.001, vectorAntialias); - softMask = NULL; - deleteSoftMask = gFalse; - inNonIsolatedGroup = gFalse; - fillOverprint = gFalse; - strokeOverprint = gFalse; - overprintMode = 0; - for (i = 0; i < 256; ++i) { - rgbTransferR[i] = (Guchar)i; - rgbTransferG[i] = (Guchar)i; - rgbTransferB[i] = (Guchar)i; - grayTransfer[i] = (Guchar)i; -#if SPLASH_CMYK - cmykTransferC[i] = (Guchar)i; - cmykTransferM[i] = (Guchar)i; - cmykTransferY[i] = (Guchar)i; - cmykTransferK[i] = (Guchar)i; - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - deviceNTransfer[cp][i] = (Guchar)i; -#endif - } - overprintMask = 0xffffffff; - overprintAdditive = gFalse; - next = NULL; -} - -SplashState::SplashState(SplashState *state) { - memcpy(matrix, state->matrix, 6 * sizeof(SplashCoord)); - strokePattern = state->strokePattern->copy(); - fillPattern = state->fillPattern->copy(); - screen = state->screen->copy(); - blendFunc = state->blendFunc; - strokeAlpha = state->strokeAlpha; - fillAlpha = state->fillAlpha; - multiplyPatternAlpha = state->multiplyPatternAlpha; - patternStrokeAlpha = state->patternStrokeAlpha; - patternFillAlpha = state->patternFillAlpha; - lineWidth = state->lineWidth; - lineCap = state->lineCap; - lineJoin = state->lineJoin; - miterLimit = state->miterLimit; - flatness = state->flatness; - if (state->lineDash) { - lineDashLength = state->lineDashLength; - lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord)); - memcpy(lineDash, state->lineDash, lineDashLength * sizeof(SplashCoord)); - } else { - lineDash = NULL; - lineDashLength = 0; - } - lineDashPhase = state->lineDashPhase; - strokeAdjust = state->strokeAdjust; - clip = state->clip->copy(); - softMask = state->softMask; - deleteSoftMask = gFalse; - inNonIsolatedGroup = state->inNonIsolatedGroup; - fillOverprint = state->fillOverprint; - strokeOverprint = state->strokeOverprint; - overprintMode = state->overprintMode; - memcpy(rgbTransferR, state->rgbTransferR, 256); - memcpy(rgbTransferG, state->rgbTransferG, 256); - memcpy(rgbTransferB, state->rgbTransferB, 256); - memcpy(grayTransfer, state->grayTransfer, 256); -#if SPLASH_CMYK - memcpy(cmykTransferC, state->cmykTransferC, 256); - memcpy(cmykTransferM, state->cmykTransferM, 256); - memcpy(cmykTransferY, state->cmykTransferY, 256); - memcpy(cmykTransferK, state->cmykTransferK, 256); - for (int cp = 0; cp < SPOT_NCOMPS+4; cp++) - memcpy(deviceNTransfer[cp], state->deviceNTransfer[cp], 256); -#endif - overprintMask = state->overprintMask; - overprintAdditive = state->overprintAdditive; - next = NULL; -} - -SplashState::~SplashState() { - delete strokePattern; - delete fillPattern; - delete screen; - gfree(lineDash); - delete clip; - if (deleteSoftMask && softMask) { - delete softMask; - } -} - -void SplashState::setStrokePattern(SplashPattern *strokePatternA) { - delete strokePattern; - strokePattern = strokePatternA; -} - -void SplashState::setFillPattern(SplashPattern *fillPatternA) { - delete fillPattern; - fillPattern = fillPatternA; -} - -void SplashState::setScreen(SplashScreen *screenA) { - delete screen; - screen = screenA; -} - -void SplashState::setLineDash(SplashCoord *lineDashA, int lineDashLengthA, - SplashCoord lineDashPhaseA) { - gfree(lineDash); - lineDashLength = lineDashLengthA; - if (lineDashLength > 0) { - lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord)); - memcpy(lineDash, lineDashA, lineDashLength * sizeof(SplashCoord)); - } else { - lineDash = NULL; - } - lineDashPhase = lineDashPhaseA; -} - -void SplashState::setSoftMask(SplashBitmap *softMaskA) { - if (deleteSoftMask) { - delete softMask; - } - softMask = softMaskA; - deleteSoftMask = gTrue; -} - -void SplashState::setTransfer(Guchar *red, Guchar *green, Guchar *blue, - Guchar *gray) { -#if SPLASH_CMYK - int i; - - for (i = 0; i < 256; ++i) { - cmykTransferC[i] = 255 - rgbTransferR[255 - i]; - cmykTransferM[i] = 255 - rgbTransferG[255 - i]; - cmykTransferY[i] = 255 - rgbTransferB[255 - i]; - cmykTransferK[i] = 255 - grayTransfer[255 - i]; - } - for (i = 0; i < 256; ++i) { - deviceNTransfer[0][i] = 255 - rgbTransferR[255 - i]; - deviceNTransfer[1][i] = 255 - rgbTransferG[255 - i]; - deviceNTransfer[2][i] = 255 - rgbTransferB[255 - i]; - deviceNTransfer[3][i] = 255 - grayTransfer[255 - i]; - } -#endif - memcpy(rgbTransferR, red, 256); - memcpy(rgbTransferG, green, 256); - memcpy(rgbTransferB, blue, 256); - memcpy(grayTransfer, gray, 256); -} diff --git a/source/libs/poppler/poppler-src/splash/SplashState.h b/source/libs/poppler/poppler-src/splash/SplashState.h deleted file mode 100644 index fea7603500edf6849dec401cefb94c19a0071b35..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashState.h +++ /dev/null @@ -1,142 +0,0 @@ -//======================================================================== -// -// SplashState.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2011, 2012, 2015 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHSTATE_H -#define SPLASHSTATE_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" - -class SplashPattern; -class SplashScreen; -class SplashClip; -class SplashBitmap; - -//------------------------------------------------------------------------ -// line cap values -//------------------------------------------------------------------------ - -#define splashLineCapButt 0 -#define splashLineCapRound 1 -#define splashLineCapProjecting 2 - -//------------------------------------------------------------------------ -// line join values -//------------------------------------------------------------------------ - -#define splashLineJoinMiter 0 -#define splashLineJoinRound 1 -#define splashLineJoinBevel 2 - -//------------------------------------------------------------------------ -// SplashState -//------------------------------------------------------------------------ - -class SplashState { -public: - - // Create a new state object, initialized with default settings. - SplashState(int width, int height, GBool vectorAntialias, - SplashScreenParams *screenParams); - SplashState(int width, int height, GBool vectorAntialias, - SplashScreen *screenA); - - // Copy a state object. - SplashState *copy() { return new SplashState(this); } - - ~SplashState(); - - // Set the stroke pattern. This does not copy <strokePatternA>. - void setStrokePattern(SplashPattern *strokePatternA); - - // Set the fill pattern. This does not copy <fillPatternA>. - void setFillPattern(SplashPattern *fillPatternA); - - // Set the screen. This does not copy <screenA>. - void setScreen(SplashScreen *screenA); - - // Set the line dash pattern. This copies the <lineDashA> array. - void setLineDash(SplashCoord *lineDashA, int lineDashLengthA, - SplashCoord lineDashPhaseA); - - // Set the soft mask bitmap. - void setSoftMask(SplashBitmap *softMaskA); - - // Set the overprint parametes. - void setFillOverprint(GBool fillOverprintA) { fillOverprint = fillOverprintA; } - void setStrokeOverprint(GBool strokeOverprintA) { strokeOverprint = strokeOverprintA; } - void setOverprintMode(int overprintModeA) { overprintMode = overprintModeA; } - - // Set the transfer function. - void setTransfer(Guchar *red, Guchar *green, Guchar *blue, Guchar *gray); - -private: - - SplashState(SplashState *state); - - SplashCoord matrix[6]; - SplashPattern *strokePattern; - SplashPattern *fillPattern; - SplashScreen *screen; - SplashBlendFunc blendFunc; - SplashCoord strokeAlpha; - SplashCoord fillAlpha; - GBool multiplyPatternAlpha; - SplashCoord patternStrokeAlpha; - SplashCoord patternFillAlpha; - SplashCoord lineWidth; - int lineCap; - int lineJoin; - SplashCoord miterLimit; - SplashCoord flatness; - SplashCoord *lineDash; - int lineDashLength; - SplashCoord lineDashPhase; - GBool strokeAdjust; - SplashClip *clip; - SplashBitmap *softMask; - GBool deleteSoftMask; - GBool inNonIsolatedGroup; - GBool fillOverprint; - GBool strokeOverprint; - int overprintMode; - Guchar rgbTransferR[256], - rgbTransferG[256], - rgbTransferB[256]; - Guchar grayTransfer[256]; -#if SPLASH_CMYK - Guchar cmykTransferC[256], - cmykTransferM[256], - cmykTransferY[256], - cmykTransferK[256]; - Guchar deviceNTransfer[SPOT_NCOMPS+4][256]; -#endif - Guint overprintMask; - GBool overprintAdditive; - - SplashState *next; // used by Splash class - - friend class Splash; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashT1Font.cc b/source/libs/poppler/poppler-src/splash/SplashT1Font.cc deleted file mode 100644 index 0fdfaaf515095e0e681facce6d4c09f9b10f1dee..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashT1Font.cc +++ /dev/null @@ -1,309 +0,0 @@ -//======================================================================== -// -// SplashT1Font.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2007 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <t1lib.h> -#include "goo/gmem.h" -#include "SplashMath.h" -#include "SplashGlyphBitmap.h" -#include "SplashPath.h" -#include "SplashT1FontEngine.h" -#include "SplashT1FontFile.h" -#include "SplashT1Font.h" - -//------------------------------------------------------------------------ - -static Guchar bitReverse[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff -}; - -//------------------------------------------------------------------------ -// SplashT1Font -//------------------------------------------------------------------------ - -SplashT1Font::SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA): - SplashFont(fontFileA, matA, textMatA, fontFileA->engine->aa) -{ - T1_TMATRIX matrix; - BBox bbox; - SplashCoord bbx0, bby0, bbx1, bby1; - int x, y; - - t1libID = T1_CopyFont(fontFileA->t1libID); - outlineID = -1; - - // compute font size - size = (float)splashDist(0, 0, mat[2], mat[3]); - - // transform the four corners of the font bounding box -- the min - // and max values form the bounding box of the transformed font - bbox = T1_GetFontBBox(t1libID); - bbx0 = 0.001 * bbox.llx; - bby0 = 0.001 * bbox.lly; - bbx1 = 0.001 * bbox.urx; - bby1 = 0.001 * bbox.ury; - // some fonts are completely broken, so we fake it (with values - // large enough that most glyphs should fit) - if (bbx0 == 0 && bby0 == 0 && bbx1 == 0 && bby1 == 0) { - bbx0 = bby0 = -0.5; - bbx1 = bby1 = 1.5; - } - x = (int)(mat[0] * bbx0 + mat[2] * bby0); - xMin = xMax = x; - y = (int)(mat[1] * bbx0 + mat[3] * bby0); - yMin = yMax = y; - x = (int)(mat[0] * bbx0 + mat[2] * bby1); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * bbx0 + mat[3] * bby1); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)(mat[0] * bbx1 + mat[2] * bby0); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * bbx1 + mat[3] * bby0); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - x = (int)(mat[0] * bbx1 + mat[2] * bby1); - if (x < xMin) { - xMin = x; - } else if (x > xMax) { - xMax = x; - } - y = (int)(mat[1] * bbx1 + mat[3] * bby1); - if (y < yMin) { - yMin = y; - } else if (y > yMax) { - yMax = y; - } - // This is a kludge: some buggy PDF generators embed fonts with - // zero bounding boxes. - if (xMax == xMin) { - xMin = 0; - xMax = (int)size; - } - if (yMax == yMin) { - yMin = 0; - yMax = (int)(1.2 * size); - } - // Another kludge: an unusually large xMin or yMin coordinate is - // probably wrong. - if (xMin > 0) { - xMin = 0; - } - if (yMin > 0) { - yMin = 0; - } - // Another kludge: t1lib doesn't correctly handle fonts with - // real (non-integer) bounding box coordinates. - if (xMax - xMin > 5000) { - xMin = 0; - xMax = (int)size; - } - if (yMax - yMin > 5000) { - yMin = 0; - yMax = (int)(1.2 * size); - } - - // transform the font - matrix.cxx = (double)mat[0] / size; - matrix.cxy = (double)mat[1] / size; - matrix.cyx = (double)mat[2] / size; - matrix.cyy = (double)mat[3] / size; - T1_TransformFont(t1libID, &matrix); -} - -SplashT1Font::~SplashT1Font() { - T1_DeleteFont(t1libID); - if (outlineID >= 0) { - T1_DeleteFont(outlineID); - } -} - -GBool SplashT1Font::getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { - return SplashFont::getGlyph(c, 0, 0, bitmap, x0, y0, clip, clipRes); -} - -GBool SplashT1Font::makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { - GLYPH *glyph; - int n, i; - - if (aa) { - glyph = T1_AASetChar(t1libID, c, size, NULL); - } else { - glyph = T1_SetChar(t1libID, c, size, NULL); - } - if (!glyph) { - return gFalse; - } - - bitmap->x = -glyph->metrics.leftSideBearing; - bitmap->y = glyph->metrics.ascent; - bitmap->w = glyph->metrics.rightSideBearing - glyph->metrics.leftSideBearing; - bitmap->h = glyph->metrics.ascent - glyph->metrics.descent; - bitmap->aa = aa; - if (aa) { - bitmap->data = (Guchar *)glyph->bits; - bitmap->freeData = gFalse; - } else { - n = bitmap->h * ((bitmap->w + 7) >> 3); - bitmap->data = (Guchar *)gmalloc(n); - for (i = 0; i < n; ++i) { - bitmap->data[i] = bitReverse[glyph->bits[i] & 0xff]; - } - bitmap->freeData = gTrue; - } - - *clipRes = clip->testRect(x0 - bitmap->x, - y0 - bitmap->y, - x0 - bitmap->x + bitmap->w - 1, - y0 - bitmap->y + bitmap->h - 1); - - return gTrue; -} - -SplashPath *SplashT1Font::getGlyphPath(int c) { - T1_TMATRIX matrix; - SplashPath *path; - T1_OUTLINE *outline; - T1_PATHSEGMENT *seg; - T1_BEZIERSEGMENT *bez; - int x, y, x1, y1; - GBool needClose; - - if (outlineID < 0) { - outlineID = T1_CopyFont(((SplashT1FontFile *)fontFile)->t1libID); - outlineSize = (float)splashDist(0, 0, textMat[2], textMat[3]); - matrix.cxx = (double)textMat[0] / outlineSize; - matrix.cxy = (double)textMat[1] / outlineSize; - matrix.cyx = (double)textMat[2] / outlineSize; - matrix.cyy = (double)textMat[3] / outlineSize; - // t1lib doesn't seem to handle small sizes correctly here, so set - // the size to 1000, and scale the resulting coordinates later - outlineMul = (float)(outlineSize / 65536000.0); - outlineSize = 1000; - T1_TransformFont(outlineID, &matrix); - } - - path = new SplashPath(); - if ((outline = T1_GetCharOutline(outlineID, c, outlineSize, NULL))) { - // NB: t1lib uses integer coordinates here; we keep a running - // (x,y) total as integers, so that the final point in the path is - // exactly the same as the first point, thus avoiding weird - // mitered join glitches - x = y = 0; - needClose = gFalse; - for (seg = outline; seg; seg = seg->link) { - switch (seg->type) { - case T1_PATHTYPE_MOVE: - if (needClose) { - path->close(); - needClose = gFalse; - } - x += seg->dest.x; - y += seg->dest.y; - path->moveTo(outlineMul * x, -outlineMul * y); - break; - case T1_PATHTYPE_LINE: - x += seg->dest.x; - y += seg->dest.y; - path->lineTo(outlineMul * x, -outlineMul * y); - needClose = gTrue; - break; - case T1_PATHTYPE_BEZIER: - bez = (T1_BEZIERSEGMENT *)seg; - x1 = x + bez->dest.x; - y1 = y + bez->dest.y; - path->curveTo(outlineMul * (x + bez->B.x), - -outlineMul * (y + bez->B.y), - outlineMul * (x + bez->C.x), - -outlineMul * (y + bez->C.y), - outlineMul * x1, - -outlineMul * y1); - x = x1; - y = y1; - needClose = gTrue; - break; - } - } - if (needClose) { - path->close(); - } - T1_FreeOutline(outline); - } - - return path; -} - -#endif // HAVE_T1LIB_H diff --git a/source/libs/poppler/poppler-src/splash/SplashT1Font.h b/source/libs/poppler/poppler-src/splash/SplashT1Font.h deleted file mode 100644 index 1dbe66cd7fc3007201d7ab837c52a0fe5894c914..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashT1Font.h +++ /dev/null @@ -1,69 +0,0 @@ -//======================================================================== -// -// SplashT1Font.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2007 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHT1FONT_H -#define SPLASHT1FONT_H - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashFont.h" - -class SplashT1FontFile; - -//------------------------------------------------------------------------ -// SplashT1Font -//------------------------------------------------------------------------ - -class SplashT1Font: public SplashFont { -public: - - SplashT1Font(SplashT1FontFile *fontFileA, SplashCoord *matA, - SplashCoord *textMatA); - - virtual ~SplashT1Font(); - - // Munge xFrac and yFrac before calling SplashFont::getGlyph. - virtual GBool getGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); - - // Rasterize a glyph. The <xFrac> and <yFrac> values are the same - // as described for getGlyph. - virtual GBool makeGlyph(int c, int xFrac, int yFrac, - SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); - - // Return the path for a glyph. - virtual SplashPath *getGlyphPath(int c); - -private: - - int t1libID; // t1lib font ID - int outlineID; // t1lib font ID for glyph outlines - float size; - float outlineSize; // size for glyph outlines - float outlineMul; -}; - -#endif // HAVE_T1LIB_H - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.cc b/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.cc deleted file mode 100644 index fb4b38dae88ac9c9132829bb52d418bbc39079fd..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.cc +++ /dev/null @@ -1,138 +0,0 @@ -//======================================================================== -// -// SplashT1FontEngine.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <stdio.h> -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif -#include <t1lib.h> -#include "goo/GooString.h" -#include "goo/gfile.h" -#include "fofi/FoFiType1C.h" -#include "SplashT1FontFile.h" -#include "SplashT1FontEngine.h" - -#ifdef VMS -#if (__VMS_VER < 70000000) -extern "C" int unlink(char *filename); -#endif -#endif - -//------------------------------------------------------------------------ - -int SplashT1FontEngine::t1libInitCount = 0; - -//------------------------------------------------------------------------ - -static void fileWrite(void *stream, const char *data, int len) { - fwrite(data, 1, len, (FILE *)stream); -} - -//------------------------------------------------------------------------ -// SplashT1FontEngine -//------------------------------------------------------------------------ - -SplashT1FontEngine::SplashT1FontEngine(GBool aaA) { - aa = aaA; -} - -SplashT1FontEngine *SplashT1FontEngine::init(GBool aaA) { - // grayVals[i] = round(i * 255 / 16) - static unsigned long grayVals[17] = { - 0, 16, 32, 48, 64, 80, 96, 112, 128, 143, 159, 175, 191, 207, 223, 239, 255 - }; - - //~ for multithreading: need a mutex here - if (t1libInitCount == 0) { - T1_SetBitmapPad(8); - if (!T1_InitLib(NO_LOGFILE | IGNORE_CONFIGFILE | IGNORE_FONTDATABASE | - T1_NO_AFM)) { - return NULL; - } - if (aaA) { - T1_AASetBitsPerPixel(8); - T1_AASetLevel(T1_AA_HIGH); - T1_AAHSetGrayValues(grayVals); - } else { - T1_AANSetGrayValues(0, 1); - } - } - ++t1libInitCount; - - return new SplashT1FontEngine(aaA); -} - -SplashT1FontEngine::~SplashT1FontEngine() { - //~ for multithreading: need a mutex here - if (--t1libInitCount == 0) { - T1_CloseLib(); - } -} - -SplashFontFile *SplashT1FontEngine::loadType1Font(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - return SplashT1FontFile::loadType1Font(this, idA, src, enc); -} - -SplashFontFile *SplashT1FontEngine::loadType1CFont(SplashFontFileID *idA, - SplashFontSrc *src, - const char **enc) { - FoFiType1C *ff; - GooString *tmpFileName; - FILE *tmpFile; - SplashFontFile *ret; - - SplashFontSrc *newsrc; - - if (src->isFile) - ff = FoFiType1C::load(src->fileName->getCString()); - else - ff = FoFiType1C::make(src->buf, src->bufLen); - if (! ff) - return NULL; - - tmpFileName = NULL; - if (!openTempFile(&tmpFileName, &tmpFile, "wb")) { - delete ff; - return NULL; - } - ff->convertToType1(NULL, NULL, gTrue, &fileWrite, tmpFile); - delete ff; - fclose(tmpFile); - newsrc = new SplashFontSrc; - newsrc->setFile(tmpFileName, gTrue); - delete tmpFileName; - ret = SplashT1FontFile::loadType1Font(this, idA, newsrc, enc); - newsrc->unref(); - return ret; -} - -#endif // HAVE_T1LIB_H diff --git a/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.h b/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.h deleted file mode 100644 index 268a01479b03d9e083c756298432c219f172ffa6..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashT1FontEngine.h +++ /dev/null @@ -1,50 +0,0 @@ -//======================================================================== -// -// SplashT1FontEngine.h -// -//======================================================================== - -#ifndef SPLASHT1FONTENGINE_H -#define SPLASHT1FONTENGINE_H - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "goo/gtypes.h" - -class SplashFontFile; -class SplashFontFileID; -class SplashFontSrc; - -//------------------------------------------------------------------------ -// SplashT1FontEngine -//------------------------------------------------------------------------ - -class SplashT1FontEngine { -public: - - static SplashT1FontEngine *init(GBool aaA); - - ~SplashT1FontEngine(); - - // Load fonts. - SplashFontFile *loadType1Font(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - SplashFontFile *loadType1CFont(SplashFontFileID *idA, SplashFontSrc *src, const char **enc); - -private: - - SplashT1FontEngine(GBool aaA); - - static int t1libInitCount; - GBool aa; - - friend class SplashT1FontFile; - friend class SplashT1Font; -}; - -#endif // HAVE_T1LIB_H - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashT1FontFile.cc b/source/libs/poppler/poppler-src/splash/SplashT1FontFile.cc deleted file mode 100644 index 1832a916d9ae3730e9f95501737bd98ff6622c7a..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashT1FontFile.cc +++ /dev/null @@ -1,134 +0,0 @@ -//======================================================================== -// -// SplashT1FontFile.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <string.h> -#include <t1lib.h> -#include "goo/GooString.h" -#include "goo/gfile.h" -#include "goo/gmem.h" -#include "SplashT1FontEngine.h" -#include "SplashT1Font.h" -#include "SplashT1FontFile.h" - -//------------------------------------------------------------------------ -// SplashT1FontFile -//------------------------------------------------------------------------ - -SplashFontFile *SplashT1FontFile::loadType1Font(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - const char **encA) { - int t1libIDA; - const char **encTmp; - char *encStrTmp; - int encStrSize; - char *encPtr; - int i; - - GooString *fileNameA; - SplashFontSrc *newsrc = NULL; - SplashFontFile *ff; - - if (! src->isFile) { - GooString *tmpFileName; - FILE *tmpFile; - if (!openTempFile(&tmpFileName, &tmpFile, "wb")) - return NULL; - fwrite(src->buf, 1, src->bufLen, tmpFile); - fclose(tmpFile); - newsrc = new SplashFontSrc; - newsrc->setFile(tmpFileName, gTrue); - src = newsrc; - delete tmpFileName; - } - fileNameA = src->fileName; - // load the font file - if ((t1libIDA = T1_AddFont(fileNameA->getCString())) < 0) { - delete newsrc; - return NULL; - } - T1_LoadFont(t1libIDA); - - // reencode it - encStrSize = 0; - for (i = 0; i < 256; ++i) { - if (encA[i]) { - encStrSize += strlen(encA[i]) + 1; - } - } - encTmp = (const char **)gmallocn(257, sizeof(char *)); - encStrTmp = (char *)gmallocn(encStrSize, sizeof(char)); - encPtr = encStrTmp; - for (i = 0; i < 256; ++i) { - if (encA[i]) { - strcpy(encPtr, encA[i]); - encTmp[i] = encPtr; - encPtr += strlen(encPtr) + 1; - } else { - encTmp[i] = ".notdef"; - } - } - encTmp[256] = "custom"; - T1_ReencodeFont(t1libIDA, (char **)encTmp); - - ff = new SplashT1FontFile(engineA, idA, src, - t1libIDA, encTmp, encStrTmp); - if (newsrc) - newsrc->unref(); - return ff; -} - -SplashT1FontFile::SplashT1FontFile(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *srcA, - int t1libIDA, const char **encA, char *encStrA): - SplashFontFile(idA, srcA) -{ - engine = engineA; - t1libID = t1libIDA; - enc = encA; - encStr = encStrA; -} - -SplashT1FontFile::~SplashT1FontFile() { - gfree(encStr); - gfree(enc); - T1_DeleteFont(t1libID); -} - -SplashFont *SplashT1FontFile::makeFont(SplashCoord *mat, - SplashCoord *textMat) { - SplashFont *font; - - font = new SplashT1Font(this, mat, textMat); - font->initCache(); - return font; -} - -#endif // HAVE_T1LIB_H diff --git a/source/libs/poppler/poppler-src/splash/SplashT1FontFile.h b/source/libs/poppler/poppler-src/splash/SplashT1FontFile.h deleted file mode 100644 index c094b6d8b2931bebb033dd61f36314c0a1afcf51..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashT1FontFile.h +++ /dev/null @@ -1,70 +0,0 @@ -//======================================================================== -// -// SplashT1FontFile.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHT1FONTFILE_H -#define SPLASHT1FONTFILE_H - -#if HAVE_T1LIB_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashFontFile.h" - -class SplashT1FontEngine; - -//------------------------------------------------------------------------ -// SplashT1FontFile -//------------------------------------------------------------------------ - -class SplashT1FontFile: public SplashFontFile { -public: - - static SplashFontFile *loadType1Font(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - const char **encA); - - virtual ~SplashT1FontFile(); - - // Create a new SplashT1Font, i.e., a scaled instance of this font - // file. - virtual SplashFont *makeFont(SplashCoord *mat, - SplashCoord *textMat); - -private: - - SplashT1FontFile(SplashT1FontEngine *engineA, - SplashFontFileID *idA, - SplashFontSrc *src, - int t1libIDA, const char **encA, char *encStrA); - - SplashT1FontEngine *engine; - int t1libID; // t1lib font ID - const char **enc; - char *encStr; - - friend class SplashT1Font; -}; - -#endif // HAVE_T1LIB_H - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashXPath.cc b/source/libs/poppler/poppler-src/splash/SplashXPath.cc deleted file mode 100644 index 27106ee3d148a5d93b0f5f3ebb1a037ed7f881a0..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashXPath.cc +++ /dev/null @@ -1,472 +0,0 @@ -//======================================================================== -// -// SplashXPath.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2010 PaweÅ‚ Wiejacha <pawel.wiejacha@gmail.com> -// Copyright (C) 2010, 2011 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <string.h> -#include <algorithm> -#include "goo/gmem.h" -#include "SplashMath.h" -#include "SplashPath.h" -#include "SplashXPath.h" - -//------------------------------------------------------------------------ - -struct SplashXPathPoint { - SplashCoord x, y; -}; - -struct SplashXPathAdjust { - int firstPt, lastPt; // range of points - GBool vert; // vertical or horizontal hint - SplashCoord x0a, x0b, // hint boundaries - xma, xmb, - x1a, x1b; - SplashCoord x0, x1, xm; // adjusted coordinates -}; - -//------------------------------------------------------------------------ - -// Transform a point from user space to device space. -inline void SplashXPath::transform(SplashCoord *matrix, - SplashCoord xi, SplashCoord yi, - SplashCoord *xo, SplashCoord *yo) { - // [ m[0] m[1] 0 ] - // [xo yo 1] = [xi yi 1] * [ m[2] m[3] 0 ] - // [ m[4] m[5] 1 ] - *xo = xi * matrix[0] + yi * matrix[2] + matrix[4]; - *yo = xi * matrix[1] + yi * matrix[3] + matrix[5]; -} - -//------------------------------------------------------------------------ -// SplashXPath -//------------------------------------------------------------------------ - -SplashXPath::SplashXPath(SplashPath *path, SplashCoord *matrix, - SplashCoord flatness, GBool closeSubpaths, - GBool adjustLines, int linePosI) { - SplashPathHint *hint; - SplashXPathPoint *pts; - SplashXPathAdjust *adjusts, *adjust; - SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xsp, ysp; - SplashCoord adj0, adj1; - int curSubpath, i, j; - - // transform the points - pts = (SplashXPathPoint *)gmallocn(path->length, sizeof(SplashXPathPoint)); - for (i = 0; i < path->length; ++i) { - transform(matrix, path->pts[i].x, path->pts[i].y, &pts[i].x, &pts[i].y); - } - - // set up the stroke adjustment hints - if (path->hints) { - adjusts = (SplashXPathAdjust *)gmallocn(path->hintsLength, - sizeof(SplashXPathAdjust)); - for (i = 0; i < path->hintsLength; ++i) { - hint = &path->hints[i]; - if (hint->ctrl0 + 1 >= path->length || hint->ctrl1 + 1 >= path->length) { - gfree(adjusts); - adjusts = NULL; - break; - } - x0 = pts[hint->ctrl0 ].x; y0 = pts[hint->ctrl0 ].y; - x1 = pts[hint->ctrl0 + 1].x; y1 = pts[hint->ctrl0 + 1].y; - x2 = pts[hint->ctrl1 ].x; y2 = pts[hint->ctrl1 ].y; - x3 = pts[hint->ctrl1 + 1].x; y3 = pts[hint->ctrl1 + 1].y; - if (x0 == x1 && x2 == x3) { - adjusts[i].vert = gTrue; - adj0 = x0; - adj1 = x2; - } else if (y0 == y1 && y2 == y3) { - adjusts[i].vert = gFalse; - adj0 = y0; - adj1 = y2; - } else { - gfree(adjusts); - adjusts = NULL; - break; - } - if (adj0 > adj1) { - x0 = adj0; - adj0 = adj1; - adj1 = x0; - } - adjusts[i].x0a = adj0 - 0.01; - adjusts[i].x0b = adj0 + 0.01; - adjusts[i].xma = (SplashCoord)0.5 * (adj0 + adj1) - 0.01; - adjusts[i].xmb = (SplashCoord)0.5 * (adj0 + adj1) + 0.01; - adjusts[i].x1a = adj1 - 0.01; - adjusts[i].x1b = adj1 + 0.01; - // rounding both edge coordinates can result in lines of - // different widths (e.g., adj=10.1, adj1=11.3 --> x0=10, x1=11; - // adj0=10.4, adj1=11.6 --> x0=10, x1=12), but it has the - // benefit of making adjacent strokes/fills line up without any - // gaps between them - x0 = splashRound(adj0); - x1 = splashRound(adj1); - if (x1 == x0) { - if (adjustLines) { - // the adjustment moves thin lines (clip rectangle with - // empty width or height) out of clip area, here we need - // a special adjustment: - x0 = linePosI; - x1 = x0 + 1; - } else { - x1 = x1 + 1; - } - } - adjusts[i].x0 = (SplashCoord)x0; - adjusts[i].x1 = (SplashCoord)x1 - 0.01; - adjusts[i].xm = (SplashCoord)0.5 * (adjusts[i].x0 + adjusts[i].x1); - adjusts[i].firstPt = hint->firstPt; - adjusts[i].lastPt = hint->lastPt; - } - - } else { - adjusts = NULL; - } - - // perform stroke adjustment - if (adjusts) { - for (i = 0, adjust = adjusts; i < path->hintsLength; ++i, ++adjust) { - for (j = adjust->firstPt; j <= adjust->lastPt; ++j) { - strokeAdjust(adjust, &pts[j].x, &pts[j].y); - } - } - gfree(adjusts); - } - - segs = NULL; - length = size = 0; - - x0 = y0 = xsp = ysp = 0; // make gcc happy - adj0 = adj1 = 0; // make gcc happy - curSubpath = 0; - i = 0; - while (i < path->length) { - - // first point in subpath - skip it - if (path->flags[i] & splashPathFirst) { - x0 = pts[i].x; - y0 = pts[i].y; - xsp = x0; - ysp = y0; - curSubpath = i; - ++i; - - } else { - - // curve segment - if (path->flags[i] & splashPathCurve) { - x1 = pts[i].x; - y1 = pts[i].y; - x2 = pts[i+1].x; - y2 = pts[i+1].y; - x3 = pts[i+2].x; - y3 = pts[i+2].y; - addCurve(x0, y0, x1, y1, x2, y2, x3, y3, - flatness, - (path->flags[i-1] & splashPathFirst), - (path->flags[i+2] & splashPathLast), - !closeSubpaths && - (path->flags[i-1] & splashPathFirst) && - !(path->flags[i-1] & splashPathClosed), - !closeSubpaths && - (path->flags[i+2] & splashPathLast) && - !(path->flags[i+2] & splashPathClosed)); - x0 = x3; - y0 = y3; - i += 3; - - // line segment - } else { - x1 = pts[i].x; - y1 = pts[i].y; - addSegment(x0, y0, x1, y1); - x0 = x1; - y0 = y1; - ++i; - } - - // close a subpath - if (closeSubpaths && - (path->flags[i-1] & splashPathLast) && - (pts[i-1].x != pts[curSubpath].x || - pts[i-1].y != pts[curSubpath].y)) { - addSegment(x0, y0, xsp, ysp); - } - } - } - - gfree(pts); -} - -// Apply the stroke adjust hints to point <pt>: (*<xp>, *<yp>). -void SplashXPath::strokeAdjust(SplashXPathAdjust *adjust, - SplashCoord *xp, SplashCoord *yp) { - SplashCoord x, y; - - if (adjust->vert) { - x = *xp; - if (x > adjust->x0a && x < adjust->x0b) { - *xp = adjust->x0; - } else if (x > adjust->xma && x < adjust->xmb) { - *xp = adjust->xm; - } else if (x > adjust->x1a && x < adjust->x1b) { - *xp = adjust->x1; - } - } else { - y = *yp; - if (y > adjust->x0a && y < adjust->x0b) { - *yp = adjust->x0; - } else if (y > adjust->xma && y < adjust->xmb) { - *yp = adjust->xm; - } else if (y > adjust->x1a && y < adjust->x1b) { - *yp = adjust->x1; - } - } -} - -SplashXPath::SplashXPath(SplashXPath *xPath) { - length = xPath->length; - size = xPath->size; - segs = (SplashXPathSeg *)gmallocn(size, sizeof(SplashXPathSeg)); - memcpy(segs, xPath->segs, length * sizeof(SplashXPathSeg)); -} - -SplashXPath::~SplashXPath() { - gfree(segs); -} - -// Add space for <nSegs> more segments -void SplashXPath::grow(int nSegs) { - if (length + nSegs > size) { - if (size == 0) { - size = 32; - } - while (size < length + nSegs) { - size *= 2; - } - segs = (SplashXPathSeg *)greallocn(segs, size, sizeof(SplashXPathSeg)); - } -} - -void SplashXPath::addCurve(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1, - SplashCoord x2, SplashCoord y2, - SplashCoord x3, SplashCoord y3, - SplashCoord flatness, - GBool first, GBool last, GBool end0, GBool end1) { - SplashCoord *cx = new SplashCoord[(splashMaxCurveSplits + 1) * 3]; - SplashCoord *cy = new SplashCoord[(splashMaxCurveSplits + 1) * 3]; - int *cNext = new int[splashMaxCurveSplits + 1]; - SplashCoord xl0, xl1, xl2, xr0, xr1, xr2, xr3, xx1, xx2, xh; - SplashCoord yl0, yl1, yl2, yr0, yr1, yr2, yr3, yy1, yy2, yh; - SplashCoord dx, dy, mx, my, d1, d2, flatness2; - int p1, p2, p3; - -#if USE_FIXEDPOINT - flatness2 = flatness; -#else - flatness2 = flatness * flatness; -#endif - - // initial segment - p1 = 0; - p2 = splashMaxCurveSplits; - - *(cx + p1 * 3 + 0) = x0; - *(cx + p1 * 3 + 1) = x1; - *(cx + p1 * 3 + 2) = x2; - *(cx + p2 * 3 + 0) = x3; - - *(cy + p1 * 3 + 0) = y0; - *(cy + p1 * 3 + 1) = y1; - *(cy + p1 * 3 + 2) = y2; - *(cy + p2 * 3 + 0) = y3; - - *(cNext + p1) = p2; - - while (p1 < splashMaxCurveSplits) { - - // get the next segment - xl0 = *(cx + p1 * 3 + 0); - xx1 = *(cx + p1 * 3 + 1); - xx2 = *(cx + p1 * 3 + 2); - - yl0 = *(cy + p1 * 3 + 0); - yy1 = *(cy + p1 * 3 + 1); - yy2 = *(cy + p1 * 3 + 2); - - p2 = *(cNext + p1); - - xr3 = *(cx + p2 * 3 + 0); - yr3 = *(cy + p2 * 3 + 0); - - // compute the distances from the control points to the - // midpoint of the straight line (this is a bit of a hack, but - // it's much faster than computing the actual distances to the - // line) - mx = (xl0 + xr3) * 0.5; - my = (yl0 + yr3) * 0.5; -#if USE_FIXEDPOINT - d1 = splashDist(xx1, yy1, mx, my); - d2 = splashDist(xx2, yy2, mx, my); -#else - dx = xx1 - mx; - dy = yy1 - my; - d1 = dx*dx + dy*dy; - dx = xx2 - mx; - dy = yy2 - my; - d2 = dx*dx + dy*dy; -#endif - - // if the curve is flat enough, or no more subdivisions are - // allowed, add the straight line segment - if (p2 - p1 == 1 || (d1 <= flatness2 && d2 <= flatness2)) { - addSegment(xl0, yl0, xr3, yr3); - p1 = p2; - - // otherwise, subdivide the curve - } else { - xl1 = (xl0 + xx1) * 0.5; - yl1 = (yl0 + yy1) * 0.5; - xh = (xx1 + xx2) * 0.5; - yh = (yy1 + yy2) * 0.5; - xl2 = (xl1 + xh) * 0.5; - yl2 = (yl1 + yh) * 0.5; - xr2 = (xx2 + xr3) * 0.5; - yr2 = (yy2 + yr3) * 0.5; - xr1 = (xh + xr2) * 0.5; - yr1 = (yh + yr2) * 0.5; - xr0 = (xl2 + xr1) * 0.5; - yr0 = (yl2 + yr1) * 0.5; - // add the new subdivision points - p3 = (p1 + p2) / 2; - - *(cx + p1 * 3 + 1) = xl1; - *(cx + p1 * 3 + 2) = xl2; - - *(cy + p1 * 3 + 1) = yl1; - *(cy + p1 * 3 + 2) = yl2; - - *(cNext + p1) = p3; - - *(cx + p3 * 3 + 0) = xr0; - *(cx + p3 * 3 + 1) = xr1; - *(cx + p3 * 3 + 2) = xr2; - - *(cy + p3 * 3 + 0) = yr0; - *(cy + p3 * 3 + 1) = yr1; - *(cy + p3 * 3 + 2) = yr2; - - *(cNext + p3) = p2; - } - } - - delete [] cx; - delete [] cy; - delete [] cNext; -} - -void SplashXPath::addSegment(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1) { - grow(1); - segs[length].x0 = x0; - segs[length].y0 = y0; - segs[length].x1 = x1; - segs[length].y1 = y1; - segs[length].flags = 0; - if (y1 == y0) { - segs[length].dxdy = segs[length].dydx = 0; - segs[length].flags |= splashXPathHoriz; - if (x1 == x0) { - segs[length].flags |= splashXPathVert; - } - } else if (x1 == x0) { - segs[length].dxdy = segs[length].dydx = 0; - segs[length].flags |= splashXPathVert; - } else { -#if USE_FIXEDPOINT - if (FixedPoint::divCheck(x1 - x0, y1 - y0, &segs[length].dxdy)) { - segs[length].dydx = (SplashCoord)1 / segs[length].dxdy; - } else { - segs[length].dxdy = segs[length].dydx = 0; - if (splashAbs(x1 - x0) > splashAbs(y1 - y0)) { - segs[length].flags |= splashXPathHoriz; - } else { - segs[length].flags |= splashXPathVert; - } - } -#else - segs[length].dxdy = (x1 - x0) / (y1 - y0); - segs[length].dydx = (SplashCoord)1 / segs[length].dxdy; -#endif - } - if (y0 > y1) { - segs[length].flags |= splashXPathFlip; - } - ++length; -} - -struct cmpXPathSegsFunctor { - bool operator()(const SplashXPathSeg &seg0, const SplashXPathSeg &seg1) { - SplashCoord x0, y0, x1, y1; - - if (seg0.flags & splashXPathFlip) { - x0 = seg0.x1; - y0 = seg0.y1; - } else { - x0 = seg0.x0; - y0 = seg0.y0; - } - if (seg1.flags & splashXPathFlip) { - x1 = seg1.x1; - y1 = seg1.y1; - } else { - x1 = seg1.x0; - y1 = seg1.y0; - } - return (y0 != y1) ? (y0 < y1) : (x0 < x1); - } -}; - -void SplashXPath::aaScale() { - SplashXPathSeg *seg; - int i; - - for (i = 0, seg = segs; i < length; ++i, ++seg) { - seg->x0 *= splashAASize; - seg->y0 *= splashAASize; - seg->x1 *= splashAASize; - seg->y1 *= splashAASize; - } -} - -void SplashXPath::sort() { - std::sort(segs, segs + length, cmpXPathSegsFunctor()); -} diff --git a/source/libs/poppler/poppler-src/splash/SplashXPath.h b/source/libs/poppler/poppler-src/splash/SplashXPath.h deleted file mode 100644 index 1c7040daa2309edab11ebfd4d7af8c283ebe5c2b..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashXPath.h +++ /dev/null @@ -1,107 +0,0 @@ -//======================================================================== -// -// SplashXPath.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHXPATH_H -#define SPLASHXPATH_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" - -class SplashPath; -struct SplashXPathAdjust; - -//------------------------------------------------------------------------ - -#define splashMaxCurveSplits (1 << 10) - -//------------------------------------------------------------------------ -// SplashXPathSeg -//------------------------------------------------------------------------ - -struct SplashXPathSeg { - SplashCoord x0, y0; // first endpoint - SplashCoord x1, y1; // second endpoint - SplashCoord dxdy; // slope: delta-x / delta-y - SplashCoord dydx; // slope: delta-y / delta-x - Guint flags; -}; - -#define splashXPathHoriz 0x01 // segment is vertical (y0 == y1) - // (dxdy is undef) -#define splashXPathVert 0x02 // segment is horizontal (x0 == x1) - // (dydx is undef) -#define splashXPathFlip 0x04 // y0 > y1 - -//------------------------------------------------------------------------ -// SplashXPath -//------------------------------------------------------------------------ - -class SplashXPath { -public: - - // Expands (converts to segments) and flattens (converts curves to - // lines) <path>. Transforms all points from user space to device - // space, via <matrix>. If <closeSubpaths> is true, closes all open - // subpaths. - SplashXPath(SplashPath *path, SplashCoord *matrix, - SplashCoord flatness, GBool closeSubpaths, - GBool adjustLines = gFalse, int linePosI = 0); - - // Copy an expanded path. - SplashXPath *copy() { return new SplashXPath(this); } - - ~SplashXPath(); - - // Multiply all coordinates by splashAASize, in preparation for - // anti-aliased rendering. - void aaScale(); - - // Sort by upper coordinate (lower y), in y-major order. - void sort(); - -protected: - - SplashXPath(SplashXPath *xPath); - void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi, - SplashCoord *xo, SplashCoord *yo); - void strokeAdjust(SplashXPathAdjust *adjust, - SplashCoord *xp, SplashCoord *yp); - void grow(int nSegs); - void addCurve(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1, - SplashCoord x2, SplashCoord y2, - SplashCoord x3, SplashCoord y3, - SplashCoord flatness, - GBool first, GBool last, GBool end0, GBool end1); - void addSegment(SplashCoord x0, SplashCoord y0, - SplashCoord x1, SplashCoord y1); - - SplashXPathSeg *segs; - int length, size; // length and size of segs array - - friend class SplashXPathScanner; - friend class SplashClip; - friend class Splash; -}; - -#endif diff --git a/source/libs/poppler/poppler-src/splash/SplashXPathScanner.cc b/source/libs/poppler/poppler-src/splash/SplashXPathScanner.cc deleted file mode 100644 index ac47881cb4f395c80f282f4caf4a8c03329bfaa6..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashXPathScanner.cc +++ /dev/null @@ -1,544 +0,0 @@ -//======================================================================== -// -// SplashXPathScanner.cc -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2008, 2010, 2014 Albert Astals Cid <aacid@kde.org> -// Copyright (C) 2010 PaweÅ‚ Wiejacha <pawel.wiejacha@gmail.com> -// Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#include <config.h> - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include <stdlib.h> -#include <string.h> -#include <algorithm> -#include "goo/gmem.h" -#include "SplashMath.h" -#include "SplashXPath.h" -#include "SplashBitmap.h" -#include "SplashXPathScanner.h" - -//------------------------------------------------------------------------ - -struct SplashIntersect { - int y; - int x0, x1; // intersection of segment with [y, y+1) - int count; // EO/NZWN counter increment -}; - -struct cmpIntersectFunctor { - bool operator()(const SplashIntersect &i0, const SplashIntersect &i1) { - return (i0.y != i1.y) ? (i0.y < i1.y) : (i0.x0 < i1.x0); - } -}; - -//------------------------------------------------------------------------ -// SplashXPathScanner -//------------------------------------------------------------------------ - -SplashXPathScanner::SplashXPathScanner(SplashXPath *xPathA, GBool eoA, - int clipYMin, int clipYMax) { - SplashXPathSeg *seg; - SplashCoord xMinFP, yMinFP, xMaxFP, yMaxFP; - int i; - - xPath = xPathA; - eo = eoA; - partialClip = gFalse; - - // compute the bbox - if (xPath->length == 0) { - xMin = yMin = 1; - xMax = yMax = 0; - } else { - seg = &xPath->segs[0]; - if (seg->x0 <= seg->x1) { - xMinFP = seg->x0; - xMaxFP = seg->x1; - } else { - xMinFP = seg->x1; - xMaxFP = seg->x0; - } - if (seg->flags & splashXPathFlip) { - yMinFP = seg->y1; - yMaxFP = seg->y0; - } else { - yMinFP = seg->y0; - yMaxFP = seg->y1; - } - for (i = 1; i < xPath->length; ++i) { - seg = &xPath->segs[i]; - if (seg->x0 < xMinFP) { - xMinFP = seg->x0; - } else if (seg->x0 > xMaxFP) { - xMaxFP = seg->x0; - } - if (seg->x1 < xMinFP) { - xMinFP = seg->x1; - } else if (seg->x1 > xMaxFP) { - xMaxFP = seg->x1; - } - if (seg->flags & splashXPathFlip) { - if (seg->y0 > yMaxFP) { - yMaxFP = seg->y0; - } - } else { - if (seg->y1 > yMaxFP) { - yMaxFP = seg->y1; - } - } - } - xMin = splashFloor(xMinFP); - xMax = splashFloor(xMaxFP); - yMin = splashFloor(yMinFP); - yMax = splashFloor(yMaxFP); - if (clipYMin > yMin) { - yMin = clipYMin; - partialClip = gTrue; - } - if (clipYMax < yMax) { - yMax = clipYMax; - partialClip = gTrue; - } - } - - allInter = NULL; - inter = NULL; - computeIntersections(); - interY = yMin - 1; -} - -SplashXPathScanner::~SplashXPathScanner() { - gfree(inter); - gfree(allInter); -} - -void SplashXPathScanner::getBBoxAA(int *xMinA, int *yMinA, - int *xMaxA, int *yMaxA) { - *xMinA = xMin / splashAASize; - *yMinA = yMin / splashAASize; - *xMaxA = xMax / splashAASize; - *yMaxA = yMax / splashAASize; -} - -void SplashXPathScanner::getSpanBounds(int y, int *spanXMin, int *spanXMax) { - int interBegin, interEnd, xx, i; - - if (y < yMin || y > yMax) { - interBegin = interEnd = 0; - } else { - interBegin = inter[y - yMin]; - interEnd = inter[y - yMin + 1]; - } - if (interBegin < interEnd) { - *spanXMin = allInter[interBegin].x0; - xx = allInter[interBegin].x1; - for (i = interBegin + 1; i < interEnd; ++i) { - if (allInter[i].x1 > xx) { - xx = allInter[i].x1; - } - } - *spanXMax = xx; - } else { - *spanXMin = xMax + 1; - *spanXMax = xMax; - } -} - -GBool SplashXPathScanner::test(int x, int y) { - int interBegin, interEnd, count, i; - - if (y < yMin || y > yMax) { - return gFalse; - } - interBegin = inter[y - yMin]; - interEnd = inter[y - yMin + 1]; - count = 0; - for (i = interBegin; i < interEnd && allInter[i].x0 <= x; ++i) { - if (x <= allInter[i].x1) { - return gTrue; - } - count += allInter[i].count; - } - return eo ? (count & 1) : (count != 0); -} - -GBool SplashXPathScanner::testSpan(int x0, int x1, int y) { - int interBegin, interEnd, count, xx1, i; - - if (y < yMin || y > yMax) { - return gFalse; - } - interBegin = inter[y - yMin]; - interEnd = inter[y - yMin + 1]; - count = 0; - for (i = interBegin; i < interEnd && allInter[i].x1 < x0; ++i) { - count += allInter[i].count; - } - - // invariant: the subspan [x0,xx1] is inside the path - xx1 = x0 - 1; - while (xx1 < x1) { - if (i >= interEnd) { - return gFalse; - } - if (allInter[i].x0 > xx1 + 1 && - !(eo ? (count & 1) : (count != 0))) { - return gFalse; - } - if (allInter[i].x1 > xx1) { - xx1 = allInter[i].x1; - } - count += allInter[i].count; - ++i; - } - - return gTrue; -} - -GBool SplashXPathScanner::getNextSpan(int y, int *x0, int *x1) { - int interEnd, xx0, xx1; - - if (y < yMin || y > yMax) { - return gFalse; - } - if (interY != y) { - interY = y; - interIdx = inter[y - yMin]; - interCount = 0; - } - interEnd = inter[y - yMin + 1]; - if (interIdx >= interEnd) { - return gFalse; - } - xx0 = allInter[interIdx].x0; - xx1 = allInter[interIdx].x1; - interCount += allInter[interIdx].count; - ++interIdx; - while (interIdx < interEnd && - (allInter[interIdx].x0 <= xx1 || - (eo ? (interCount & 1) : (interCount != 0)))) { - if (allInter[interIdx].x1 > xx1) { - xx1 = allInter[interIdx].x1; - } - interCount += allInter[interIdx].count; - ++interIdx; - } - *x0 = xx0; - *x1 = xx1; - return gTrue; -} - -void SplashXPathScanner::computeIntersections() { - SplashXPathSeg *seg; - SplashCoord segXMin, segXMax, segYMin, segYMax, xx0, xx1; - int x, y, y0, y1, i; - - if (yMin > yMax) { - return; - } - - // build the list of all intersections - allInterLen = 0; - allInterSize = 16; - allInter = (SplashIntersect *)gmallocn(allInterSize, - sizeof(SplashIntersect)); - for (i = 0; i < xPath->length; ++i) { - seg = &xPath->segs[i]; - if (seg->flags & splashXPathFlip) { - segYMin = seg->y1; - segYMax = seg->y0; - } else { - segYMin = seg->y0; - segYMax = seg->y1; - } - if (seg->flags & splashXPathHoriz) { - y = splashFloor(seg->y0); - if (y >= yMin && y <= yMax) { - if (!addIntersection(segYMin, segYMax, seg->flags, - y, splashFloor(seg->x0), splashFloor(seg->x1))) - break; - } - } else if (seg->flags & splashXPathVert) { - y0 = splashFloor(segYMin); - if (y0 < yMin) { - y0 = yMin; - } - y1 = splashFloor(segYMax); - if (y1 > yMax) { - y1 = yMax; - } - x = splashFloor(seg->x0); - for (y = y0; y <= y1; ++y) { - if (!addIntersection(segYMin, segYMax, seg->flags, y, x, x)) - break; - } - } else { - if (seg->x0 < seg->x1) { - segXMin = seg->x0; - segXMax = seg->x1; - } else { - segXMin = seg->x1; - segXMax = seg->x0; - } - y0 = splashFloor(segYMin); - if (y0 < yMin) { - y0 = yMin; - } - y1 = splashFloor(segYMax); - if (y1 > yMax) { - y1 = yMax; - } - // this loop could just add seg->dxdy to xx1 on each iteration, - // but that introduces numerical accuracy problems - xx1 = seg->x0 + ((SplashCoord)y0 - seg->y0) * seg->dxdy; - for (y = y0; y <= y1; ++y) { - xx0 = xx1; - xx1 = seg->x0 + ((SplashCoord)(y + 1) - seg->y0) * seg->dxdy; - // the segment may not actually extend to the top and/or bottom edges - if (xx0 < segXMin) { - xx0 = segXMin; - } else if (xx0 > segXMax) { - xx0 = segXMax; - } - if (xx1 < segXMin) { - xx1 = segXMin; - } else if (xx1 > segXMax) { - xx1 = segXMax; - } - if (!addIntersection(segYMin, segYMax, seg->flags, y, - splashFloor(xx0), splashFloor(xx1))) - break; - } - } - } - std::sort(allInter, allInter + allInterLen, cmpIntersectFunctor()); - - // build the list of y pointers - inter = (int *)gmallocn(yMax - yMin + 2, sizeof(int)); - i = 0; - for (y = yMin; y <= yMax; ++y) { - inter[y - yMin] = i; - while (i < allInterLen && allInter[i].y <= y) { - ++i; - } - } - inter[yMax - yMin + 1] = i; -} - -GBool SplashXPathScanner::addIntersection(double segYMin, double segYMax, - Guint segFlags, - int y, int x0, int x1) { - if (allInterLen == allInterSize) { - unsigned int newInterSize = ((unsigned int) allInterSize * 2 > INT_MAX / sizeof(SplashIntersect)) ? allInterSize + 32768 : allInterSize * 2; - if (newInterSize >= INT_MAX / sizeof(SplashIntersect)) { - error(errInternal, -1, "Bogus memory allocation size in SplashXPathScanner::addIntersection {0:d}", newInterSize); - return gFalse; - } - allInterSize = newInterSize; - allInter = (SplashIntersect *)greallocn(allInter, newInterSize, - sizeof(SplashIntersect)); - } - allInter[allInterLen].y = y; - if (x0 < x1) { - allInter[allInterLen].x0 = x0; - allInter[allInterLen].x1 = x1; - } else { - allInter[allInterLen].x0 = x1; - allInter[allInterLen].x1 = x0; - } - if (segYMin <= y && - (SplashCoord)y < segYMax && - !(segFlags & splashXPathHoriz)) { - allInter[allInterLen].count = eo ? 1 - : (segFlags & splashXPathFlip) ? 1 : -1; - } else { - allInter[allInterLen].count = 0; - } - ++allInterLen; - return gTrue; -} - -void SplashXPathScanner::renderAALine(SplashBitmap *aaBuf, - int *x0, int *x1, int y, GBool adjustVertLine) { - int xx0, xx1, xx, xxMin, xxMax, yy, interEnd; - Guchar mask; - SplashColorPtr p; - - memset(aaBuf->getDataPtr(), 0, aaBuf->getRowSize() * aaBuf->getHeight()); - xxMin = aaBuf->getWidth(); - xxMax = -1; - if (yMin <= yMax) { - if (splashAASize * y < yMin) { - interIdx = inter[0]; - } else if (splashAASize * y > yMax) { - interIdx = inter[yMax - yMin + 1]; - } else { - interIdx = inter[splashAASize * y - yMin]; - } - for (yy = 0; yy < splashAASize; ++yy) { - if (splashAASize * y + yy < yMin) { - interEnd = inter[0]; - } else if (splashAASize * y + yy > yMax) { - interEnd = inter[yMax - yMin + 1]; - } else { - interEnd = inter[splashAASize * y + yy - yMin + 1]; - } - interCount = 0; - while (interIdx < interEnd) { - xx0 = allInter[interIdx].x0; - xx1 = allInter[interIdx].x1; - interCount += allInter[interIdx].count; - ++interIdx; - while (interIdx < interEnd && - (allInter[interIdx].x0 <= xx1 || - (eo ? (interCount & 1) : (interCount != 0)))) { - if (allInter[interIdx].x1 > xx1) { - xx1 = allInter[interIdx].x1; - } - interCount += allInter[interIdx].count; - ++interIdx; - } - if (xx0 < 0) { - xx0 = 0; - } - ++xx1; - if (xx1 > aaBuf->getWidth()) { - xx1 = aaBuf->getWidth(); - } - // set [xx0, xx1) to 1 - if (xx0 < xx1) { - xx = xx0; - p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + (xx >> 3); - if (xx & 7) { - mask = adjustVertLine ? 0xff : 0xff >> (xx & 7); - if (!adjustVertLine && (xx & ~7) == (xx1 & ~7)) { - mask &= (Guchar)(0xff00 >> (xx1 & 7)); - } - *p++ |= mask; - xx = (xx & ~7) + 8; - } - for (; xx + 7 < xx1; xx += 8) { - *p++ |= 0xff; - } - if (xx < xx1) { - *p |= adjustVertLine ? 0xff : (Guchar)(0xff00 >> (xx1 & 7)); - } - } - if (xx0 < xxMin) { - xxMin = xx0; - } - if (xx1 > xxMax) { - xxMax = xx1; - } - } - } - } - if (xxMin > xxMax) { - xxMin = xxMax; - } - *x0 = xxMin / splashAASize; - *x1 = (xxMax - 1) / splashAASize; -} - -void SplashXPathScanner::clipAALine(SplashBitmap *aaBuf, - int *x0, int *x1, int y) { - int xx0, xx1, xx, yy, interEnd; - Guchar mask; - SplashColorPtr p; - - for (yy = 0; yy < splashAASize; ++yy) { - xx = *x0 * splashAASize; - if (yMin <= yMax) { - if (splashAASize * y + yy < yMin) { - interIdx = interEnd = inter[0]; - } else if (splashAASize * y + yy > yMax) { - interIdx = interEnd = inter[yMax - yMin + 1]; - } else { - interIdx = inter[splashAASize * y + yy - yMin]; - if (splashAASize * y + yy > yMax) { - interEnd = inter[yMax - yMin + 1]; - } else { - interEnd = inter[splashAASize * y + yy - yMin + 1]; - } - } - interCount = 0; - while (interIdx < interEnd && xx < (*x1 + 1) * splashAASize) { - xx0 = allInter[interIdx].x0; - xx1 = allInter[interIdx].x1; - interCount += allInter[interIdx].count; - ++interIdx; - while (interIdx < interEnd && - (allInter[interIdx].x0 <= xx1 || - (eo ? (interCount & 1) : (interCount != 0)))) { - if (allInter[interIdx].x1 > xx1) { - xx1 = allInter[interIdx].x1; - } - interCount += allInter[interIdx].count; - ++interIdx; - } - if (xx0 > aaBuf->getWidth()) { - xx0 = aaBuf->getWidth(); - } - // set [xx, xx0) to 0 - if (xx < xx0) { - p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + (xx >> 3); - if (xx & 7) { - mask = (Guchar)(0xff00 >> (xx & 7)); - if ((xx & ~7) == (xx0 & ~7)) { - mask |= 0xff >> (xx0 & 7); - } - *p++ &= mask; - xx = (xx & ~7) + 8; - } - for (; xx + 7 < xx0; xx += 8) { - *p++ = 0x00; - } - if (xx < xx0) { - *p &= 0xff >> (xx0 & 7); - } - } - if (xx1 >= xx) { - xx = xx1 + 1; - } - } - } - xx0 = (*x1 + 1) * splashAASize; - if (xx0 > aaBuf->getWidth()) xx0 = aaBuf->getWidth(); - // set [xx, xx0) to 0 - if (xx < xx0 && xx >= 0) { - p = aaBuf->getDataPtr() + yy * aaBuf->getRowSize() + (xx >> 3); - if (xx & 7) { - mask = (Guchar)(0xff00 >> (xx & 7)); - if ((xx & ~7) == (xx0 & ~7)) { - mask &= 0xff >> (xx0 & 7); - } - *p++ &= mask; - xx = (xx & ~7) + 8; - } - for (; xx + 7 < xx0; xx += 8) { - *p++ = 0x00; - } - if (xx < xx0) { - *p &= 0xff >> (xx0 & 7); - } - } - } -} diff --git a/source/libs/poppler/poppler-src/splash/SplashXPathScanner.h b/source/libs/poppler/poppler-src/splash/SplashXPathScanner.h deleted file mode 100644 index cc295cb68fede84c6a8e038103534a68b55b42a6..0000000000000000000000000000000000000000 --- a/source/libs/poppler/poppler-src/splash/SplashXPathScanner.h +++ /dev/null @@ -1,108 +0,0 @@ -//======================================================================== -// -// SplashXPathScanner.h -// -//======================================================================== - -//======================================================================== -// -// Modified under the Poppler project - http://poppler.freedesktop.org -// -// All changes made under the Poppler project to this file are licensed -// under GPL version 2 or later -// -// Copyright (C) 2013, 2014 Thomas Freitag <Thomas.Freitag@alfa.de> -// -// 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 -// -//======================================================================== - -#ifndef SPLASHXPATHSCANNER_H -#define SPLASHXPATHSCANNER_H - -#ifdef USE_GCC_PRAGMAS -#pragma interface -#endif - -#include "SplashTypes.h" - -class SplashXPath; -class SplashBitmap; -struct SplashIntersect; - -//------------------------------------------------------------------------ -// SplashXPathScanner -//------------------------------------------------------------------------ - -class SplashXPathScanner { -public: - - // Create a new SplashXPathScanner object. <xPathA> must be sorted. - SplashXPathScanner(SplashXPath *xPathA, GBool eoA, - int clipYMin, int clipYMax); - - ~SplashXPathScanner(); - - // Return the path's bounding box. - void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA) - { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } - - // Return the path's bounding box. - void getBBoxAA(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA); - - // Returns true if at least part of the path was outside the - // clipYMin/clipYMax bounds passed to the constructor. - GBool hasPartialClip() { return partialClip; } - - // Return the min/max x values for the span at <y>. - void getSpanBounds(int y, int *spanXMin, int *spanXMax); - - // Returns true if (<x>,<y>) is inside the path. - GBool test(int x, int y); - - // Returns true if the entire span ([<x0>,<x1>], <y>) is inside the - // path. - GBool testSpan(int x0, int x1, int y); - - // Returns the next span inside the path at <y>. If <y> is - // different than the previous call to getNextSpan, this returns the - // first span at <y>; otherwise it returns the next span (relative - // to the previous call to getNextSpan). Returns false if there are - // no more spans at <y>. - GBool getNextSpan(int y, int *x0, int *x1); - - // Renders one anti-aliased line into <aaBuf>. Returns the min and - // max x coordinates with non-zero pixels in <x0> and <x1>. - void renderAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y, - GBool adjustVertLine = gFalse); - - // Clips an anti-aliased line by setting pixels to zero. On entry, - // all non-zero pixels are between <x0> and <x1>. This function - // will update <x0> and <x1>. - void clipAALine(SplashBitmap *aaBuf, int *x0, int *x1, int y); - -private: - - void computeIntersections(); - GBool addIntersection(double segYMin, double segYMax, - Guint segFlags, - int y, int x0, int x1); - - SplashXPath *xPath; - GBool eo; - int xMin, yMin, xMax, yMax; - GBool partialClip; - - SplashIntersect *allInter; // array of intersections - int allInterLen; // number of intersections in <allInter> - int allInterSize; // size of the <allInter> array - int *inter; // indexes into <allInter> for each y value - int interY; // current y value - used by getNextSpan - int interIdx; // current index into <inter> - used by - // getNextSpan - int interCount; // current EO/NZWN counter - used by - // getNextSpan -}; - -#endif diff --git a/source/libs/poppler/version.ac b/source/libs/poppler/version.ac index 678ff6080c78aadabcb306c927b88fcae7064e29..6f38baf5def1c1a657886c0a57c41593aa20105b 100644 --- a/source/libs/poppler/version.ac +++ b/source/libs/poppler/version.ac @@ -8,4 +8,4 @@ dnl dnl -------------------------------------------------------- dnl dnl m4-include this file to define the current poppler version -m4_define([poppler_version], [0.59.0]) +m4_define([poppler_version], [0.60.0]) diff --git a/source/texk/web2c/luatexdir/font/writefont.w b/source/texk/web2c/luatexdir/font/writefont.w index 1cbe42cdbc2c025188d88cff63401efddad134b3..2ba81d61749d7069751ec1a4237a30803787f9fd 100644 --- a/source/texk/web2c/luatexdir/font/writefont.w +++ b/source/texk/web2c/luatexdir/font/writefont.w @@ -578,7 +578,7 @@ static void write_fontdescriptor(PDF pdf, fd_entry * fd) assert(0); } } - if ((! pdf->omit_cidset) && (cidset != 0)) { + if ((! pdf->omit_cidset) && (pdf->major_version == 1) && (cidset != 0) ) { pdf_dict_add_ref(pdf, "CIDSet", cidset); } /* diff --git a/source/texk/web2c/luatexdir/font/writetype2.w b/source/texk/web2c/luatexdir/font/writetype2.w index dc1821c5e5f8da5ae2eb2d915b4e96eea6915986..81aefb1fb69206dcd7444e355df2bd4fa9e2f18f 100644 --- a/source/texk/web2c/luatexdir/font/writetype2.w +++ b/source/texk/web2c/luatexdir/font/writetype2.w @@ -387,24 +387,26 @@ boolean make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buff, int buflen) /* CIDSet: a table of bits indexed by cid, bytes with high order bit first, each (set) bit is a (present) CID. */ if (is_subsetted(fd->fm)) { - cidset = pdf_create_obj(pdf, obj_type_others, 0); - if (cidset != 0) { - size_t l = (last_cid / 8) + 1; - char *stream = xmalloc(l); - memset(stream, 0, l); - for (cid = 1; cid <= (long) last_cid; cid++) { - if (used_chars[cid]) { - stream[(cid / 8)] |= (1 << (7 - (cid % 8))); + if ((! pdf->omit_cidset) && (pdf->major_version == 1)) { + cidset = pdf_create_obj(pdf, obj_type_others, 0); + if (cidset != 0) { + size_t l = (last_cid / 8) + 1; + char *stream = xmalloc(l); + memset(stream, 0, l); + for (cid = 1; cid <= (long) last_cid; cid++) { + if (used_chars[cid]) { + stream[(cid / 8)] |= (1 << (7 - (cid % 8))); + } } + pdf_begin_obj(pdf, cidset, OBJSTM_NEVER); + pdf_begin_dict(pdf); + pdf_dict_add_streaminfo(pdf); + pdf_end_dict(pdf); + pdf_begin_stream(pdf); + pdf_out_block(pdf, stream, l); + pdf_end_stream(pdf); + pdf_end_obj(pdf); } - pdf_begin_obj(pdf, cidset, OBJSTM_NEVER); - pdf_begin_dict(pdf); - pdf_dict_add_streaminfo(pdf); - pdf_end_dict(pdf); - pdf_begin_stream(pdf); - pdf_out_block(pdf, stream, l); - pdf_end_stream(pdf); - pdf_end_obj(pdf); } } diff --git a/source/texk/web2c/luatexdir/image/image.h b/source/texk/web2c/luatexdir/image/image.h index 2ff07d448bdec74477e0c863d2f43a1aa7752e9d..7c79723f1df206e7a1ff68555a0a3dffe9fde9e7 100644 --- a/source/texk/web2c/luatexdir/image/image.h +++ b/source/texk/web2c/luatexdir/image/image.h @@ -126,6 +126,7 @@ typedef struct { int luaref ; boolean keepopen; int errorlevel; + int pdfmajorversion; int pdfminorversion; union { pdf_stream_struct *pdfstream; @@ -171,6 +172,7 @@ typedef struct { # define img_luaref(N) ((N)->luaref) # define img_keepopen(N) ((N)->keepopen) # define img_errorlevel(N) ((N)->errorlevel) +# define img_pdfmajorversion(N) ((N)->pdfmajorversion) # define img_pdfminorversion(N) ((N)->pdfminorversion) # define img_pdfstream_ptr(N) ((N)->img_struct.pdfstream) diff --git a/source/texk/web2c/luatexdir/image/pdftoepdf.w b/source/texk/web2c/luatexdir/image/pdftoepdf.w index c60cd7d77dffeba6d9954bea30577af5b937582f..09dcd251584c5adf82c192c2f4493cf8169bc7a1 100644 --- a/source/texk/web2c/luatexdir/image/pdftoepdf.w +++ b/source/texk/web2c/luatexdir/image/pdftoepdf.w @@ -27,7 +27,7 @@ /* This file is mostly C and not very much C++; it's just used to interface the functions of poppler, which happens to be written in C++. - Patches for the new poppler 0.59 from + Patches for the new poppler 0.59 from https://www.mail-archive.com/arch-commits@archlinux.org/msg357548.html with some modifications to comply the poppler API. @@ -597,7 +597,7 @@ void read_pdf_info(image_dict * idict) pdf_doc = refPdfDocument(img_filepath(idict), FE_FAIL); else if (img_type(idict) == IMG_TYPE_PDFMEMSTREAM) { pdf_doc = findPdfDocument(img_filepath(idict)) ; - if (pdf_doc == NULL ) + if (pdf_doc == NULL ) normal_error("pdf inclusion", "memstream not initialized"); if (pdf_doc->doc == NULL) normal_error("pdf inclusion", "memstream document is empty"); @@ -614,12 +614,12 @@ void read_pdf_info(image_dict * idict) */ pdf_major_version_found = doc->getPDFMajorVersion(); pdf_minor_version_found = doc->getPDFMinorVersion(); - if ((pdf_major_version_found > 1) || (pdf_minor_version_found > img_pdfminorversion(idict))) { - const char *msg = "PDF inclusion: found PDF version '%d.%d', but at most version '1.%d' allowed"; + if ((100 * pdf_major_version_found + pdf_major_version_found) > (100 * img_pdfmajorversion(idict) + img_pdfminorversion(idict))) { + const char *msg = "PDF inclusion: found PDF version '%d.%d', but at most version '%d.%d' allowed"; if (img_errorlevel(idict) > 0) { - formatted_error("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfminorversion(idict)); + formatted_error("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfmajorversion(idict), img_pdfminorversion(idict)); } else { - formatted_warning("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfminorversion(idict)); + formatted_warning("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfmajorversion(idict), img_pdfminorversion(idict)); } } img_totalpages(idict) = catalog->getNumPages(); diff --git a/source/texk/web2c/luatexdir/image/writeimg.w b/source/texk/web2c/luatexdir/image/writeimg.w index 0944509c044495ab21240f6e51f6ea55d353b717..95e1ec3049de198e26bfcc1eea8e7aec770447db 100644 --- a/source/texk/web2c/luatexdir/image/writeimg.w +++ b/source/texk/web2c/luatexdir/image/writeimg.w @@ -100,7 +100,7 @@ that a type has been found. #define HEADER_PNG "\x89PNG\r\n\x1A\n" #define HEADER_JBIG2 "\x97\x4A\x42\x32\x0D\x0A\x1A\x0A" #define HEADER_JP2 "\x6A\x50\x20\x20" -#define HEADER_PDF "%PDF-1." +#define HEADER_PDF "%PDF-" #define MAX_HEADER (sizeof(HEADER_PNG)-1) #define HEADER_PDF_MEMSTREAM "data:application/pdf," /* see epdf.h */ #define LEN_PDF_MEMSTREAM 21 /* see epdf.h */ @@ -217,7 +217,8 @@ image_dict *new_image_dict(void) img_index(p) = -1; /* -1 = unused, used count from 0 */ img_luaref(p) = 0; img_errorlevel(p) = pdf_inclusion_errorlevel; - fix_pdf_minorversion(static_pdf); + fix_pdf_version(static_pdf); + img_pdfmajorversion(p) = pdf_major_version; img_pdfminorversion(p) = pdf_minor_version; return p; } diff --git a/source/texk/web2c/luatexdir/image/writejbig2.w b/source/texk/web2c/luatexdir/image/writejbig2.w index d1ed0a408d414459e60137aaa4597898f147307b..a58313ce8d8992a4a7dacb097c51bedf2685b93e 100644 --- a/source/texk/web2c/luatexdir/image/writejbig2.w +++ b/source/texk/web2c/luatexdir/image/writejbig2.w @@ -762,7 +762,7 @@ static void wr_jbig2(PDF pdf, image_dict * idict, FILEINFO * fip, @ @c boolean supported_jbig2(image_dict * idict) { - if (img_pdfminorversion(idict) < 4) { + if (img_pdfmajorversion(idict) < 2 && img_pdfminorversion(idict) < 4) { normal_error("readjbig2","you need to generate at least PDF 1.4"); return false; } else { diff --git a/source/texk/web2c/luatexdir/image/writejpg.w b/source/texk/web2c/luatexdir/image/writejpg.w index 7d463b7737452374b99b814fa0813c918cf7fe0d..54ed47f0f9297d9866f87e2b8899958d7beab3b4 100644 --- a/source/texk/web2c/luatexdir/image/writejpg.w +++ b/source/texk/web2c/luatexdir/image/writejpg.w @@ -132,9 +132,9 @@ static unsigned int read_exif_bytes(unsigned char **p, int n, int b) XResolution, YResolution and ResolutionUnit (tag 282, 283 and 296) as well as PixelPerUnitX, PixelPerUnitY and PixelUnit (tag 0x5111, 0x5112 and 0x5110). Tags 282, 293 and 296 have the priority, -with ResolutionUnit set to inch by default, then +with ResolutionUnit set to inch by default, then tag 0x5110, 0x5111 and 0x5112, where the only valid value for PixelUnit is 0.0254, -and finally the given value xx and yy, +and finally the given value xx and yy, choosen if the Exif x and y resolution are not strictly positive. @@ -256,7 +256,7 @@ static void read_APP1_Exif (FILE *fp, unsigned short length, int *xx, int *yy, i res_unit_ms = 0.0254; /* Unit is meter */ break; default: - res_unit_ms = 0; + res_unit_ms = 0; } case 0x5111: /* PixelPerUnitX */ found_x_ms = true ; @@ -269,13 +269,13 @@ static void read_APP1_Exif (FILE *fp, unsigned short length, int *xx, int *yy, i } - } + } if (found_x && found_y && res_unit>0) { - found_res = true; + found_res = true; tempx = (int)(xres * res_unit+0.5); tempy = (int)(yres * res_unit+0.5); } else if (found_x_ms && found_y_ms && res_unit_ms==0.0254) { - found_res = true; + found_res = true; tempx = (int)(xres_ms * res_unit_ms+0.5); tempy = (int)(yres_ms * res_unit_ms+0.5); } @@ -394,7 +394,7 @@ void read_jpg_info(image_dict * idict) formatted_error("readjpg","unsupported compression SOF_%d", i - M_SOF0); break; case M_SOF2: - if (img_pdfminorversion(idict) <= 2) { + if (img_pdfmajorversion(idict) < 2 && img_pdfminorversion(idict) <= 2) { normal_error("readjpg","progressive DCT with PDF-1.2 is not permitted"); } case M_SOF0: diff --git a/source/texk/web2c/luatexdir/lua/lpdflib.c b/source/texk/web2c/luatexdir/lua/lpdflib.c index f20604ead8f37f4afb3e95a1a0bd56a915f310ec..88f9eac7c24ac27fdb714f2dda47f52964be7b09 100644 --- a/source/texk/web2c/luatexdir/lua/lpdflib.c +++ b/source/texk/web2c/luatexdir/lua/lpdflib.c @@ -949,6 +949,25 @@ static int getpdfcreationdate(lua_State * L) return 1 ; } +static int getpdfmajorversion(lua_State * L) +{ + /* lua_pushinteger(L,static_pdf->major_version); */ + lua_pushinteger(L,pdf_major_version); + return 1 ; +} + +static int setpdfmajorversion(lua_State * L) +{ + if (lua_type(L, 1) == LUA_TNUMBER) { + int c = (int) lua_tointeger(L, 1); + if ((c >= 1) && (c <= 2)) { + static_pdf->major_version = c; + set_pdf_major_version(c); + } + } + return 0 ; +} + static int getpdfminorversion(lua_State * L) { /* lua_pushinteger(L,static_pdf->minor_version); */ @@ -1199,6 +1218,8 @@ static const struct luaL_Reg pdflib[] = { { "xformname", getpdfxformname }, { "getversion", getpdfversion }, { "getcreationdate", getpdfcreationdate }, + { "getmajorversion", getpdfmajorversion }, + { "setmajorversion", setpdfmajorversion }, { "getminorversion", getpdfminorversion }, { "setminorversion", setpdfminorversion }, { "newcolorstack", newpdfcolorstack }, diff --git a/source/texk/web2c/luatexdir/lua/ltexlib.c b/source/texk/web2c/luatexdir/lua/ltexlib.c index f975dc90af910c0e97d3695c7b6af1a82e208843..641bc578f0d98e2e32f377a6b6be03c0f785be77 100644 --- a/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -789,7 +789,7 @@ static int get_item_index(lua_State * L, int i, int base) static int gettex(lua_State * L); -#define get_item_index_plus(L, where, base, what, value, is_assign, get_register, glue) { \ +#define get_item_index_plus(L, where, base, what, value, is_assign, get_register, texget) { \ size_t len; \ const char *str; \ int key, cs; \ @@ -804,7 +804,7 @@ static int gettex(lua_State * L); if (key >= 0 && key <= 65535) { \ value = get_register(key); \ } else if (is_assign(eq_type(cs))) { \ - gettex(L); /* lazy */ \ + texget = gettex(L); /* lazy */ \ } else { \ luaL_error(L, "incorrect %s name", what); \ } \ @@ -849,7 +849,11 @@ static int setdimen(lua_State * L) static int getdimen(lua_State * L) { int value = 0; - get_item_index_plus(L, lua_gettop(L), scaled_base, "dimen", value, is_dim_assign, get_tex_dimen_register, false); + int texget = 0; + get_item_index_plus(L, lua_gettop(L), scaled_base, "dimen", value, is_dim_assign, get_tex_dimen_register, texget); + if (texget > 0) { + return texget; + } lua_pushinteger(L, value); return 1; } @@ -877,7 +881,11 @@ static int setskip(lua_State * L) static int getskip(lua_State * L) { int value = 0; - get_item_index_plus(L, lua_gettop(L), skip_base, "skip", value, is_glue_assign, get_tex_skip_register, true); + int texget = 0; + get_item_index_plus(L, lua_gettop(L), skip_base, "skip", value, is_glue_assign, get_tex_skip_register, texget); + if (texget > 0) { + return texget; + } if (value == null) { lua_nodelib_push_fast(L, copy_node(zero_glue)); } else { @@ -910,22 +918,47 @@ static int setglue(lua_State * L) static int getglue(lua_State * L) { int value = 0; + int texget = 0; int top = lua_gettop(L); - get_item_index_plus(L, top, skip_base, "skip", value, is_glue_assign, get_tex_skip_register, true); - if (value == null) { - lua_pushinteger(L,0); - lua_pushinteger(L,0); - lua_pushinteger(L,0); - lua_pushinteger(L,0); - lua_pushinteger(L,0); + int dim = -1; + if (top > 1 && lua_type(L,top) == LUA_TBOOLEAN) { + dim = lua_toboolean(L,top); + top = top - 1; } else { - lua_pushinteger(L,width(value)); - lua_pushinteger(L,stretch(value)); - lua_pushinteger(L,shrink(value)); - lua_pushinteger(L,stretch_order(value)); - lua_pushinteger(L,shrink_order(value)); + lua_pushboolean(L,1); + dim = 1 ; + /* no top adaption. somewhat messy, but the gettex fallback checks itself */ + } + /* checks itself for the boolean */ + get_item_index_plus(L, top, skip_base, "glue", value, is_glue_assign, get_tex_skip_register, texget); + if (texget > 0) { + return texget; + } + if (dim == 0) { + /* false */ + if (value == null) { + lua_pushinteger(L,0); + } else { + lua_pushinteger(L,width(value)); + } + return 1; + } else { + /* true and nil */ + if (value == null) { + lua_pushinteger(L,0); + lua_pushinteger(L,0); + lua_pushinteger(L,0); + lua_pushinteger(L,0); + lua_pushinteger(L,0); + } else { + lua_pushinteger(L,width(value)); + lua_pushinteger(L,stretch(value)); + lua_pushinteger(L,shrink(value)); + lua_pushinteger(L,stretch_order(value)); + lua_pushinteger(L,shrink_order(value)); + } + return 5; } - return 5; } static int ismuskip(lua_State * L) @@ -947,7 +980,11 @@ static int setmuskip(lua_State * L) static int getmuskip(lua_State * L) { int value = 0; - get_item_index_plus(L, lua_gettop(L), mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, true); + int texget = 0; + get_item_index_plus(L, lua_gettop(L), mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, texget); + if (texget > 0) { + return texget; + } lua_nodelib_push_fast(L, copy_node(value)); return 1; } @@ -976,16 +1013,45 @@ static int setmuglue(lua_State * L) static int getmuglue(lua_State * L) { int value = 0; - get_item_index_plus(L, lua_gettop(L), mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, true); - if (value == null) { - lua_pushnil(L); - return 1; + int texget = 0; + int top = lua_gettop(L); + int dim = -1; + if (top > 1 && lua_type(L,top) == LUA_TBOOLEAN) { + dim = lua_toboolean(L,top); + top = top - 1; } else { - lua_pushinteger(L,width(value)); - lua_pushinteger(L,stretch(value)); - lua_pushinteger(L,shrink(value)); - lua_pushinteger(L,stretch_order(value)); - lua_pushinteger(L,shrink_order(value)); + lua_pushboolean(L,1); + dim = 1 ; + /* no top adaption. somewhat messy, but the gettex fallback checks itself */ + } + /* checks itself for the boolean */ + get_item_index_plus(L, top, mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, texget); + if (texget > 0) { + return texget; + } + if (dim == 0) { + /* false */ + if (value == null) { + lua_pushinteger(L,0); + } else { + lua_pushinteger(L,width(value)); + } + return 1; + } else { + /* true and nil */ + if (value == null) { + lua_pushinteger(L,0); + lua_pushinteger(L,0); + lua_pushinteger(L,0); + lua_pushinteger(L,0); + lua_pushinteger(L,0); + } else { + lua_pushinteger(L,width(value)); + lua_pushinteger(L,stretch(value)); + lua_pushinteger(L,shrink(value)); + lua_pushinteger(L,stretch_order(value)); + lua_pushinteger(L,shrink_order(value)); + } return 5; } } @@ -1015,7 +1081,11 @@ static int setcount(lua_State * L) static int getcount(lua_State * L) { int value = 0; - get_item_index_plus(L, lua_gettop(L), count_base, "count", value, is_int_assign, get_tex_count_register, false); + int texget = 0; + get_item_index_plus(L, lua_gettop(L), count_base, "count", value, is_int_assign, get_tex_count_register, texget); + if (texget > 0) { + return texget; + } lua_pushinteger(L, value); return 1; } @@ -1047,7 +1117,11 @@ static int setattribute(lua_State * L) static int getattribute(lua_State * L) { int value = 0; - get_item_index_plus(L, lua_gettop(L), attribute_base, "attribute", value, is_attr_assign, get_tex_attribute_register, false); + int texget = 0; + get_item_index_plus(L, lua_gettop(L), attribute_base, "attribute", value, is_attr_assign, get_tex_attribute_register, texget); + if (texget > 0) { + return texget; + } lua_pushinteger(L, value); return 1; } @@ -3041,6 +3115,7 @@ static int tex_save_box_resource(lua_State * L) int attributes = null; int resources = null; int type = 0; + int margin = pdf_xform_margin; boolean immediate = false; /* box attributes resources */ halfword boxnumber = lua_tointeger(L,1); @@ -3058,6 +3133,9 @@ static int tex_save_box_resource(lua_State * L) if (lua_type(L,5) == LUA_TNUMBER) { type = lua_tointeger(L, 5); } + if (lua_type(L,6) == LUA_TNUMBER) { + margin = lua_tointeger(L, 6); + } /* more or less same as scanner variant */ boxdata = box(boxnumber); if (boxdata == null) @@ -3074,6 +3152,7 @@ static int tex_save_box_resource(lua_State * L) set_obj_xform_height(static_pdf, index, height(boxdata)); set_obj_xform_depth(static_pdf, index, depth(boxdata)); set_obj_xform_type(static_pdf, index, type); + set_obj_xform_margin(static_pdf, index, margin); box(boxnumber) = null; last_saved_box_index = index; lua_pushinteger(L, index); @@ -3138,14 +3217,16 @@ static int tex_get_box_resource_dimensions(lua_State * L) lua_pushnil(L); lua_pushnil(L); lua_pushnil(L); + lua_pushnil(L); } else { index = lua_tointeger(L,1); check_obj_type(static_pdf, obj_type_xform, index); lua_pushinteger(L, (int) obj_xform_width(static_pdf, index)); lua_pushinteger(L, (int) obj_xform_height(static_pdf, index)); lua_pushinteger(L, (int) obj_xform_depth(static_pdf, index)); + lua_pushinteger(L, (int) obj_xform_margin(static_pdf, index)); } - return 3; + return 4; } static int tex_build_page(lua_State * L) diff --git a/source/texk/web2c/luatexdir/luapeg/lpeg.h b/source/texk/web2c/luatexdir/luapeg/lpeg.h index 280e3eaeb37d23eea69bdad9d1afe175c8c9826f..9bc79ff74c689cd0a8b81f2e27e17c7669e5b481 100644 --- a/source/texk/web2c/luatexdir/luapeg/lpeg.h +++ b/source/texk/web2c/luatexdir/luapeg/lpeg.h @@ -13,7 +13,7 @@ #if !defined(lptypes_h) #define lptypes_h - +#define LPEG_DEBUG #if !defined(LPEG_DEBUG) #define NDEBUG #endif diff --git a/source/texk/web2c/luatexdir/luatex.c b/source/texk/web2c/luatexdir/luatex.c index 801906e8e6f554a18419b03dfa0087f54acc6791..1d817b76d235a1681bca5eb3c45eab188d18ba27 100644 --- a/source/texk/web2c/luatexdir/luatex.c +++ b/source/texk/web2c/luatexdir/luatex.c @@ -33,8 +33,8 @@ */ int luatex_version = 106; -int luatex_revision = '1'; -const char *luatex_version_string = "1.06.1"; +int luatex_revision = '2'; +const char *luatex_version_string = "1.06.2"; const char *engine_name = my_name; #include <kpathsea/c-ctype.h> diff --git a/source/texk/web2c/luatexdir/luatex_svnversion.h b/source/texk/web2c/luatexdir/luatex_svnversion.h index 6ab2f316668cd7d4da647dcaa7d98fa52cc841e9..b4b5b28caf0a2a6472405a1b899d63e18087785f 100644 --- a/source/texk/web2c/luatexdir/luatex_svnversion.h +++ b/source/texk/web2c/luatexdir/luatex_svnversion.h @@ -1 +1 @@ -#define luatex_svn_revision 6409 +#define luatex_svn_revision 6420 diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.h b/source/texk/web2c/luatexdir/pdf/pdfgen.h index f2086663c70b82d05d0f921002e4167f437e1917..01b0e74cd1eac0c5d8977c5abb67d88ebf0a1846 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfgen.h +++ b/source/texk/web2c/luatexdir/pdf/pdfgen.h @@ -81,7 +81,7 @@ extern int ten_pow[10]; extern void pdf_flush(PDF); extern void pdf_room(PDF, int); -extern void fix_pdf_minorversion(PDF); +extern void fix_pdf_version(PDF); /* output a byte to PDF buffer without checking of overflow */ diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.w b/source/texk/web2c/luatexdir/pdf/pdfgen.w index 0137755a5745e01500237d35a2a6da294ea72572..26b7112ed0977b80e66d06849081817f3d1458c0 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfgen.w +++ b/source/texk/web2c/luatexdir/pdf/pdfgen.w @@ -190,6 +190,7 @@ PDF init_pdf_struct(PDF pdf) memset(pdf->obj_tab, 0, sizeof(obj_entry)); pdf->minor_version = -1; + pdf->major_version = -1; pdf->decimal_digits = 4; pdf->gamma = 65536; pdf->image_gamma = 65536; @@ -262,35 +263,43 @@ void fix_o_mode(void) } } -@ This ensures that |pdfminorversion| is set only before any bytes have been -written to the generated \.{PDF} file. Here also all variables for \.{PDF} output -are initialized, the \.{PDF} file is opened by |ensure_pdf_open|, and the \.{PDF} -header is written. +@ This ensures that |pdfmajorversion| and |pdfminorversion| are set only before any +bytes have been written to the generated \.{PDF} file. Here also all variables for +\.{PDF} output are initialized, the \.{PDF} file is opened by |ensure_pdf_open|, and +the \.{PDF} header is written. @c -void fix_pdf_minorversion(PDF pdf) -{ - if (pdf->minor_version < 0) { /* unset */ +void fix_pdf_version(PDF pdf) +{ + if (pdf->major_version < 0) { /* unset */ + if (pdf_major_version == 0) { + normal_warning("pdf backend","unset major version, using 1 instead"); + pdf->major_version = 1; + } else if ((pdf_major_version < 0) || (pdf_major_version > 2)) { + formatted_warning("pdf backend","illegal major version %d, using 1 instead",pdf_major_version); + pdf->major_version = 1; + } else { + pdf->major_version = pdf_major_version; + } + } else if (pdf->major_version != pdf_major_version) { + normal_warning("pdf backend", "the major version cannot be changed after data is written to the PDF file"); + } + if (pdf->minor_version < 0) { /* unset */ if ((pdf_minor_version < 0) || (pdf_minor_version > 9)) { - const char *hlp[] = { "The pdfminorversion must be between 0 and 9.", "I changed this to 4.", NULL }; - char msg[256]; - (void) snprintf(msg, 255, "LuaTeX error (illegal pdfminorversion %d)", (int) pdf_minor_version); - tex_error(msg, hlp); + formatted_warning("pdf backend","illegal minor version %d, using 4 instead",pdf_minor_version); pdf->minor_version = 4; } else { pdf->minor_version = pdf_minor_version; } - } else { - /* Check that variables for \.{PDF} output are unchanged */ - if (pdf->minor_version != pdf_minor_version) - normal_error("pdf backend", "minorversion cannot be changed after data is written to the PDF file"); + } else if (pdf->minor_version != pdf_minor_version) { + normal_warning("pdf backend", "minorversion cannot be changed after data is written to the PDF file"); } } static void fix_pdf_draftmode(PDF pdf) { if (pdf->draftmode != draft_mode_par) - normal_error("pdf backend", "draftmode cannot be changed after data is written to the PDF file"); + normal_warning("pdf backend", "draftmode cannot be changed after data is written to the PDF file"); if (pdf->draftmode != 0) { pdf->compress_level = 0; /* re-fix it, might have been changed inbetween */ pdf->objcompresslevel = 0; @@ -1027,11 +1036,11 @@ static void ensure_output_file_open(PDF pdf, const char *ext) static void ensure_pdf_header_written(PDF pdf) { /* Initialize variables for \.{PDF} output */ - fix_pdf_minorversion(pdf); + fix_pdf_version(pdf); init_pdf_outputparameters(pdf); fix_pdf_draftmode(pdf); /* Write \.{PDF} header */ - pdf_printf(pdf, "%%PDF-1.%d\n", pdf->minor_version); + pdf_printf(pdf, "%%PDF-%d.%d\n", pdf->major_version, pdf->minor_version); /* The next blob will be removed 1.0. */ pdf_out(pdf, '%'); pdf_out(pdf, 'P' + 128); @@ -1732,6 +1741,7 @@ void pdf_begin_page(PDF pdf) pdf_dict_add_int(pdf, "FormType", 1); } xform_attributes = pdf_xform_attr; /* lookup once */ + form_margin = obj_xform_margin(pdf, pdf_cur_form); /* now stored in object */ if (xform_attributes != null) pdf_print_toks(pdf, xform_attributes); if (obj_xform_attr(pdf, pdf_cur_form) != null) { @@ -2062,19 +2072,21 @@ void pdf_end_page(PDF pdf) pdf_end_dict(pdf); } /* Generate ProcSet */ - pdf_add_name(pdf, "ProcSet"); - pdf_begin_array(pdf); - if ((procset & PROCSET_PDF) != 0) - pdf_add_name(pdf, "PDF"); - if ((procset & PROCSET_TEXT) != 0) - pdf_add_name(pdf, "Text"); - if ((procset & PROCSET_IMAGE_B) != 0) - pdf_add_name(pdf, "ImageB"); - if ((procset & PROCSET_IMAGE_C) != 0) - pdf_add_name(pdf, "ImageC"); - if ((procset & PROCSET_IMAGE_I) != 0) - pdf_add_name(pdf, "ImageI"); - pdf_end_array(pdf); + if (pdf->major_version == 1) { + pdf_add_name(pdf, "ProcSet"); + pdf_begin_array(pdf); + if ((procset & PROCSET_PDF) != 0) + pdf_add_name(pdf, "PDF"); + if ((procset & PROCSET_TEXT) != 0) + pdf_add_name(pdf, "Text"); + if ((procset & PROCSET_IMAGE_B) != 0) + pdf_add_name(pdf, "ImageB"); + if ((procset & PROCSET_IMAGE_C) != 0) + pdf_add_name(pdf, "ImageC"); + if ((procset & PROCSET_IMAGE_I) != 0) + pdf_add_name(pdf, "ImageI"); + pdf_end_array(pdf); + } pdf_end_dict(pdf); pdf_end_obj(pdf); } diff --git a/source/texk/web2c/luatexdir/pdf/pdftables.h b/source/texk/web2c/luatexdir/pdf/pdftables.h index 9a14d65da458cadda561a46ca5f34894497b7517..cfaab5df04678e43093e4ccd6e2405b9f8c469e6 100644 --- a/source/texk/web2c/luatexdir/pdf/pdftables.h +++ b/source/texk/web2c/luatexdir/pdf/pdftables.h @@ -123,6 +123,7 @@ typedef enum { c_pdf_image_resolution, c_pdf_pk_resolution, c_pdf_unique_resname, + c_pdf_major_version, c_pdf_minor_version, c_pdf_pagebox, c_pdf_inclusion_errorlevel, @@ -170,6 +171,7 @@ extern int pdf_retval; # define pdf_image_resolution get_tex_extension_count_register(c_pdf_image_resolution) # define pdf_pk_resolution get_tex_extension_count_register(c_pdf_pk_resolution) # define pdf_unique_resname get_tex_extension_count_register(c_pdf_unique_resname) +# define pdf_major_version get_tex_extension_count_register(c_pdf_major_version) # define pdf_minor_version get_tex_extension_count_register(c_pdf_minor_version) # define pdf_pagebox get_tex_extension_count_register(c_pdf_pagebox) # define pdf_inclusion_errorlevel get_tex_extension_count_register(c_pdf_inclusion_errorlevel) @@ -200,6 +202,7 @@ extern int pdf_retval; # define pdf_pk_mode get_tex_extension_toks_register(t_pdf_pk_mode) # define pdf_trailer_id get_tex_extension_toks_register(t_pdf_trailer_id) +# define set_pdf_major_version(i) set_tex_extension_count_register(c_pdf_major_version,i) # define set_pdf_minor_version(i) set_tex_extension_count_register(c_pdf_minor_version,i) # define set_pdf_compress_level(i) set_tex_extension_count_register(c_pdf_compress_level,i) # define set_pdf_obj_compress_level(i) set_tex_extension_count_register(c_pdf_obj_compress_level,i) diff --git a/source/texk/web2c/luatexdir/pdf/pdftypes.h b/source/texk/web2c/luatexdir/pdf/pdftypes.h index 34153600d97b56c877773bae6c72c5584af2b270..c5f0393cc207509cedd1e52f80b3a4ebebddb021 100644 --- a/source/texk/web2c/luatexdir/pdf/pdftypes.h +++ b/source/texk/web2c/luatexdir/pdf/pdftypes.h @@ -293,6 +293,7 @@ typedef struct pdf_output_file_ { int gen_tounicode; int omit_cidset; int inclusion_copy_font; + int major_version; /* fixed major part of the PDF version */ int minor_version; /* fixed minor part of the PDF version */ int compress_level; /* level for zlib object stream compression */ int objcompresslevel; /* fixed level for activating PDF object streams */ diff --git a/source/texk/web2c/luatexdir/pdf/pdfxform.h b/source/texk/web2c/luatexdir/pdf/pdfxform.h index 64525d837ea2b24797b553fc74fd57c81ebeae35..2d6441ff496147900883414671e380dd653f478a 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfxform.h +++ b/source/texk/web2c/luatexdir/pdf/pdfxform.h @@ -22,7 +22,7 @@ #ifndef PDFXFORM_H # define PDFXFORM_H -# define pdfmem_xform_size 9 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */ +# define pdfmem_xform_size 10 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */ # define obj_xform_width(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 0] # define obj_xform_height(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 1] @@ -33,6 +33,7 @@ # define obj_xform_attr_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 6] # define obj_xform_resources_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 7] # define obj_xform_type(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 8] +# define obj_xform_margin(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 9] # define set_pdf_xform_objnum(A,B) pdf_xform_objnum(A)=B # define set_obj_xform_width(pdf,A,B) obj_xform_width(pdf,A)=B @@ -44,6 +45,7 @@ # define set_obj_xform_attr_str(pdf,A,B) obj_xform_attr_str(pdf,A)=B # define set_obj_xform_resources_str(pdf,A,B) obj_xform_resources_str(pdf,A)=B # define set_obj_xform_type(pdf,A,B) obj_xform_type(pdf,A)=B +# define set_obj_xform_margin(pdf,A,B) obj_xform_margin(pdf,A)=B extern int pdf_cur_form; /* the form being output */ diff --git a/source/texk/web2c/luatexdir/pdf/pdfxform.w b/source/texk/web2c/luatexdir/pdf/pdfxform.w index 4c83b024939bfbee2631e687d2a64223300b000a..731dc229080a21c9ae75a71361b53852d41fab5f 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfxform.w +++ b/source/texk/web2c/luatexdir/pdf/pdfxform.w @@ -89,6 +89,12 @@ void scan_pdfxform(PDF pdf) } else { set_obj_xform_resources(pdf, k, null); } + if (scan_keyword("margin")) { + scan_int(); + set_obj_xform_margin(pdf, k, cur_val); + } else { + set_obj_xform_margin(pdf, k, pdf_xform_margin); + } set_obj_xform_resources_str(pdf, k, null); scan_int(); p = box(cur_val); diff --git a/source/texk/web2c/luatexdir/tex/dumpdata.w b/source/texk/web2c/luatexdir/tex/dumpdata.w index 6973fbf0e6975acd22e05bf131e35816b50d2a47..8683318bd440c393ec47fca424e30daeedd7ae02 100644 --- a/source/texk/web2c/luatexdir/tex/dumpdata.w +++ b/source/texk/web2c/luatexdir/tex/dumpdata.w @@ -23,7 +23,7 @@ /* we start with 907: the sum of the values of the bytes of "don knuth" */ -#define FORMAT_ID (907+34) +#define FORMAT_ID (907+35) #if ((FORMAT_ID>=0) && (FORMAT_ID<=256)) #error Wrong value for FORMAT_ID. #endif diff --git a/source/texk/web2c/luatexdir/tex/linebreak.w b/source/texk/web2c/luatexdir/tex/linebreak.w index 66536666062e17e57858e2b41d7bd6aba9533f48..345a1a424561e70980bba22b7f9fcfeeae0bc539 100644 --- a/source/texk/web2c/luatexdir/tex/linebreak.w +++ b/source/texk/web2c/luatexdir/tex/linebreak.w @@ -755,6 +755,14 @@ Replacement texts and discretionary texts are supposed to contain only character nodes, kern nodes, and box or rule nodes. @c +#define bad_node_in_disc_error(p) { \ + if (type(p) == whatsit_node) { \ + formatted_error("linebreak","invalid node with type %s and subtype %i found in discretionary",node_data[type(p)].name,subtype(p)); \ + } else { \ + formatted_error("linebreak","invalid node with type %s found in discretionary",node_data[type(p)].name); \ + } \ +} + static void add_to_widths(halfword s, int line_break_dir, int adjust_spacing, scaled * widths) { while (s != null) { @@ -783,7 +791,8 @@ static void add_to_widths(halfword s, int line_break_dir, int adjust_spacing, sc case disc_node: /* TH temp */ break; default: - confusion("invalid node found in discretionary"); /* todo: report type */ + bad_node_in_disc_error(s); + break; } } s = vlink(s); @@ -825,7 +834,7 @@ static void sub_from_widths(halfword s, int line_break_dir, int adjust_spacing, case disc_node: /* TH temp */ break; default: - confusion("invalid node found in discretionary"); /* todo: report type */ + bad_node_in_disc_error(s); break; } } diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.w b/source/texk/web2c/luatexdir/tex/maincontrol.w index 8c712289fde01b88df040babdcd49a7a201fa84d..30de71ad7576aaf3c386cc8198cf43ce26dba707 100644 --- a/source/texk/web2c/luatexdir/tex/maincontrol.w +++ b/source/texk/web2c/luatexdir/tex/maincontrol.w @@ -3660,7 +3660,9 @@ void initialize(void) set_eq_level(end_write, level_one); set_eq_type(end_write, outer_call_cmd); set_equiv(end_write, null); - + /* bah */ + set_pdf_major_version(1); + set_pdf_minor_version(0); } synctexoffset = int_base + synctex_code; diff --git a/source/texk/web2c/luatexdir/tex/texnodes.w b/source/texk/web2c/luatexdir/tex/texnodes.w index 75a8c765612e1255711fcb2e3b98aa5f3f444c60..59c0627c563e5338c478127e9f0332299f857a81 100644 --- a/source/texk/web2c/luatexdir/tex/texnodes.w +++ b/source/texk/web2c/luatexdir/tex/texnodes.w @@ -656,11 +656,14 @@ static int test_count = 1; #define check_action_ref(a) { dorangetest(p,a,var_mem_max); } #define check_attribute_ref(a) { dorangetest(p,a,var_mem_max); } -#define check_token_ref(a) { \ + +/* hm, we can just pass p then */ + +#define check_token_ref(p) { \ if (type(p) == whatsit_node) { \ - formatted_error("nodes","fuzzy token cleanup in whatsit node with id %i and subtype %i",type(p),subtype(p)); \ + formatted_error("nodes","fuzzy token cleanup in whatsit node with type %s and subtype %i",node_data[type(p)].name,subtype(p)); \ } else { \ - formatted_error("nodes","fuzzy token cleanup in node with id %i",type(p)); \ + formatted_error("nodes","fuzzy token cleanup in node with type %s",node_data[type(p)].name); \ } \ } @@ -1631,7 +1634,7 @@ static void check_node_wrapup_core(halfword p) switch (subtype(p)) { /* frontend code */ case special_node: - check_token_ref(write_tokens(p)); + check_token_ref(p); break; case user_defined_node: switch (user_node_type(p)) { @@ -1639,7 +1642,7 @@ static void check_node_wrapup_core(halfword p) check_attribute_ref(user_node_value(p)); break; case 't': - check_token_ref(user_node_value(p)); + check_token_ref(p); break; case 'n': dorangetest(p, user_node_value(p), var_mem_max); @@ -1669,39 +1672,39 @@ void check_node_wrapup_pdf(halfword p) switch (subtype(p)) { case pdf_literal_node: if (pdf_literal_type(p) == normal) - check_token_ref(pdf_literal_data(p)); + check_token_ref(p); break; case pdf_colorstack_node: if (pdf_colorstack_cmd(p) <= colorstack_data) - check_token_ref(pdf_colorstack_data(p)); + check_token_ref(p); break; case pdf_setmatrix_node: - check_token_ref(pdf_setmatrix_data(p)); + check_token_ref(p); break; case late_lua_node: if (late_lua_name(p) > 0) - check_token_ref(late_lua_name(p)); + check_token_ref(p); if (late_lua_type(p) == normal) - check_token_ref(late_lua_data(p)); + check_token_ref(p); break; case pdf_annot_node: - check_token_ref(pdf_annot_data(p)); + check_token_ref(p); break; case pdf_start_link_node: if (pdf_link_attr(p) != null) - check_token_ref(pdf_link_attr(p)); + check_token_ref(p); check_action_ref(pdf_link_action(p)); break; case pdf_dest_node: if (pdf_dest_named_id(p) > 0) - check_token_ref(pdf_dest_id(p)); + check_token_ref(p); break; case pdf_thread_node: case pdf_start_thread_node: if (pdf_thread_named_id(p) > 0) - check_token_ref(pdf_thread_id(p)); + check_token_ref(p); if (pdf_thread_attr(p) != null) - check_token_ref(pdf_thread_attr(p)); + check_token_ref(p); break; case pdf_save_node: case pdf_restore_node: diff --git a/source/texk/web2c/luatexdir/tex/textoken.w b/source/texk/web2c/luatexdir/tex/textoken.w index b11169a8931bd295150ba2d6cdaa19eed4a0ffd8..bf14a96148e1403026e613a916e37e6d29e84a00 100644 --- a/source/texk/web2c/luatexdir/tex/textoken.w +++ b/source/texk/web2c/luatexdir/tex/textoken.w @@ -2311,6 +2311,7 @@ static int do_variable_pdf(halfword c) else if (scan_keyword("imageresolution")) { do_variable_backend_int(c_pdf_image_resolution); } else if (scan_keyword("pkresolution")) { do_variable_backend_int(c_pdf_pk_resolution); } else if (scan_keyword("uniqueresname")) { do_variable_backend_int(c_pdf_unique_resname); } + else if (scan_keyword("majorversion")) { do_variable_backend_int(c_pdf_major_version); } else if (scan_keyword("minorversion")) { do_variable_backend_int(c_pdf_minor_version); } else if (scan_keyword("pagebox")) { do_variable_backend_int(c_pdf_pagebox); } else if (scan_keyword("inclusionerrorlevel")) { do_variable_backend_int(c_pdf_inclusion_errorlevel); }