[poppler] CMakeLists.txt poppler/poppler-config.h.cmake splash/SplashXPathScanner.cc splash/SplashXPathScanner.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jul 21 22:10:57 UTC 2019
CMakeLists.txt | 13 +++++++++++++
poppler/poppler-config.h.cmake | 6 ++++++
splash/SplashXPathScanner.cc | 2 ++
splash/SplashXPathScanner.h | 14 ++++++++++++++
4 files changed, 35 insertions(+)
New commits:
commit 355fd8d58ca0209284fe568b3add28f207e995c1
Author: Stefan Brüns <stefan.bruens at rwth-aachen.de>
Date: Mon Aug 27 02:29:20 2018 +0200
SplashXPathScanner: Optionally use small_vector from boost
Currently, each row in the intersections vector is allocated separately,
when the first intersection is added.
To avoid these allocations for common simple polygons,
boost::container::small_vector<4, T> is used, which stores up to
4 intersections inline. small_vector is a header-only class.
For the documents from #57 (fdo#96728) and #24 (fdo#78728), the
runtime/memory is significantly reduced (according to /usr/bin/time -v):
(1) $> pdftoppm -r 18 -aa no runsforever-poppler.pdf
(2) $> pdftoppm surf-types.pdf
Before/After
runsforever-poppler | surf-types
User time (seconds): 2348.08 / 1773.53 | 7.76 / 5.02
Maximum resident set size (kbytes): 46288 / 45896 | 14076 / 13748
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7001544c..edcc5a23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -286,6 +286,14 @@ if(LCMS2_FOUND)
include_directories(SYSTEM ${LCMS2_INCLUDE_DIR})
endif()
+if(ENABLE_SPLASH)
+ find_package(Boost 1.58.0)
+ if(Boost_FOUND)
+ include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
+ set(USE_BOOST_HEADERS ON)
+ endif()
+endif()
+
# Recent versions of poppler-data install a .pc file.
# Use it to determine the encoding data path, if available.
# Default to the same prefix otherwise.
@@ -730,6 +738,7 @@ show_end_message_yesno("use nss3" ENABLE_NSS3)
show_end_message_yesno("use curl" ENABLE_LIBCURL)
show_end_message_yesno("use libopenjpeg2" WITH_OPENJPEG)
show_end_message_yesno("use lcms2" USE_CMS)
+show_end_message_yesno("use boost" Boost_FOUND)
show_end_message_yesno("command line utils" ENABLE_UTILS)
show_end_message_yesno("fuzz target" ENABLE_FUZZER)
show_end_message("test data dir" ${TESTDATADIR})
@@ -762,6 +771,10 @@ if(NOT HAVE_JPX_DECODER)
message("Warning: You're not compiling any JPX decoder. Some files will fail to display properly.")
endif()
+if(ENABLE_SPLASH AND NOT Boost_FOUND)
+ message("Warning: Use of boost is recommended for better performance.")
+endif()
+
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${POPPLER_VERSION})
add_custom_target(dist
COMMAND
diff --git a/poppler/poppler-config.h.cmake b/poppler/poppler-config.h.cmake
index f0a5a1a0..746d8630 100644
--- a/poppler/poppler-config.h.cmake
+++ b/poppler/poppler-config.h.cmake
@@ -18,6 +18,7 @@
// Copyright (C) 2016 Tor Lillqvist <tml at collabora.com>
// Copyright (C) 2017 Adrian Johnson <ajohnson at redneon.com>
// Copyright (C) 2018 Adam Reichold <adam.reichold at t-online.de>
+// Copyright (C) 2018 Stefan Brüns <stefan.bruens at rwth-aachen.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
@@ -115,6 +116,11 @@
#cmakedefine USE_CMS 1
#endif
+/* Use header-only classes from Boost in the Splash backend */
+#ifndef USE_BOOST_HEADERS
+#cmakedefine USE_BOOST_HEADERS 1
+#endif
+
//------------------------------------------------------------------------
// version
//------------------------------------------------------------------------
diff --git a/splash/SplashXPathScanner.cc b/splash/SplashXPathScanner.cc
index e8abe94c..042a6ef6 100644
--- a/splash/SplashXPathScanner.cc
+++ b/splash/SplashXPathScanner.cc
@@ -344,9 +344,11 @@ bool SplashXPathScanner::addIntersection(double segYMin, double segYMax,
}
auto& line = allIntersections[y - yMin];
+#ifndef USE_BOOST_HEADERS
if (line.empty()) {
line.reserve(4);
}
+#endif
line.push_back(intersect);
return true;
diff --git a/splash/SplashXPathScanner.h b/splash/SplashXPathScanner.h
index 1ac8ce84..88b9d8c9 100644
--- a/splash/SplashXPathScanner.h
+++ b/splash/SplashXPathScanner.h
@@ -25,6 +25,12 @@
#include "SplashTypes.h"
+#include <poppler-config.h>
+
+#ifdef USE_BOOST_HEADERS
+#include <boost/container/small_vector.hpp>
+#endif
+
#include <vector>
class SplashXPath;
@@ -94,7 +100,11 @@ private:
int xMin, yMin, xMax, yMax;
bool partialClip;
+#ifdef USE_BOOST_HEADERS
+ typedef boost::container::small_vector<SplashIntersect, 4> IntersectionLine;
+#else
typedef std::vector<SplashIntersect> IntersectionLine;
+#endif
std::vector<IntersectionLine> allIntersections;
friend class SplashXPathScanIterator;
@@ -109,7 +119,11 @@ public:
bool getNextSpan(int *x0, int *x1);
private:
+#ifdef USE_BOOST_HEADERS
+ typedef boost::container::small_vector<SplashIntersect, 4> IntersectionLine;
+#else
typedef std::vector<SplashIntersect> IntersectionLine;
+#endif
const IntersectionLine &line;
size_t interIdx; // current index into <line>
More information about the poppler
mailing list