summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-03-16 22:24:11 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-17 15:50:57 +0000
commit78616574cedcb52cce8a25bd684bf9638a87de7a (patch)
tree4a9dc03d7d9243893947e26232db152a18777304 /core
parentadee4859cdb4a591cdc202d0a4452d17a827fc90 (diff)
downloadpdfium-78616574cedcb52cce8a25bd684bf9638a87de7a.tar.xz
Coalesce redundant path points.
There exists PDFs with many redundant path points, and keeping track of them all uses a lot of memory. BUG=chromium:679353 Change-Id: I514610cbba181658b6396e30f5bf58a3661359f5 Reviewed-on: https://pdfium-review.googlesource.com/3110 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 798b9d4f4e..d8b176b288 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -1440,6 +1440,15 @@ void CPDF_StreamContentParser::AddPathPoint(float x,
float y,
FXPT_TYPE type,
bool close) {
+ // If the path point is the same move as the previous one and neither of them
+ // closes the path, then just skip it.
+ if (!close && type == FXPT_TYPE::MoveTo && m_PathPointCount &&
+ !m_pPathPoints[m_PathPointCount - 1].m_CloseFigure &&
+ m_pPathPoints[m_PathPointCount - 1].m_Type == type &&
+ m_PathCurrentX == x && m_PathCurrentY == y) {
+ return;
+ }
+
m_PathCurrentX = x;
m_PathCurrentY = y;
if (type == FXPT_TYPE::MoveTo && !close) {