diff options
author | dan sinclair <dsinclair@chromium.org> | 2017-02-22 19:56:15 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-23 01:17:40 +0000 |
commit | b147e07ee36be10ca0796a6566be107077c21a03 (patch) | |
tree | 637b1b206000a88fb3e198f648e86a9ee5178f1b /core/fpdfapi/edit | |
parent | e3f237740fd8bea50b4a6f37f56455dfa0328546 (diff) | |
download | pdfium-b147e07ee36be10ca0796a6566be107077c21a03.tar.xz |
Convert point x,y into CFX_PointF
This Cl converts the PointX,PointY pairs into a CFX_PointF.
Change-Id: I46897832077c317a5bffb4e568550705decbc40c
Reviewed-on: https://pdfium-review.googlesource.com/2821
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/edit')
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp | 14 | ||||
-rw-r--r-- | core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp | 44 |
2 files changed, 34 insertions, 24 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index b5fe4c0f35..35595b3e1f 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -150,14 +150,14 @@ void CPDF_PageContentGenerator::ProcessPath(CFX_ByteTextBuf* buf, ProcessGraphics(buf, pPathObj); auto& pPoints = pPathObj->m_Path.GetPoints(); if (pPathObj->m_Path.IsRect()) { - *buf << pPoints[0].m_PointX << " " << pPoints[0].m_PointY << " " - << (pPoints[2].m_PointX - pPoints[0].m_PointX) << " " - << (pPoints[2].m_PointY - pPoints[0].m_PointY) << " re"; + CFX_PointF diff = pPoints[2].m_Point - pPoints[0].m_Point; + *buf << pPoints[0].m_Point.x << " " << pPoints[0].m_Point.y << " " << diff.x + << " " << diff.y << " re"; } else { for (size_t i = 0; i < pPoints.size(); i++) { if (i > 0) *buf << " "; - *buf << pPoints[i].m_PointX << " " << pPoints[i].m_PointY; + *buf << pPoints[i].m_Point.x << " " << pPoints[i].m_Point.y; FXPT_TYPE pointType = pPoints[i].m_Type; if (pointType == FXPT_TYPE::MoveTo) { *buf << " m"; @@ -172,9 +172,9 @@ void CPDF_PageContentGenerator::ProcessPath(CFX_ByteTextBuf* buf, *buf << " h"; break; } - *buf << " " << pPoints[i + 1].m_PointX << " " << pPoints[i + 1].m_PointY - << " " << pPoints[i + 2].m_PointX << " " << pPoints[i + 2].m_PointY - << " c"; + *buf << " " << pPoints[i + 1].m_Point.x << " " + << pPoints[i + 1].m_Point.y << " " << pPoints[i + 2].m_Point.x + << " " << pPoints[i + 2].m_Point.y << " c"; i += 2; } if (pPoints[i].m_CloseFigure) diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index 42e6e2d843..d8813ba30f 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -52,10 +52,11 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { EXPECT_EQ("q 10 5 3 25 re B* Q\n", buf.MakeString()); pPathObj = pdfium::MakeUnique<CPDF_PathObject>(); - pPathObj->m_Path.AppendPoint(0, 0, FXPT_TYPE::MoveTo, false); - pPathObj->m_Path.AppendPoint(5.2f, 0, FXPT_TYPE::LineTo, false); - pPathObj->m_Path.AppendPoint(5.2f, 3.78f, FXPT_TYPE::LineTo, false); - pPathObj->m_Path.AppendPoint(0, 3.78f, FXPT_TYPE::LineTo, true); + pPathObj->m_Path.AppendPoint(CFX_PointF(0, 0), FXPT_TYPE::MoveTo, false); + pPathObj->m_Path.AppendPoint(CFX_PointF(5.2f, 0), FXPT_TYPE::LineTo, false); + pPathObj->m_Path.AppendPoint(CFX_PointF(5.2f, 3.78f), FXPT_TYPE::LineTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(0, 3.78f), FXPT_TYPE::LineTo, true); pPathObj->m_FillType = 0; pPathObj->m_bStroke = false; buf.Clear(); @@ -66,16 +67,25 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessRect) { TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) { auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(); - pPathObj->m_Path.AppendPoint(3.102f, 4.67f, FXPT_TYPE::MoveTo, false); - pPathObj->m_Path.AppendPoint(5.45f, 0.29f, FXPT_TYPE::LineTo, false); - pPathObj->m_Path.AppendPoint(4.24f, 3.15f, FXPT_TYPE::BezierTo, false); - pPathObj->m_Path.AppendPoint(4.65f, 2.98f, FXPT_TYPE::BezierTo, false); - pPathObj->m_Path.AppendPoint(3.456f, 0.24f, FXPT_TYPE::BezierTo, false); - pPathObj->m_Path.AppendPoint(10.6f, 11.15f, FXPT_TYPE::LineTo, false); - pPathObj->m_Path.AppendPoint(11, 12.5f, FXPT_TYPE::LineTo, false); - pPathObj->m_Path.AppendPoint(11.46f, 12.67f, FXPT_TYPE::BezierTo, false); - pPathObj->m_Path.AppendPoint(11.84f, 12.96f, FXPT_TYPE::BezierTo, false); - pPathObj->m_Path.AppendPoint(12, 13.64f, FXPT_TYPE::BezierTo, true); + pPathObj->m_Path.AppendPoint(CFX_PointF(3.102f, 4.67f), FXPT_TYPE::MoveTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(5.45f, 0.29f), FXPT_TYPE::LineTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(4.24f, 3.15f), FXPT_TYPE::BezierTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(4.65f, 2.98f), FXPT_TYPE::BezierTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(3.456f, 0.24f), FXPT_TYPE::BezierTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(10.6f, 11.15f), FXPT_TYPE::LineTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(11, 12.5f), FXPT_TYPE::LineTo, false); + pPathObj->m_Path.AppendPoint(CFX_PointF(11.46f, 12.67f), FXPT_TYPE::BezierTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(11.84f, 12.96f), FXPT_TYPE::BezierTo, + false); + pPathObj->m_Path.AppendPoint(CFX_PointF(12, 13.64f), FXPT_TYPE::BezierTo, + true); pPathObj->m_FillType = FXFILL_WINDING; pPathObj->m_bStroke = false; @@ -91,9 +101,9 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessPath) { TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { auto pPathObj = pdfium::MakeUnique<CPDF_PathObject>(); - pPathObj->m_Path.AppendPoint(1, 2, FXPT_TYPE::MoveTo, false); - pPathObj->m_Path.AppendPoint(3, 4, FXPT_TYPE::LineTo, false); - pPathObj->m_Path.AppendPoint(5, 6, FXPT_TYPE::LineTo, true); + pPathObj->m_Path.AppendPoint(CFX_PointF(1, 2), FXPT_TYPE::MoveTo, false); + pPathObj->m_Path.AppendPoint(CFX_PointF(3, 4), FXPT_TYPE::LineTo, false); + pPathObj->m_Path.AppendPoint(CFX_PointF(5, 6), FXPT_TYPE::LineTo, true); pPathObj->m_FillType = FXFILL_WINDING; pPathObj->m_bStroke = true; |