summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-02-07 14:21:36 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-07 19:46:09 +0000
commit79365f7e3d2d62138e79e4403d4959318776c139 (patch)
treeb00196a8cdc6777ee0224653ef70bb2f2f7bb8b9 /core/fpdfapi/page
parentc222907f453e8a0e6376a86f89354eedb8285854 (diff)
downloadpdfium-79365f7e3d2d62138e79e4403d4959318776c139.tar.xz
Use enum class for PathPoint types.
This hopefully makes it less confusing what the description of a point is. Currently we have defines for the types, which is confusing because a point can only be one of the three. And it is mixed up with whether the point is closing a figure or not. Change-Id: Icd71355d69c77b3d52ca78e03bc379081ff87753 Reviewed-on: https://pdfium-review.googlesource.com/2552 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_path.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_path.h1
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp77
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.h2
4 files changed, 42 insertions, 42 deletions
diff --git a/core/fpdfapi/page/cpdf_path.cpp b/core/fpdfapi/page/cpdf_path.cpp
index 2bfda75f56..8151ae46d7 100644
--- a/core/fpdfapi/page/cpdf_path.cpp
+++ b/core/fpdfapi/page/cpdf_path.cpp
@@ -28,10 +28,6 @@ FX_PATHPOINT* CPDF_Path::GetMutablePoints() {
return m_Ref.GetPrivateCopy()->GetPoints();
}
-int CPDF_Path::GetFlag(int index) const {
- return m_Ref.GetObject()->GetFlag(index);
-}
-
FX_FLOAT CPDF_Path::GetPointX(int index) const {
return m_Ref.GetObject()->GetPointX(index);
}
diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h
index 407905e429..252be2673c 100644
--- a/core/fpdfapi/page/cpdf_path.h
+++ b/core/fpdfapi/page/cpdf_path.h
@@ -27,7 +27,6 @@ class CPDF_Path {
const FX_PATHPOINT* GetPoints() const;
FX_PATHPOINT* GetMutablePoints();
- int GetFlag(int index) const;
FX_FLOAT GetPointX(int index) const;
FX_FLOAT GetPointY(int index) const;
CFX_FloatRect GetBoundingBox() const;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 0e78612bc9..3dec01a52e 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -586,7 +586,7 @@ void CPDF_StreamContentParser::Handle_FillStrokePath() {
}
void CPDF_StreamContentParser::Handle_CloseEOFillStrokePath() {
- AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE);
+ AddPathPoint(m_PathStartX, m_PathStartY, FXPT_TYPE::LineTo, true);
AddPathObject(FXFILL_ALTERNATE, true);
}
@@ -682,9 +682,9 @@ void CPDF_StreamContentParser::Handle_BeginText() {
}
void CPDF_StreamContentParser::Handle_CurveTo_123() {
- AddPathPoint(GetNumber(5), GetNumber(4), FXPT_BEZIERTO);
- AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
- AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
+ AddPathPoint(GetNumber(5), GetNumber(4), FXPT_TYPE::BezierTo, false);
+ AddPathPoint(GetNumber(3), GetNumber(2), FXPT_TYPE::BezierTo, false);
+ AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false);
}
void CPDF_StreamContentParser::Handle_ConcatMatrix() {
@@ -887,9 +887,9 @@ void CPDF_StreamContentParser::Handle_ClosePath() {
return;
}
if (m_PathStartX != m_PathCurrentX || m_PathStartY != m_PathCurrentY) {
- AddPathPoint(m_PathStartX, m_PathStartY, FXPT_LINETO | FXPT_CLOSEFIGURE);
- } else if (m_pPathPoints[m_PathPointCount - 1].m_Flag != FXPT_MOVETO) {
- m_pPathPoints[m_PathPointCount - 1].m_Flag |= FXPT_CLOSEFIGURE;
+ AddPathPoint(m_PathStartX, m_PathStartY, FXPT_TYPE::LineTo, true);
+ } else if (m_pPathPoints[m_PathPointCount - 1].m_Type != FXPT_TYPE::MoveTo) {
+ m_pPathPoints[m_PathPointCount - 1].m_CloseFigure = true;
}
}
@@ -937,14 +937,14 @@ void CPDF_StreamContentParser::Handle_LineTo() {
if (m_ParamCount != 2)
return;
- AddPathPoint(GetNumber(1), GetNumber(0), FXPT_LINETO);
+ AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::LineTo, false);
}
void CPDF_StreamContentParser::Handle_MoveTo() {
if (m_ParamCount != 2)
return;
- AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO);
+ AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::MoveTo, false);
ParsePathObject();
}
@@ -982,11 +982,11 @@ void CPDF_StreamContentParser::AddPathRect(FX_FLOAT x,
FX_FLOAT y,
FX_FLOAT w,
FX_FLOAT h) {
- AddPathPoint(x, y, FXPT_MOVETO);
- AddPathPoint(x + w, y, FXPT_LINETO);
- AddPathPoint(x + w, y + h, FXPT_LINETO);
- AddPathPoint(x, y + h, FXPT_LINETO);
- AddPathPoint(x, y, FXPT_LINETO | FXPT_CLOSEFIGURE);
+ AddPathPoint(x, y, FXPT_TYPE::MoveTo, false);
+ AddPathPoint(x + w, y, FXPT_TYPE::LineTo, false);
+ AddPathPoint(x + w, y + h, FXPT_TYPE::LineTo, false);
+ AddPathPoint(x, y + h, FXPT_TYPE::LineTo, false);
+ AddPathPoint(x, y, FXPT_TYPE::LineTo, true);
}
void CPDF_StreamContentParser::Handle_SetRGBColor_Fill() {
@@ -1416,9 +1416,9 @@ void CPDF_StreamContentParser::Handle_MoveToNextLine() {
}
void CPDF_StreamContentParser::Handle_CurveTo_23() {
- AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_BEZIERTO);
- AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
- AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
+ AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_TYPE::BezierTo, false);
+ AddPathPoint(GetNumber(3), GetNumber(2), FXPT_TYPE::BezierTo, false);
+ AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false);
}
void CPDF_StreamContentParser::Handle_SetLineWidth() {
@@ -1434,9 +1434,9 @@ void CPDF_StreamContentParser::Handle_EOClip() {
}
void CPDF_StreamContentParser::Handle_CurveTo_13() {
- AddPathPoint(GetNumber(3), GetNumber(2), FXPT_BEZIERTO);
- AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
- AddPathPoint(GetNumber(1), GetNumber(0), FXPT_BEZIERTO);
+ AddPathPoint(GetNumber(3), GetNumber(2), FXPT_TYPE::BezierTo, false);
+ AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false);
+ AddPathPoint(GetNumber(1), GetNumber(0), FXPT_TYPE::BezierTo, false);
}
void CPDF_StreamContentParser::Handle_NextLineShowText() {
@@ -1452,14 +1452,17 @@ void CPDF_StreamContentParser::Handle_NextLineShowText_Space() {
void CPDF_StreamContentParser::Handle_Invalid() {}
-void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag) {
+void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x,
+ FX_FLOAT y,
+ FXPT_TYPE type,
+ bool close) {
m_PathCurrentX = x;
m_PathCurrentY = y;
- if (flag == FXPT_MOVETO) {
+ if (type == FXPT_TYPE::MoveTo && !close) {
m_PathStartX = x;
m_PathStartY = y;
if (m_PathPointCount &&
- m_pPathPoints[m_PathPointCount - 1].m_Flag == FXPT_MOVETO) {
+ m_pPathPoints[m_PathPointCount - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) {
m_pPathPoints[m_PathPointCount - 1].m_PointX = x;
m_pPathPoints[m_PathPointCount - 1].m_PointY = y;
return;
@@ -1479,7 +1482,8 @@ void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag) {
m_pPathPoints = pNewPoints;
m_PathAllocSize = newsize;
}
- m_pPathPoints[m_PathPointCount - 1].m_Flag = flag;
+ m_pPathPoints[m_PathPointCount - 1].m_Type = type;
+ m_pPathPoints[m_PathPointCount - 1].m_CloseFigure = close;
m_pPathPoints[m_PathPointCount - 1].m_PointX = x;
m_pPathPoints[m_PathPointCount - 1].m_PointY = y;
}
@@ -1498,7 +1502,7 @@ void CPDF_StreamContentParser::AddPathObject(int FillType, bool bStroke) {
return;
}
if (PathPointCount &&
- m_pPathPoints[PathPointCount - 1].m_Flag == FXPT_MOVETO) {
+ m_pPathPoints[PathPointCount - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) {
PathPointCount--;
}
CPDF_Path Path;
@@ -1576,29 +1580,30 @@ void CPDF_StreamContentParser::ParsePathObject() {
if (len == 1) {
switch (strc[0]) {
case kPathOperatorSubpath:
- AddPathPoint(params[0], params[1], FXPT_MOVETO);
+ AddPathPoint(params[0], params[1], FXPT_TYPE::MoveTo, false);
nParams = 0;
break;
case kPathOperatorLine:
- AddPathPoint(params[0], params[1], FXPT_LINETO);
+ AddPathPoint(params[0], params[1], FXPT_TYPE::LineTo, false);
nParams = 0;
break;
case kPathOperatorCubicBezier1:
- AddPathPoint(params[0], params[1], FXPT_BEZIERTO);
- AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
- AddPathPoint(params[4], params[5], FXPT_BEZIERTO);
+ AddPathPoint(params[0], params[1], FXPT_TYPE::BezierTo, false);
+ AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false);
+ AddPathPoint(params[4], params[5], FXPT_TYPE::BezierTo, false);
nParams = 0;
break;
case kPathOperatorCubicBezier2:
- AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_BEZIERTO);
- AddPathPoint(params[0], params[1], FXPT_BEZIERTO);
- AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
+ AddPathPoint(m_PathCurrentX, m_PathCurrentY, FXPT_TYPE::BezierTo,
+ false);
+ AddPathPoint(params[0], params[1], FXPT_TYPE::BezierTo, false);
+ AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false);
nParams = 0;
break;
case kPathOperatorCubicBezier3:
- AddPathPoint(params[0], params[1], FXPT_BEZIERTO);
- AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
- AddPathPoint(params[2], params[3], FXPT_BEZIERTO);
+ AddPathPoint(params[0], params[1], FXPT_TYPE::BezierTo, false);
+ AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false);
+ AddPathPoint(params[2], params[3], FXPT_TYPE::BezierTo, false);
nParams = 0;
break;
case kPathOperatorClosePath:
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index e23ae8ea99..ca7ea7c106 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -96,7 +96,7 @@ class CPDF_StreamContentParser {
void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y);
void OnChangeTextMatrix();
void ParsePathObject();
- void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag);
+ void AddPathPoint(FX_FLOAT x, FX_FLOAT y, FXPT_TYPE type, bool close);
void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h);
void AddPathObject(int FillType, bool bStroke);
CPDF_ImageObject* AddImage(std::unique_ptr<CPDF_Stream> pStream);