diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-02-15 11:07:32 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-15 17:47:57 +0000 |
commit | e4602321f3175fa5addb6761d0e94f5c2fc93d0c (patch) | |
tree | 6671774659645fad6d9ce55a5910b4665a25094f /fpdfsdk/pdfwindow/PWL_Utils.cpp | |
parent | eb55885e9a9eec670ed98cbd12dc96d63e6a6623 (diff) | |
download | pdfium-e4602321f3175fa5addb6761d0e94f5c2fc93d0c.tar.xz |
Cleanup CFX_PathData.
This CL replaces the array of path points with a vector. Cleaning up the usage
as required.
Change-Id: Ifa386a2c847005fef68af748ebe99c4e08961238
Reviewed-on: https://pdfium-review.googlesource.com/2710
Reviewed-by: Nicolás Peña <npm@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow/PWL_Utils.cpp')
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Utils.cpp | 114 |
1 files changed, 51 insertions, 63 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_Utils.cpp b/fpdfsdk/pdfwindow/PWL_Utils.cpp index 8b2813d3e6..9f5e31f6fd 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.cpp +++ b/fpdfsdk/pdfwindow/PWL_Utils.cpp @@ -48,21 +48,19 @@ CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, int32_t nCount) { - path.SetPointCount(nCount); - for (int32_t i = 0; i < nCount; i++) { switch (pPathData[i].type) { case PWLPT_MOVETO: - path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_TYPE::MoveTo, false); + path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y, + FXPT_TYPE::MoveTo, false); break; case PWLPT_LINETO: - path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_TYPE::LineTo, false); + path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y, + FXPT_TYPE::LineTo, false); break; case PWLPT_BEZIERTO: - path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, - FXPT_TYPE::BezierTo, false); + path.AppendPoint(pPathData[i].point.x, pPathData[i].point.y, + FXPT_TYPE::BezierTo, false); break; default: break; @@ -1234,11 +1232,9 @@ void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, int32_t nCount, const FX_COLORREF& color) { CFX_PathData path; - path.SetPointCount(nCount); - - path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false); + path.AppendPoint(pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false); for (int32_t i = 1; i < nCount; i++) - path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false); + path.AppendPoint(pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false); pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE); } @@ -1265,9 +1261,8 @@ void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, const FX_COLORREF& color, FX_FLOAT fWidth) { CFX_PathData path; - path.SetPointCount(2); - path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_TYPE::LineTo, false); + path.AppendPoint(ptMoveTo.x, ptMoveTo.y, FXPT_TYPE::MoveTo, false); + path.AppendPoint(ptLineTo.x, ptLineTo.y, FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; @@ -1350,18 +1345,16 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, } case BorderStyle::DASH: { CFX_PathData path; - - path.SetPointCount(5); - path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_TYPE::MoveTo, false); - path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, - FXPT_TYPE::LineTo, false); - path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, - FXPT_TYPE::LineTo, false); - path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_TYPE::LineTo, false); - path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, - FXPT_TYPE::LineTo, false); + path.AppendPoint(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, + FXPT_TYPE::MoveTo, false); + path.AppendPoint(fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, + FXPT_TYPE::LineTo, false); + path.AppendPoint(fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, + FXPT_TYPE::LineTo, false); + path.AppendPoint(fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, + FXPT_TYPE::LineTo, false); + path.AppendPoint(fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, + FXPT_TYPE::LineTo, false); CFX_GraphStateData gsd; gsd.SetDashCount(2); @@ -1382,43 +1375,40 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CFX_PathData pathLT; - pathLT.SetPointCount(7); - pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::MoveTo, false); - pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::MoveTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathLT.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::LineTo, false); pDevice->DrawPath(&pathLT, pUser2Device, &gsd, PWLColorToFXColor(crLeftTop, nTransparancy), 0, FXFILL_ALTERNATE); CFX_PathData pathRB; - - pathRB.SetPointCount(7); - pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::MoveTo, false); - pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, - FXPT_TYPE::LineTo, false); - pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, - FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::MoveTo, false); + pathRB.AppendPoint(fRight - fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fLeft + fHalfWidth, fBottom + fHalfWidth, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, + FXPT_TYPE::LineTo, false); + pathRB.AppendPoint(fRight - fHalfWidth, fTop - fHalfWidth, + FXPT_TYPE::LineTo, false); pDevice->DrawPath(&pathRB, pUser2Device, &gsd, PWLColorToFXColor(crRightBottom, nTransparancy), 0, @@ -1437,11 +1427,9 @@ void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, } case BorderStyle::UNDERLINE: { CFX_PathData path; - - path.SetPointCount(2); - path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_TYPE::MoveTo, false); - path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_TYPE::LineTo, - false); + path.AppendPoint(fLeft, fBottom + fWidth / 2, FXPT_TYPE::MoveTo, false); + path.AppendPoint(fRight, fBottom + fWidth / 2, FXPT_TYPE::LineTo, + false); CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; |