From afb44560a21298b3588b36cbaf45e2be50f2e75b Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 9 Feb 2017 13:07:43 -0500 Subject: Remove Transform in favour of TransformPoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL removes the two Transform() overrides from CFX_Matrix and calls the TransformPoint methods directly. In the case of the 4 param version the values were assigned to the out values before calling. Change-Id: Id633826caec75b848774dcda6cfdcef2dbf5a7db Reviewed-on: https://pdfium-review.googlesource.com/2573 Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxge/agg/fx_agg_driver.cpp | 8 ++++---- core/fxge/apple/fx_apple_platform.cpp | 2 +- core/fxge/ge/cfx_pathdata.cpp | 31 +++++++++++++++++-------------- core/fxge/ge/cfx_renderdevice.cpp | 19 ++++++++----------- core/fxge/win32/cfx_psrenderer.cpp | 10 +++++----- core/fxge/win32/fx_win32_device.cpp | 22 +++++++++++----------- core/fxge/win32/fx_win32_gdipext.cpp | 29 ++++++++++++----------------- 7 files changed, 58 insertions(+), 63 deletions(-) (limited to 'core/fxge') diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 71d6dbaf86..3ae2c37150 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -278,7 +278,7 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, for (int i = 0; i < nPoints; i++) { FX_FLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY; if (pObject2Device) { - pObject2Device->Transform(x, y); + pObject2Device->TransformPoint(x, y); } HardClip(x, y); FXPT_TYPE point_type = pPoints[i].m_Type; @@ -298,9 +298,9 @@ void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, FX_FLOAT x2 = pPoints[i + 1].m_PointX, y2 = pPoints[i + 1].m_PointY; FX_FLOAT x3 = pPoints[i + 2].m_PointX, y3 = pPoints[i + 2].m_PointY; if (pObject2Device) { - pObject2Device->Transform(x0, y0); - pObject2Device->Transform(x2, y2); - pObject2Device->Transform(x3, y3); + pObject2Device->TransformPoint(x0, y0); + pObject2Device->TransformPoint(x2, y2); + pObject2Device->TransformPoint(x3, y3); } HardClip(x0, y0); HardClip(x2, y2); diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index 6d7fb2e06a..d6867384e6 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -41,7 +41,7 @@ bool CGDrawGlyphRun(CGContextRef pContext, FX_FLOAT ori_x = pCharPos[0].m_OriginX, ori_y = pCharPos[0].m_OriginY; CFX_Matrix new_matrix; - new_matrix.Transform(ori_x, ori_y); + new_matrix.TransformPoint(ori_x, ori_y); if (pObject2Device) new_matrix.Concat(*pObject2Device); diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp index d1391850c0..14eabb990a 100644 --- a/core/fxge/ge/cfx_pathdata.cpp +++ b/core/fxge/ge/cfx_pathdata.cpp @@ -65,8 +65,8 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) { pSrc->m_PointCount * sizeof(FX_PATHPOINT)); if (pMatrix) { for (int i = 0; i < pSrc->m_PointCount; i++) { - pMatrix->Transform(m_pPoints[old_count + i].m_PointX, - m_pPoints[old_count + i].m_PointY); + pMatrix->TransformPoint(m_pPoints[old_count + i].m_PointX, + m_pPoints[old_count + i].m_PointY); } } } @@ -316,7 +316,7 @@ void CFX_PathData::Transform(const CFX_Matrix* pMatrix) { return; } for (int i = 0; i < m_PointCount; i++) { - pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); + pMatrix->TransformPoint(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); } } @@ -497,9 +497,9 @@ bool CFX_PathData::IsRect() const { bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* pRect) const { if (!pMatrix) { - if (!IsRect()) { + if (!IsRect()) return false; - } + if (pRect) { pRect->left = m_pPoints[0].m_PointX; pRect->right = m_pPoints[2].m_PointX; @@ -509,9 +509,10 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix, } return true; } - if (m_PointCount != 5 && m_PointCount != 4) { + + if (m_PointCount != 5 && m_PointCount != 4) return false; - } + if ((m_PointCount == 5 && (m_pPoints[0].m_PointX != m_pPoints[4].m_PointX || m_pPoints[0].m_PointY != m_pPoints[4].m_PointY)) || (m_pPoints[1].m_PointX == m_pPoints[3].m_PointX && @@ -522,19 +523,21 @@ bool CFX_PathData::IsRect(const CFX_Matrix* pMatrix, m_pPoints[0].m_PointY != m_pPoints[3].m_PointY) { return false; } - FX_FLOAT x[5], y[5]; + + FX_FLOAT x[5]; + FX_FLOAT y[5]; for (int i = 0; i < m_PointCount; i++) { - pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY, x[i], - y[i]); + x[i] = m_pPoints[i].m_PointX; + y[i] = m_pPoints[i].m_PointY; + pMatrix->TransformPoint(x[i], y[i]); if (i) { - if (m_pPoints[i].m_Type != FXPT_TYPE::LineTo) { + if (m_pPoints[i].m_Type != FXPT_TYPE::LineTo) return false; - } - if (x[i] != x[i - 1] && y[i] != y[i - 1]) { + if (x[i] != x[i - 1] && y[i] != y[i - 1]) return false; - } } } + if (pRect) { pRect->left = x[0]; pRect->right = x[2]; diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index 52ed8c37c0..0c73c7a66a 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -475,21 +475,18 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData, uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0; if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) { FX_PATHPOINT* pPoints = pPathData->GetPoints(); - FX_FLOAT x1, x2, y1, y2; + 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; if (pObject2Device) { - pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, - y1); - pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, - y2); - } else { - x1 = pPoints[0].m_PointX; - y1 = pPoints[0].m_PointY; - x2 = pPoints[1].m_PointX; - y2 = pPoints[1].m_PointY; + pObject2Device->TransformPoint(x1, y1); + pObject2Device->TransformPoint(x2, y2); } DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, blend_type); return true; } + if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && stroke_alpha == 0) { CFX_FloatRect rect_f; @@ -913,7 +910,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, const FXTEXT_CHARPOS& charpos = pCharPos[i]; glyph.m_fOriginX = charpos.m_OriginX; glyph.m_fOriginY = charpos.m_OriginY; - text2Device.Transform(glyph.m_fOriginX, glyph.m_fOriginY); + text2Device.TransformPoint(glyph.m_fOriginX, glyph.m_fOriginY); if (anti_alias < FXFT_RENDER_MODE_LCD) glyph.m_OriginX = FXSYS_round(glyph.m_fOriginX); else diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 2e4519c46f..7fc47b9a46 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -117,9 +117,9 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, bool closing = pPathData->IsClosingFigure(i); FX_FLOAT x = pPathData->GetPointX(i); FX_FLOAT y = pPathData->GetPointY(i); - if (pObject2Device) { - pObject2Device->Transform(x, y); - } + if (pObject2Device) + pObject2Device->TransformPoint(x, y); + buf << x << " " << y; switch (type) { case FXPT_TYPE::MoveTo: @@ -136,8 +136,8 @@ void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, FX_FLOAT y1 = pPathData->GetPointY(i + 1); FX_FLOAT y2 = pPathData->GetPointY(i + 2); if (pObject2Device) { - pObject2Device->Transform(x1, y1); - pObject2Device->Transform(x2, y2); + pObject2Device->TransformPoint(x1, y1); + pObject2Device->TransformPoint(x2, y2); } buf << " " << x1 << " " << y1 << " " << x2 << " " << y2 << " c"; if (closing) diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index c8ceacfc4c..3df38f1965 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -170,9 +170,9 @@ void SetPathToDC(HDC hDC, FX_PATHPOINT* pPoints = pPathData->GetPoints(); for (int i = 0; i < nPoints; i++) { FX_FLOAT posx = pPoints[i].m_PointX, posy = pPoints[i].m_PointY; - if (pMatrix) { - pMatrix->Transform(posx, posy); - } + if (pMatrix) + pMatrix->TransformPoint(posx, posy); + int screen_x = FXSYS_round(posx), screen_y = FXSYS_round(posy); FXPT_TYPE point_type = pPoints[i].m_Type; if (point_type == FXPT_TYPE::MoveTo) { @@ -189,16 +189,16 @@ void SetPathToDC(HDC hDC, lppt[0].y = screen_y; posx = pPoints[i + 1].m_PointX; posy = pPoints[i + 1].m_PointY; - if (pMatrix) { - pMatrix->Transform(posx, posy); - } + if (pMatrix) + pMatrix->TransformPoint(posx, posy); + lppt[1].x = FXSYS_round(posx); lppt[1].y = FXSYS_round(posy); posx = pPoints[i + 2].m_PointX; posy = pPoints[i + 2].m_PointY; - if (pMatrix) { - pMatrix->Transform(posx, posy); - } + if (pMatrix) + pMatrix->TransformPoint(posx, posy); + lppt[2].x = FXSYS_round(posx); lppt[2].y = FXSYS_round(posy); PolyBezierTo(hDC, lppt, 3); @@ -1056,8 +1056,8 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, FX_FLOAT x2 = pPathData->GetPointX(1); FX_FLOAT y2 = pPathData->GetPointY(1); if (pMatrix) { - pMatrix->Transform(x1, y1); - pMatrix->Transform(x2, y2); + pMatrix->TransformPoint(x1, y1); + pMatrix->TransformPoint(x2, y2); } DrawLine(x1, y1, x2, y2); } else { diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 65f7b3e732..c703e3e300 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -1083,8 +1083,8 @@ static bool IsSmallTriangle(PointF* points, FX_FLOAT x1 = points[pair1].X, x2 = points[pair2].X; FX_FLOAT y1 = points[pair1].Y, y2 = points[pair2].Y; if (pMatrix) { - pMatrix->Transform(x1, y1); - pMatrix->Transform(x2, y2); + pMatrix->TransformPoint(x1, y1); + pMatrix->TransformPoint(x2, y2); } FX_FLOAT dx = x1 - x2; FX_FLOAT dy = y1 - y2; @@ -1132,25 +1132,20 @@ bool CGdiplusExt::DrawPath(HDC hDC, for (int i = 0; i < nPoints; i++) { points[i].X = pPoints[i].m_PointX; points[i].Y = pPoints[i].m_PointY; - FX_FLOAT x, y; - if (pObject2Device) { - pObject2Device->Transform(pPoints[i].m_PointX, pPoints[i].m_PointY, x, y); - } else { - x = pPoints[i].m_PointX; - y = pPoints[i].m_PointY; - } - if (x > 50000 * 1.0f) { + FX_FLOAT x = pPoints[i].m_PointX; + FX_FLOAT y = pPoints[i].m_PointY; + if (pObject2Device) + pObject2Device->TransformPoint(x, y); + + if (x > 50000 * 1.0f) points[i].X = 50000 * 1.0f; - } - if (x < -50000 * 1.0f) { + if (x < -50000 * 1.0f) points[i].X = -50000 * 1.0f; - } - if (y > 50000 * 1.0f) { + if (y > 50000 * 1.0f) points[i].Y = 50000 * 1.0f; - } - if (y < -50000 * 1.0f) { + if (y < -50000 * 1.0f) points[i].Y = -50000 * 1.0f; - } + FXPT_TYPE point_type = pPoints[i].m_Type; if (point_type == FXPT_TYPE::MoveTo) { types[i] = PathPointTypeStart; -- cgit v1.2.3