From 669a418f75c05d4a39e2bcaff2b7b93dec1c5764 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 3 Apr 2017 14:51:45 -0400 Subject: Drop FXSYS_ from math methods This Cl drops the FXSYS_ from math methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I85c9ff841fd9095b1434f67319847ba0cd9df7ac Reviewed-on: https://pdfium-review.googlesource.com/3598 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- xfa/fde/cfde_path.cpp | 25 +++++++++++---------- xfa/fde/cfde_renderdevice.cpp | 7 +++--- xfa/fde/cfde_txtedtengine.cpp | 3 +-- xfa/fde/css/cfde_cssnumbervalue.cpp | 2 +- xfa/fgas/crt/cfgas_formatstring.cpp | 4 ++-- xfa/fgas/layout/fgas_rtfbreak.cpp | 2 +- xfa/fgas/layout/fgas_textbreak.cpp | 2 +- xfa/fwl/cfwl_edit.cpp | 2 +- xfa/fxfa/app/cxfa_textlayout.cpp | 4 ++-- xfa/fxfa/cxfa_ffwidget.cpp | 8 +++---- xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 36 ++++++++++++++----------------- xfa/fxfa/parser/cxfa_stroke.cpp | 4 ++-- xfa/fxfa/parser/cxfa_timezoneprovider.cpp | 4 ++-- xfa/fxgraphics/cfx_graphics.cpp | 2 +- xfa/fxgraphics/cfx_path.cpp | 16 +++++++------- 15 files changed, 57 insertions(+), 64 deletions(-) (limited to 'xfa') diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp index 4afa718978..a7d2e47ac1 100644 --- a/xfa/fde/cfde_path.cpp +++ b/xfa/fde/cfde_path.cpp @@ -41,10 +41,9 @@ void CFDE_Path::ArcTo(bool bStart, float ry = rect.height / 2; float cx = rect.left + rx; float cy = rect.top + ry; - float alpha = - FXSYS_atan2(rx * FXSYS_sin(startAngle), ry * FXSYS_cos(startAngle)); - float beta = FXSYS_atan2(rx * FXSYS_sin(endAngle), ry * FXSYS_cos(endAngle)); - if (FXSYS_fabs(beta - alpha) > FX_PI) { + float alpha = atan2(rx * sin(startAngle), ry * cos(startAngle)); + float beta = atan2(rx * sin(endAngle), ry * cos(endAngle)); + if (fabs(beta - alpha) > FX_PI) { if (beta > alpha) beta -= 2 * FX_PI; else @@ -52,11 +51,11 @@ void CFDE_Path::ArcTo(bool bStart, } float half_delta = (beta - alpha) / 2; - float bcp = 4.0f / 3 * (1 - FXSYS_cos(half_delta)) / FXSYS_sin(half_delta); - float sin_alpha = FXSYS_sin(alpha); - float sin_beta = FXSYS_sin(beta); - float cos_alpha = FXSYS_cos(alpha); - float cos_beta = FXSYS_cos(beta); + float bcp = 4.0f / 3 * (1 - cos(half_delta)) / sin(half_delta); + float sin_alpha = sin(alpha); + float sin_beta = sin(beta); + float cos_alpha = cos(alpha); + float cos_beta = cos(beta); if (bStart) MoveTo(CFX_PointF(cx + rx * cos_alpha, cy + ry * sin_alpha)); @@ -154,8 +153,8 @@ void CFDE_Path::AddEllipse(const CFX_RectF& rect) { void CFDE_Path::AddLine(const CFX_PointF& pt1, const CFX_PointF& pt2) { std::vector& points = m_Path.GetPoints(); - if (points.empty() || FXSYS_fabs(points.back().m_Point.x - pt1.x) > 0.001 || - FXSYS_fabs(points.back().m_Point.y - pt1.y) > 0.001) { + if (points.empty() || fabs(points.back().m_Point.x - pt1.x) > 0.001 || + fabs(points.back().m_Point.y - pt1.y) > 0.001) { MoveTo(pt1); } LineTo(pt2); @@ -180,8 +179,8 @@ void CFDE_Path::AddPolygon(const std::vector& points) { AddLines(points); const CFX_PointF* p = points.data(); - if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f || - FXSYS_fabs(p[0].y - p[iCount - 1].y) < 0.01f) { + if (fabs(p[0].x - p[iCount - 1].x) < 0.01f || + fabs(p[0].y - p[iCount - 1].y) < 0.01f) { LineTo(p[0]); } CloseFigure(); diff --git a/xfa/fde/cfde_renderdevice.cpp b/xfa/fde/cfde_renderdevice.cpp index d3456e17cb..6f2431737b 100644 --- a/xfa/fde/cfde_renderdevice.cpp +++ b/xfa/fde/cfde_renderdevice.cpp @@ -57,10 +57,9 @@ void CFDE_RenderDevice::RestoreState() { bool CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) { m_rtClip = rtClip; - return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left), - (int32_t)FXSYS_floor(rtClip.top), - (int32_t)FXSYS_ceil(rtClip.right()), - (int32_t)FXSYS_ceil(rtClip.bottom()))); + return m_pDevice->SetClip_Rect( + FX_RECT((int32_t)floor(rtClip.left), (int32_t)floor(rtClip.top), + (int32_t)ceil(rtClip.right()), (int32_t)ceil(rtClip.bottom()))); } const CFX_RectF& CFDE_RenderDevice::GetClipRect() { diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 15edfc1c1c..37e3e118d1 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -283,8 +283,7 @@ int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, break; } if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) { - AddSelRange(std::min(m_nAnchorPos, m_nCaret), - FXSYS_abs(m_nAnchorPos - m_nCaret)); + AddSelRange(std::min(m_nAnchorPos, m_nCaret), abs(m_nAnchorPos - m_nCaret)); m_Param.pEventSink->OnSelChanged(); } if (bSelChange) diff --git a/xfa/fde/css/cfde_cssnumbervalue.cpp b/xfa/fde/css/cfde_cssnumbervalue.cpp index e74ca5b859..45a9c917b1 100644 --- a/xfa/fde/css/cfde_cssnumbervalue.cpp +++ b/xfa/fde/css/cfde_cssnumbervalue.cpp @@ -8,7 +8,7 @@ CFDE_CSSNumberValue::CFDE_CSSNumberValue(FDE_CSSNumberType type, float value) : CFDE_CSSValue(FDE_CSSPrimitiveType::Number), type_(type), value_(value) { - if (type_ == FDE_CSSNumberType::Number && FXSYS_fabs(value_) < 0.001f) + if (type_ == FDE_CSSNumberType::Number && fabs(value_) < 0.001f) value_ = 0.0f; } diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp index 9123b5c127..8d80269418 100644 --- a/xfa/fgas/crt/cfgas_formatstring.cpp +++ b/xfa/fgas/crt/cfgas_formatstring.cpp @@ -885,7 +885,7 @@ bool TimeFormat(const CFX_WideString& wsTimePattern, wsResult += tz.tzHour < 0 ? L"-" : L"+"; CFX_WideString wsTimezone; - wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); + wsTimezone.Format(L"%02d:%02d", abs(tz.tzHour), tz.tzMinute); wsResult += wsTimezone; } } else if (dwSymbol == FXBSTR_ID(0, 0, 'z', '1')) { @@ -894,7 +894,7 @@ bool TimeFormat(const CFX_WideString& wsTimePattern, wsResult += tz.tzHour < 0 ? L"-" : L"+"; CFX_WideString wsTimezone; - wsTimezone.Format(L"%02d:%02d", FXSYS_abs(tz.tzHour), tz.tzMinute); + wsTimezone.Format(L"%02d:%02d", abs(tz.tzHour), tz.tzMinute); wsResult += wsTimezone; } } diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 07a3cefa69..842e729217 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -703,7 +703,7 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, continue; } - int32_t iCharWidth = FXSYS_abs(iWidth); + int32_t iCharWidth = abs(iWidth); bool bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && dwCharType <= FX_CHARTYPE_Control); if (!bEmptyChar) diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index c21d6bba3a..83a03eed5e 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -946,7 +946,7 @@ std::vector CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, bCharBBox = pFont->GetBBox(&bbox); float fLeft = std::max(0.0f, bbox.left * fScale); - float fHeight = FXSYS_fabs(bbox.height * fScale); + float fHeight = fabs(bbox.height * fScale); bool bRTLPiece = !!(pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel); bool bSingleLine = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_SingleLine); bool bCombText = !!(pTxtRun->dwStyles & FX_LAYOUTSTYLE_CombText); diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index c2b0ddf669..1b76ec6240 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -1367,7 +1367,7 @@ void CFWL_Edit::OnMouseMove(CFWL_MessageMouse* pMsg) { m_nSelStart = nLen; m_EdtEngine.AddSelRange(std::min(m_nSelStart, nIndex), - FXSYS_abs(nIndex - m_nSelStart)); + abs(nIndex - m_nSelStart)); } void CFWL_Edit::OnKeyDown(CFWL_MessageKey* pMsg) { diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index f16fd8c1a9..9f4962e458 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -273,8 +273,8 @@ float CXFA_TextLayout::StartLayout(float fWidth) { if (!m_pLoader) m_pLoader = pdfium::MakeUnique(); - if (fWidth < 0 || (m_pLoader->m_fWidth > -1 && - FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) { + if (fWidth < 0 || + (m_pLoader->m_fWidth > -1 && fabs(fWidth - m_pLoader->m_fWidth) > 0)) { m_pLoader->m_lineHeights.clear(); m_Blocks.clear(); Unload(); diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index e6f30c0467..1ebc6da353 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -640,8 +640,8 @@ bool CXFA_ImageRenderer::StartDIBSource() { FX_RECT image_rect = image_rect_f.GetOuterRect(); int dest_width = image_rect.Width(); int dest_height = image_rect.Height(); - if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || - (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { + if ((fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) || + (fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) { if (m_bPrint && !(m_pDevice->GetRenderCaps() & FXRC_BLEND_MODE)) { m_Result = false; return false; @@ -1550,8 +1550,8 @@ static void XFA_BOX_Fill_Radial(CXFA_Box box, crStart = temp; } CFX_Shading shading(rtFill.Center(), rtFill.Center(), 0, - FXSYS_sqrt(rtFill.Width() * rtFill.Width() + - rtFill.Height() * rtFill.Height()) / + sqrt(rtFill.Width() * rtFill.Width() + + rtFill.Height() * rtFill.Height()) / 2, true, true, crStart, crEnd); CFX_Color cr(&shading); diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index b95a6d3aab..d38a6715e8 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -615,8 +615,7 @@ void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, return; } - args.GetReturnValue()->SetFloat( - FXSYS_ceil(ValueToFloat(pThis, argValue.get()))); + args.GetReturnValue()->SetFloat(ceil(ValueToFloat(pThis, argValue.get()))); } // static @@ -688,8 +687,7 @@ void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, return; } - args.GetReturnValue()->SetFloat( - FXSYS_floor(ValueToFloat(pThis, argValue.get()))); + args.GetReturnValue()->SetFloat(floor(ValueToFloat(pThis, argValue.get()))); } // static @@ -1419,7 +1417,7 @@ void CXFA_FM2JSContext::Num2GMTime(CFXJSE_Value* pThis, return; } int32_t iTime = (int32_t)ValueToFloat(pThis, timeValue.get()); - if (FXSYS_abs(iTime) < 1.0) { + if (abs(iTime) < 1.0) { args.GetReturnValue()->SetNull(); return; } @@ -1466,7 +1464,7 @@ void CXFA_FM2JSContext::Num2Time(CFXJSE_Value* pThis, return; } float fTime = ValueToFloat(pThis, timeValue.get()); - if (FXSYS_fabs(fTime) < 1.0) { + if (fabs(fTime) < 1.0) { args.GetReturnValue()->SetNull(); return; } @@ -2407,9 +2405,8 @@ void CXFA_FM2JSContext::CTerm(CFXJSE_Value* pThis, return; } - args.GetReturnValue()->SetFloat( - FXSYS_log((float)(nFutureValue / nInitAmount)) / - FXSYS_log((float)(1 + nRate))); + args.GetReturnValue()->SetFloat(log((float)(nFutureValue / nInitAmount)) / + log((float)(1 + nRate))); } // static @@ -2487,10 +2484,10 @@ void CXFA_FM2JSContext::IPmt(CFXJSE_Value* pThis, } float nRateOfMonth = nRate / 12; - int32_t iNums = (int32_t)( - (FXSYS_log10((float)(nPayment / nPrincipalAmount)) - - FXSYS_log10((float)(nPayment / nPrincipalAmount - nRateOfMonth))) / - FXSYS_log10((float)(1 + nRateOfMonth))); + int32_t iNums = + (int32_t)((log10((float)(nPayment / nPrincipalAmount)) - + log10((float)(nPayment / nPrincipalAmount - nRateOfMonth))) / + log10((float)(1 + nRateOfMonth))); int32_t iEnd = std::min((int32_t)(nFirstMonth + nNumberOfMonths - 1), iNums); if (nPayment < nPrincipalAmount * nRateOfMonth) { @@ -2622,10 +2619,10 @@ void CXFA_FM2JSContext::PPmt(CFXJSE_Value* pThis, } float nRateOfMonth = nRate / 12; - int32_t iNums = (int32_t)( - (FXSYS_log10((float)(nPayment / nPrincipalAmount)) - - FXSYS_log10((float)(nPayment / nPrincipalAmount - nRateOfMonth))) / - FXSYS_log10((float)(1 + nRateOfMonth))); + int32_t iNums = + (int32_t)((log10((float)(nPayment / nPrincipalAmount)) - + log10((float)(nPayment / nPrincipalAmount - nRateOfMonth))) / + log10((float)(1 + nRateOfMonth))); int32_t iEnd = std::min((int32_t)(nFirstMonth + nNumberOfMonths - 1), iNums); if (nPayment < nPrincipalAmount * nRateOfMonth) { pContext->ThrowArgumentMismatchException(); @@ -2739,9 +2736,8 @@ void CXFA_FM2JSContext::Term(CFXJSE_Value* pThis, return; } - args.GetReturnValue()->SetFloat( - FXSYS_log((float)(nFuture / nMount * nRate) + 1) / - FXSYS_log((float)(1 + nRate))); + args.GetReturnValue()->SetFloat(log((float)(nFuture / nMount * nRate) + 1) / + log((float)(1 + nRate))); } // static diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp index 2e1ef12ce5..df11cbee00 100644 --- a/xfa/fxfa/parser/cxfa_stroke.cpp +++ b/xfa/fxfa/parser/cxfa_stroke.cpp @@ -89,7 +89,7 @@ float CXFA_Stroke::GetRadius() const { bool CXFA_Stroke::SameStyles(CXFA_Stroke stroke, uint32_t dwFlags) const { if (m_pNode == stroke.GetNode()) return true; - if (FXSYS_fabs(GetThickness() - stroke.GetThickness()) >= 0.01f) + if (fabs(GetThickness() - stroke.GetThickness()) >= 0.01f) return false; if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 && IsVisible() != stroke.IsVisible()) { @@ -100,7 +100,7 @@ bool CXFA_Stroke::SameStyles(CXFA_Stroke stroke, uint32_t dwFlags) const { if (GetColor() != stroke.GetColor()) return false; if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 && - FXSYS_fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) { + fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) { return false; } return true; diff --git a/xfa/fxfa/parser/cxfa_timezoneprovider.cpp b/xfa/fxfa/parser/cxfa_timezoneprovider.cpp index ae31977e6d..022b9225b4 100644 --- a/xfa/fxfa/parser/cxfa_timezoneprovider.cpp +++ b/xfa/fxfa/parser/cxfa_timezoneprovider.cpp @@ -17,7 +17,7 @@ CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() { _tzset(); } m_tz.tzHour = static_cast(_timezone / 3600 * -1); - m_tz.tzMinute = static_cast((FXSYS_abs(_timezone) % 3600) / 60); + m_tz.tzMinute = static_cast((abs(_timezone) % 3600) / 60); #else if (!g_bProviderTimeZoneSet) { g_bProviderTimeZoneSet = true; @@ -25,7 +25,7 @@ CXFA_TimeZoneProvider::CXFA_TimeZoneProvider() { } m_tz.tzHour = static_cast(timezone / 3600 * -1); m_tz.tzMinute = - static_cast((FXSYS_abs(static_cast(timezone)) % 3600) / 60); + static_cast((abs(static_cast(timezone)) % 3600) / 60); #endif } diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 3cfe2d0192..1f224c7685 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -452,7 +452,7 @@ void CFX_Graphics::FillPathWithShading(CFX_Path* path, if (b2_4ac < 0) { continue; } - float root = (FXSYS_sqrt(b2_4ac)); + float root = (sqrt(b2_4ac)); float s1, s2; if (a > 0) { s1 = (-b - root) / (2 * a); diff --git a/xfa/fxgraphics/cfx_path.cpp b/xfa/fxgraphics/cfx_path.cpp index 5ff9bffb07..fc0051ad4c 100644 --- a/xfa/fxgraphics/cfx_path.cpp +++ b/xfa/fxgraphics/cfx_path.cpp @@ -50,14 +50,14 @@ void CFX_Path::ArcToInternal(const CFX_PointF& pos, const CFX_SizeF& size, float start_angle, float sweep_angle) { - float x0 = FXSYS_cos(sweep_angle / 2); - float y0 = FXSYS_sin(sweep_angle / 2); + float x0 = cos(sweep_angle / 2); + float y0 = sin(sweep_angle / 2); float tx = ((1.0f - x0) * 4) / (3 * 1.0f); float ty = y0 - ((tx * x0) / y0); CFX_PointF points[] = {CFX_PointF(x0 + tx, -ty), CFX_PointF(x0 + tx, ty)}; - float sn = FXSYS_sin(start_angle + sweep_angle / 2); - float cs = FXSYS_cos(start_angle + sweep_angle / 2); + float sn = sin(start_angle + sweep_angle / 2); + float cs = cos(start_angle + sweep_angle / 2); CFX_PointF bezier; bezier.x = pos.x + (size.width * ((points[0].x * cs) - (points[0].y * sn))); @@ -68,8 +68,8 @@ void CFX_Path::ArcToInternal(const CFX_PointF& pos, bezier.y = pos.y + (size.height * ((points[1].x * sn) + (points[1].y * cs))); data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); - bezier.x = pos.x + (size.width * FXSYS_cos(start_angle + sweep_angle)); - bezier.y = pos.y + (size.height * FXSYS_sin(start_angle + sweep_angle)); + bezier.x = pos.x + (size.width * cos(start_angle + sweep_angle)); + bezier.y = pos.y + (size.height * sin(start_angle + sweep_angle)); data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); } @@ -105,8 +105,8 @@ void CFX_Path::AddArc(const CFX_PointF& original_pos, CFX_SizeF size = original_size / 2; CFX_PointF pos(original_pos.x + size.width, original_pos.y + size.height); - data_.AppendPoint(pos + CFX_PointF(size.width * FXSYS_cos(start_angle), - size.height * FXSYS_sin(start_angle)), + data_.AppendPoint(pos + CFX_PointF(size.width * cos(start_angle), + size.height * sin(start_angle)), FXPT_TYPE::MoveTo, false); float total_sweep = 0; -- cgit v1.2.3