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 /core/fxge/win32 | |
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 'core/fxge/win32')
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 17 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 17 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_gdipext.cpp | 27 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_print.cpp | 7 |
4 files changed, 35 insertions, 33 deletions
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 7fc47b9a46..d5f1f4d91c 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -109,10 +109,11 @@ void CFX_PSRenderer::RestoreState(bool bKeepSaved) { void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device) { - int nPoints = pPathData->GetPointCount(); CFX_ByteTextBuf buf; - buf.EstimateSize(nPoints * 10); - for (int i = 0; i < nPoints; i++) { + size_t size = pPathData->GetPoints().size(); + buf.EstimateSize(size * 10); + + for (size_t i = 0; i < size; i++) { FXPT_TYPE type = pPathData->GetType(i); bool closing = pPathData->IsClosingFigure(i); FX_FLOAT x = pPathData->GetPointX(i); @@ -592,17 +593,17 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache, matrix.Concat(CFX_Matrix(1.0f, 0, 0, 1.0f, 0, 0)); const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath( pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); - if (!pPathData) { + if (!pPathData) return; - } + CFX_PathData TransformedPath(*pPathData); - if (charpos.m_bGlyphAdjust) { + if (charpos.m_bGlyphAdjust) TransformedPath.Transform(&matrix); - } + CFX_ByteTextBuf buf; buf << "/X" << *ps_fontnum << " Ff/CharProcs get begin/" << glyphindex << "{n "; - for (int p = 0; p < TransformedPath.GetPointCount(); p++) { + for (size_t p = 0; p < TransformedPath.GetPoints().size(); p++) { FX_FLOAT x = TransformedPath.GetPointX(p), y = TransformedPath.GetPointY(p); switch (TransformedPath.GetType(p)) { case FXPT_TYPE::MoveTo: { diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index add0f0e3d3..b5ce7345c6 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -166,10 +166,11 @@ void SetPathToDC(HDC hDC, const CFX_PathData* pPathData, const CFX_Matrix* pMatrix) { BeginPath(hDC); - int nPoints = pPathData->GetPointCount(); - FX_PATHPOINT* pPoints = pPathData->GetPoints(); - for (int i = 0; i < nPoints; i++) { - FX_FLOAT posx = pPoints[i].m_PointX, posy = pPoints[i].m_PointY; + + const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints(); + for (size_t i = 0; i < pPoints.size(); i++) { + FX_FLOAT posx = pPoints[i].m_PointX; + FX_FLOAT posy = pPoints[i].m_PointY; if (pMatrix) pMatrix->TransformPoint(posx, posy); @@ -1019,8 +1020,8 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, (pGraphState && pGraphState->m_DashCount))) { if (!((!pMatrix || !pMatrix->WillScale()) && pGraphState && pGraphState->m_LineWidth == 1.f && - (pPathData->GetPointCount() == 5 || - pPathData->GetPointCount() == 4) && + (pPathData->GetPoints().size() == 5 || + pPathData->GetPoints().size() == 4) && pPathData->IsRect())) { if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, pGraphState, fill_color, @@ -1044,7 +1045,7 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, hBrush = CreateBrush(fill_color); hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); } - if (pPathData->GetPointCount() == 2 && pGraphState && + if (pPathData->GetPoints().size() == 2 && pGraphState && pGraphState->m_DashCount) { FX_FLOAT x1 = pPathData->GetPointX(0); FX_FLOAT y1 = pPathData->GetPointY(0); @@ -1108,7 +1109,7 @@ bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, bool CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, const CFX_Matrix* pMatrix, int fill_mode) { - if (pPathData->GetPointCount() == 5) { + if (pPathData->GetPoints().size() == 5) { CFX_FloatRect rectf; if (pPathData->IsRect(pMatrix, &rectf)) { FX_RECT rect = rectf.GetOuterRect(); diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index c703e3e300..c766ac8f3b 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -1104,11 +1104,10 @@ bool CGdiplusExt::DrawPath(HDC hDC, uint32_t fill_argb, uint32_t stroke_argb, int fill_mode) { - int nPoints = pPathData->GetPointCount(); - if (nPoints == 0) { + auto& pPoints = pPathData->GetPoints(); + if (pPoints.empty()) return true; - } - FX_PATHPOINT* pPoints = pPathData->GetPoints(); + GpGraphics* pGraphics = nullptr; CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; @@ -1122,14 +1121,14 @@ bool CGdiplusExt::DrawPath(HDC hDC, pObject2Device->e, pObject2Device->f, &pMatrix); CallFunc(GdipSetWorldTransform)(pGraphics, pMatrix); } - PointF* points = FX_Alloc(PointF, nPoints); - BYTE* types = FX_Alloc(BYTE, nPoints); + PointF* points = FX_Alloc(PointF, pPoints.size()); + BYTE* types = FX_Alloc(BYTE, pPoints.size()); int nSubPathes = 0; bool bSubClose = false; int pos_subclose = 0; bool bSmooth = false; int startpoint = 0; - for (int i = 0; i < nPoints; i++) { + for (size_t i = 0; i < pPoints.size(); i++) { points[i].X = pPoints[i].m_PointX; points[i].Y = pPoints[i].m_PointY; FX_FLOAT x = pPoints[i].m_PointX; @@ -1155,7 +1154,7 @@ bool CGdiplusExt::DrawPath(HDC hDC, } else if (point_type == FXPT_TYPE::LineTo) { types[i] = PathPointTypeLine; if (pPoints[i - 1].IsTypeAndOpen(FXPT_TYPE::MoveTo) && - (i == nPoints - 1 || + (i == pPoints.size() - 1 || pPoints[i + 1].IsTypeAndOpen(FXPT_TYPE::MoveTo)) && points[i].Y == points[i - 1].Y && points[i].X == points[i - 1].X) { points[i].X += 0.01f; @@ -1195,7 +1194,7 @@ bool CGdiplusExt::DrawPath(HDC hDC, } } int new_fill_mode = fill_mode & 3; - if (nPoints == 4 && !pGraphState) { + if (pPoints.size() == 4 && !pGraphState) { int v1, v2; if (IsSmallTriangle(points, pObject2Device, v1, v2)) { GpPen* pPen = nullptr; @@ -1208,12 +1207,12 @@ bool CGdiplusExt::DrawPath(HDC hDC, } } GpPath* pGpPath = nullptr; - CallFunc(GdipCreatePath2)(points, types, nPoints, + CallFunc(GdipCreatePath2)(points, types, pPoints.size(), GdiFillType2Gdip(new_fill_mode), &pGpPath); if (!pGpPath) { - if (pMatrix) { + if (pMatrix) CallFunc(GdipDeleteMatrix)(pMatrix); - } + FX_Free(points); FX_Free(types); CallFunc(GdipDeleteGraphics)(pGraphics); @@ -1232,8 +1231,8 @@ bool CGdiplusExt::DrawPath(HDC hDC, CallFunc(GdipDrawPath)(pGraphics, pPen, pGpPath); } else { int iStart = 0; - for (int i = 0; i < nPoints; i++) { - if (i == nPoints - 1 || types[i + 1] == PathPointTypeStart) { + for (size_t i = 0; i < pPoints.size(); i++) { + if (i == pPoints.size() - 1 || types[i + 1] == PathPointTypeStart) { GpPath* pSubPath; CallFunc(GdipCreatePath2)(points + iStart, types + iStart, i - iStart + 1, diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index a2ea82a94e..3b0c6969f9 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -346,12 +346,13 @@ CPSPrinterDriver::CPSPrinterDriver(HDC hDC, int pslevel, bool bCmykOutput) ret = ::GetRegionData(hRgn, ret, pData); if (ret) { CFX_PathData path; - path.AllocPointCount(pData->rdh.nCount * 5); for (uint32_t i = 0; i < pData->rdh.nCount; i++) { RECT* pRect = reinterpret_cast<RECT*>(pData->Buffer + pData->rdh.nRgnSize * i); - path.AppendRect((FX_FLOAT)pRect->left, (FX_FLOAT)pRect->bottom, - (FX_FLOAT)pRect->right, (FX_FLOAT)pRect->top); + path.AppendRect(static_cast<FX_FLOAT>(pRect->left), + static_cast<FX_FLOAT>(pRect->bottom), + static_cast<FX_FLOAT>(pRect->right), + static_cast<FX_FLOAT>(pRect->top)); } m_PSRenderer.SetClip_PathFill(&path, nullptr, FXFILL_WINDING); } |