summaryrefslogtreecommitdiff
path: root/core/fxge/win32
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-02-22 19:56:15 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-23 01:17:40 +0000
commitb147e07ee36be10ca0796a6566be107077c21a03 (patch)
tree637b1b206000a88fb3e198f648e86a9ee5178f1b /core/fxge/win32
parente3f237740fd8bea50b4a6f37f56455dfa0328546 (diff)
downloadpdfium-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/fxge/win32')
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp22
-rw-r--r--core/fxge/win32/fx_win32_device.cpp57
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp18
3 files changed, 45 insertions, 52 deletions
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index a0e675e23c..74fae088d9 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -116,7 +116,7 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
for (size_t i = 0; i < size; i++) {
FXPT_TYPE type = pPathData->GetType(i);
bool closing = pPathData->IsClosingFigure(i);
- CFX_PointF pos(pPathData->GetPointX(i), pPathData->GetPointY(i));
+ CFX_PointF pos = pPathData->GetPoint(i);
if (pObject2Device)
pos = pObject2Device->Transform(pos);
@@ -131,10 +131,8 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
buf << "h ";
break;
case FXPT_TYPE::BezierTo: {
- CFX_PointF pos1(pPathData->GetPointX(i + 1),
- pPathData->GetPointY(i + 1));
- CFX_PointF pos2(pPathData->GetPointX(i + 2),
- pPathData->GetPointY(i + 2));
+ CFX_PointF pos1 = pPathData->GetPoint(i + 1);
+ CFX_PointF pos2 = pPathData->GetPoint(i + 2);
if (pObject2Device) {
pos1 = pObject2Device->Transform(pos1);
pos2 = pObject2Device->Transform(pos2);
@@ -604,21 +602,21 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache,
buf << "/X" << *ps_fontnum << " Ff/CharProcs get begin/" << glyphindex
<< "{n ";
for (size_t p = 0; p < TransformedPath.GetPoints().size(); p++) {
- FX_FLOAT x = TransformedPath.GetPointX(p), y = TransformedPath.GetPointY(p);
+ CFX_PointF point = TransformedPath.GetPoint(p);
switch (TransformedPath.GetType(p)) {
case FXPT_TYPE::MoveTo: {
- buf << x << " " << y << " m\n";
+ buf << point.x << " " << point.y << " m\n";
break;
}
case FXPT_TYPE::LineTo: {
- buf << x << " " << y << " l\n";
+ buf << point.x << " " << point.y << " l\n";
break;
}
case FXPT_TYPE::BezierTo: {
- buf << x << " " << y << " " << TransformedPath.GetPointX(p + 1) << " "
- << TransformedPath.GetPointY(p + 1) << " "
- << TransformedPath.GetPointX(p + 2) << " "
- << TransformedPath.GetPointY(p + 2) << " c\n";
+ CFX_PointF point1 = TransformedPath.GetPoint(p + 1);
+ CFX_PointF point2 = TransformedPath.GetPoint(p + 2);
+ buf << point.x << " " << point.y << " " << point1.x << " " << point1.y
+ << " " << point2.x << " " << point2.y << " c\n";
p += 2;
break;
}
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index b5ce7345c6..92e9b41e06 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -169,45 +169,42 @@ void SetPathToDC(HDC hDC,
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;
+ CFX_PointF pos = pPoints[i].m_Point;
if (pMatrix)
- pMatrix->TransformPoint(posx, posy);
+ pos = pMatrix->Transform(pos);
- int screen_x = FXSYS_round(posx), screen_y = FXSYS_round(posy);
+ CFX_Point screen(FXSYS_round(pos.x), FXSYS_round(pos.y));
FXPT_TYPE point_type = pPoints[i].m_Type;
if (point_type == FXPT_TYPE::MoveTo) {
- MoveToEx(hDC, screen_x, screen_y, nullptr);
+ MoveToEx(hDC, screen.x, screen.y, nullptr);
} else if (point_type == FXPT_TYPE::LineTo) {
- if (pPoints[i].m_PointY == pPoints[i - 1].m_PointY &&
- pPoints[i].m_PointX == pPoints[i - 1].m_PointX) {
- screen_x++;
- }
- LineTo(hDC, screen_x, screen_y);
+ if (pPoints[i].m_Point == pPoints[i - 1].m_Point)
+ screen.x++;
+
+ LineTo(hDC, screen.x, screen.y);
} else if (point_type == FXPT_TYPE::BezierTo) {
POINT lppt[3];
- lppt[0].x = screen_x;
- lppt[0].y = screen_y;
- posx = pPoints[i + 1].m_PointX;
- posy = pPoints[i + 1].m_PointY;
+ lppt[0].x = screen.x;
+ lppt[0].y = screen.y;
+
+ pos = pPoints[i + 1].m_Point;
if (pMatrix)
- pMatrix->TransformPoint(posx, posy);
+ pos = pMatrix->Transform(pos);
- lppt[1].x = FXSYS_round(posx);
- lppt[1].y = FXSYS_round(posy);
- posx = pPoints[i + 2].m_PointX;
- posy = pPoints[i + 2].m_PointY;
+ lppt[1].x = FXSYS_round(pos.x);
+ lppt[1].y = FXSYS_round(pos.y);
+
+ pos = pPoints[i + 2].m_Point;
if (pMatrix)
- pMatrix->TransformPoint(posx, posy);
+ pos = pMatrix->Transform(pos);
- lppt[2].x = FXSYS_round(posx);
- lppt[2].y = FXSYS_round(posy);
+ lppt[2].x = FXSYS_round(pos.x);
+ lppt[2].y = FXSYS_round(pos.y);
PolyBezierTo(hDC, lppt, 3);
i += 2;
}
- if (pPoints[i].m_CloseFigure) {
+ if (pPoints[i].m_CloseFigure)
CloseFigure(hDC);
- }
}
EndPath(hDC);
}
@@ -1047,15 +1044,13 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
}
if (pPathData->GetPoints().size() == 2 && pGraphState &&
pGraphState->m_DashCount) {
- FX_FLOAT x1 = pPathData->GetPointX(0);
- FX_FLOAT y1 = pPathData->GetPointY(0);
- FX_FLOAT x2 = pPathData->GetPointX(1);
- FX_FLOAT y2 = pPathData->GetPointY(1);
+ CFX_PointF pos1 = pPathData->GetPoint(0);
+ CFX_PointF pos2 = pPathData->GetPoint(1);
if (pMatrix) {
- pMatrix->TransformPoint(x1, y1);
- pMatrix->TransformPoint(x2, y2);
+ pos1 = pMatrix->Transform(pos1);
+ pos2 = pMatrix->Transform(pos2);
}
- DrawLine(x1, y1, x2, y2);
+ DrawLine(pos1.x, pos1.y, pos2.x, pos2.y);
} else {
SetPathToDC(m_hDC, pPathData, pMatrix);
if (pGraphState && stroke_alpha) {
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index c766ac8f3b..54711ceef5 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -1129,20 +1129,20 @@ bool CGdiplusExt::DrawPath(HDC hDC,
bool bSmooth = false;
int startpoint = 0;
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;
- FX_FLOAT y = pPoints[i].m_PointY;
+ points[i].X = pPoints[i].m_Point.x;
+ points[i].Y = pPoints[i].m_Point.y;
+
+ CFX_PointF pos = pPoints[i].m_Point;
if (pObject2Device)
- pObject2Device->TransformPoint(x, y);
+ pos = pObject2Device->Transform(pos);
- if (x > 50000 * 1.0f)
+ if (pos.x > 50000 * 1.0f)
points[i].X = 50000 * 1.0f;
- if (x < -50000 * 1.0f)
+ if (pos.x < -50000 * 1.0f)
points[i].X = -50000 * 1.0f;
- if (y > 50000 * 1.0f)
+ if (pos.y > 50000 * 1.0f)
points[i].Y = 50000 * 1.0f;
- if (y < -50000 * 1.0f)
+ if (pos.y < -50000 * 1.0f)
points[i].Y = -50000 * 1.0f;
FXPT_TYPE point_type = pPoints[i].m_Type;