summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-21 12:56:24 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-21 19:05:18 +0000
commit1f403cee9478021862c7cc4e516907bd51e8f0f6 (patch)
tree57829fa3b036ee9ddd57a8ad5b3541fe4e96fdb8 /core
parent04557b8a7c2d3dab06fe9eadacc3c7744b3e14e2 (diff)
downloadpdfium-1f403cee9478021862c7cc4e516907bd51e8f0f6.tar.xz
Convert more TransformPoint calls to Transform
This Cl converts several uses of TransformPoint to use Transform(CFX_PointF). Change-Id: I9bc3c484e0a4304b904584218bd9e59dec7db727 Reviewed-on: https://pdfium-review.googlesource.com/2791 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')
-rw-r--r--core/fpdfapi/page/cpdf_meshstream.cpp6
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp10
-rw-r--r--core/fxcrt/fx_basic_coords.cpp22
-rw-r--r--core/fxge/ge/cfx_pathdata.cpp18
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp13
-rw-r--r--core/fxge/win32/cfx_psrenderer.cpp22
6 files changed, 42 insertions, 49 deletions
diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp
index fbbd22276f..75069cab7f 100644
--- a/core/fpdfapi/page/cpdf_meshstream.cpp
+++ b/core/fpdfapi/page/cpdf_meshstream.cpp
@@ -214,8 +214,7 @@ CPDF_MeshVertex CPDF_MeshStream::ReadVertex(const CFX_Matrix& pObject2Bitmap,
*flag = ReadFlag();
CPDF_MeshVertex vertex;
- vertex.position = ReadCoords();
- pObject2Bitmap.TransformPoint(vertex.position.x, vertex.position.y);
+ vertex.position = pObject2Bitmap.Transform(ReadCoords());
std::tie(vertex.r, vertex.g, vertex.b) = ReadColor();
m_BitStream.ByteAlign();
@@ -229,8 +228,7 @@ bool CPDF_MeshStream::ReadVertexRow(const CFX_Matrix& pObject2Bitmap,
if (m_BitStream.IsEOF())
return false;
- vertex[i].position = ReadCoords();
- pObject2Bitmap.TransformPoint(vertex[i].position.x, vertex[i].position.y);
+ vertex[i].position = pObject2Bitmap.Transform(ReadCoords());
std::tie(vertex[i].r, vertex[i].g, vertex[i].b) = ReadColor();
m_BitStream.ByteAlign();
}
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 5a340cd8b1..b041a72662 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -2228,13 +2228,11 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
for (int col = min_col; col <= max_col; col++)
for (int row = min_row; row <= max_row; row++) {
- FX_FLOAT orig_x, orig_y;
- orig_x = col * pPattern->x_step();
- orig_y = row * pPattern->y_step();
- mtPattern2Device.TransformPoint(orig_x, orig_y);
+ CFX_PointF original = mtPattern2Device.Transform(
+ CFX_PointF(col * pPattern->x_step(), row * pPattern->y_step()));
CFX_Matrix matrix = *pObj2Device;
- matrix.Translate(orig_x - mtPattern2Device.e,
- orig_y - mtPattern2Device.f);
+ matrix.Translate(original.x - mtPattern2Device.e,
+ original.y - mtPattern2Device.f);
m_pDevice->SaveState();
CPDF_RenderStatus status;
status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp
index ea11acab6b..c9f3195f36 100644
--- a/core/fxcrt/fx_basic_coords.cpp
+++ b/core/fxcrt/fx_basic_coords.cpp
@@ -390,20 +390,20 @@ void CFX_Matrix::TransformRect(FX_FLOAT& left,
FX_FLOAT& right,
FX_FLOAT& top,
FX_FLOAT& bottom) const {
- FX_FLOAT x[4] = {left, left, right, right};
- FX_FLOAT y[4] = {top, bottom, top, bottom};
+ CFX_PointF points[] = {
+ {left, top}, {left, bottom}, {right, top}, {right, bottom}};
for (int i = 0; i < 4; i++)
- TransformPoint(x[i], y[i]);
+ points[i] = Transform(points[i]);
- right = x[0];
- left = x[0];
- top = y[0];
- bottom = y[0];
+ right = points[0].x;
+ left = points[0].x;
+ top = points[0].y;
+ bottom = points[0].y;
for (int i = 1; i < 4; i++) {
- right = std::max(right, x[i]);
- left = std::min(left, x[i]);
- top = std::max(top, y[i]);
- bottom = std::min(bottom, y[i]);
+ right = std::max(right, points[i].x);
+ left = std::min(left, points[i].x);
+ top = std::max(top, points[i].y);
+ bottom = std::min(bottom, points[i].y);
}
}
diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp
index 11c421e468..e06eadd6ce 100644
--- a/core/fxge/ge/cfx_pathdata.cpp
+++ b/core/fxge/ge/cfx_pathdata.cpp
@@ -452,26 +452,24 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
return false;
}
- FX_FLOAT x[5];
- FX_FLOAT y[5];
+ CFX_PointF points[5];
for (size_t i = 0; i < m_Points.size(); i++) {
- x[i] = m_Points[i].m_PointX;
- y[i] = m_Points[i].m_PointY;
- pMatrix->TransformPoint(x[i], y[i]);
+ points[i] = pMatrix->Transform(
+ CFX_PointF(m_Points[i].m_PointX, m_Points[i].m_PointY));
if (i == 0)
continue;
if (m_Points[i].m_Type != FXPT_TYPE::LineTo)
return false;
- if (x[i] != x[i - 1] && y[i] != y[i - 1])
+ if (points[i].x != points[i - 1].x && points[i].y != points[i - 1].y)
return false;
}
if (pRect) {
- pRect->left = x[0];
- pRect->right = x[2];
- pRect->bottom = y[0];
- pRect->top = y[2];
+ pRect->left = points[0].x;
+ pRect->right = points[2].x;
+ pRect->bottom = points[0].y;
+ pRect->top = points[2].y;
pRect->Normalize();
}
return true;
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index 86e74cafc4..203fecf061 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -490,15 +490,14 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData,
uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0;
const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints();
if (stroke_alpha == 0 && pPoints.size() == 2) {
- FX_FLOAT x1 = pPoints[0].m_PointX;
- FX_FLOAT y1 = pPoints[0].m_PointY;
- FX_FLOAT x2 = pPoints[1].m_PointX;
- FX_FLOAT y2 = pPoints[1].m_PointY;
+ CFX_PointF pos1(pPoints[0].m_PointX, pPoints[0].m_PointY);
+ CFX_PointF pos2(pPoints[1].m_PointX, pPoints[1].m_PointY);
if (pObject2Device) {
- pObject2Device->TransformPoint(x1, y1);
- pObject2Device->TransformPoint(x2, y2);
+ pos1 = pObject2Device->Transform(pos1);
+ pos2 = pObject2Device->Transform(pos2);
}
- DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, blend_type);
+ DrawCosmeticLine(pos1.x, pos1.y, pos2.x, pos2.y, fill_color, fill_mode,
+ blend_type);
return true;
}
diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp
index 32da090ed6..a0e675e23c 100644
--- a/core/fxge/win32/cfx_psrenderer.cpp
+++ b/core/fxge/win32/cfx_psrenderer.cpp
@@ -116,12 +116,11 @@ 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);
- FX_FLOAT x = pPathData->GetPointX(i);
- FX_FLOAT y = pPathData->GetPointY(i);
+ CFX_PointF pos(pPathData->GetPointX(i), pPathData->GetPointY(i));
if (pObject2Device)
- pObject2Device->TransformPoint(x, y);
+ pos = pObject2Device->Transform(pos);
- buf << x << " " << y;
+ buf << pos.x << " " << pos.y;
switch (type) {
case FXPT_TYPE::MoveTo:
buf << " m ";
@@ -132,15 +131,16 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData,
buf << "h ";
break;
case FXPT_TYPE::BezierTo: {
- FX_FLOAT x1 = pPathData->GetPointX(i + 1);
- FX_FLOAT x2 = pPathData->GetPointX(i + 2);
- FX_FLOAT y1 = pPathData->GetPointY(i + 1);
- FX_FLOAT y2 = pPathData->GetPointY(i + 2);
+ CFX_PointF pos1(pPathData->GetPointX(i + 1),
+ pPathData->GetPointY(i + 1));
+ CFX_PointF pos2(pPathData->GetPointX(i + 2),
+ pPathData->GetPointY(i + 2));
if (pObject2Device) {
- pObject2Device->TransformPoint(x1, y1);
- pObject2Device->TransformPoint(x2, y2);
+ pos1 = pObject2Device->Transform(pos1);
+ pos2 = pObject2Device->Transform(pos2);
}
- buf << " " << x1 << " " << y1 << " " << x2 << " " << y2 << " c";
+ buf << " " << pos1.x << " " << pos1.y << " " << pos2.x << " " << pos2.y
+ << " c";
if (closing)
buf << " h";
buf << "\n";