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 --- core/fxge/dib/cfx_dibsource.cpp | 2 +- core/fxge/dib/cfx_imagerenderer.cpp | 10 ++++----- core/fxge/dib/cfx_imagetransformer.cpp | 21 +++++++++--------- core/fxge/dib/fx_dib_engine.cpp | 39 +++++++++++++++++----------------- 4 files changed, 35 insertions(+), 37 deletions(-) (limited to 'core/fxge/dib') diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp index 4cdedd1051..4b76b02ee7 100644 --- a/core/fxge/dib/cfx_dibsource.cpp +++ b/core/fxge/dib/cfx_dibsource.cpp @@ -513,7 +513,7 @@ CFX_RetainPtr CFX_DIBSource::StretchTo(int dest_width, uint32_t flags, const FX_RECT* pClip) { CFX_RetainPtr holder(this); - FX_RECT clip_rect(0, 0, FXSYS_abs(dest_width), FXSYS_abs(dest_height)); + FX_RECT clip_rect(0, 0, abs(dest_width), abs(dest_height)); if (pClip) clip_rect.Intersect(*pClip); diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp index 776ba92775..89eb48f0cb 100644 --- a/core/fxge/dib/cfx_imagerenderer.cpp +++ b/core/fxge/dib/cfx_imagerenderer.cpp @@ -53,11 +53,11 @@ bool CFX_ImageRenderer::Start(const CFX_RetainPtr& pDevice, m_bRgbByteOrder = bRgbByteOrder; m_BlendType = blend_type; - if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || - (FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0)) { - if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 && - FXSYS_fabs(m_Matrix.d) < FXSYS_fabs(m_Matrix.c) / 20 && - FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) { + if ((fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || + (fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0)) { + if (fabs(m_Matrix.a) < fabs(m_Matrix.b) / 20 && + fabs(m_Matrix.d) < fabs(m_Matrix.c) / 20 && fabs(m_Matrix.a) < 0.5f && + fabs(m_Matrix.d) < 0.5f) { int dest_width = image_rect.Width(); int dest_height = image_rect.Height(); FX_RECT bitmap_clip = m_ClipBox; diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index d8159aabb5..65f6bc8ec9 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -168,9 +168,9 @@ bool CFX_ImageTransformer::Start() { return false; m_result = result_clip; - if (FXSYS_fabs(m_pMatrix->a) < FXSYS_fabs(m_pMatrix->b) / 20 && - FXSYS_fabs(m_pMatrix->d) < FXSYS_fabs(m_pMatrix->c) / 20 && - FXSYS_fabs(m_pMatrix->a) < 0.5f && FXSYS_fabs(m_pMatrix->d) < 0.5f) { + if (fabs(m_pMatrix->a) < fabs(m_pMatrix->b) / 20 && + fabs(m_pMatrix->d) < fabs(m_pMatrix->c) / 20 && + fabs(m_pMatrix->a) < 0.5f && fabs(m_pMatrix->d) < 0.5f) { int dest_width = result_rect.Width(); int dest_height = result_rect.Height(); result_clip.Offset(-result_rect.left, -result_rect.top); @@ -182,12 +182,11 @@ bool CFX_ImageTransformer::Start() { m_Status = 1; return true; } - if (FXSYS_fabs(m_pMatrix->b) < FIX16_005 && - FXSYS_fabs(m_pMatrix->c) < FIX16_005) { - int dest_width = m_pMatrix->a > 0 ? (int)FXSYS_ceil(m_pMatrix->a) - : (int)FXSYS_floor(m_pMatrix->a); - int dest_height = m_pMatrix->d > 0 ? (int)-FXSYS_ceil(m_pMatrix->d) - : (int)-FXSYS_floor(m_pMatrix->d); + if (fabs(m_pMatrix->b) < FIX16_005 && fabs(m_pMatrix->c) < FIX16_005) { + int dest_width = + m_pMatrix->a > 0 ? (int)ceil(m_pMatrix->a) : (int)floor(m_pMatrix->a); + int dest_height = + m_pMatrix->d > 0 ? (int)-ceil(m_pMatrix->d) : (int)-floor(m_pMatrix->d); result_clip.Offset(-result_rect.left, -result_rect.top); m_Stretcher = pdfium::MakeUnique( &m_Storer, m_pSrc, dest_width, dest_height, result_clip, m_Flags); @@ -195,8 +194,8 @@ bool CFX_ImageTransformer::Start() { m_Status = 2; return true; } - int stretch_width = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b)); - int stretch_height = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d)); + int stretch_width = (int)ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b)); + int stretch_height = (int)ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d)); CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, (float)(stretch_height)); stretch2dest.Concat( diff --git a/core/fxge/dib/fx_dib_engine.cpp b/core/fxge/dib/fx_dib_engine.cpp index d304a56600..9a5a7c1351 100644 --- a/core/fxge/dib/fx_dib_engine.cpp +++ b/core/fxge/dib/fx_dib_engine.cpp @@ -40,9 +40,8 @@ bool CWeightTable::Calc(int dest_len, const double scale = (float)src_len / (float)dest_len; const double base = dest_len < 0 ? (float)(src_len) : 0; const int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; - m_ItemSize = - sizeof(int) * 2 + - (int)(sizeof(int) * (FXSYS_ceil(FXSYS_fabs((float)scale)) + ext_size)); + m_ItemSize = sizeof(int) * 2 + + (int)(sizeof(int) * (ceil(fabs((float)scale)) + ext_size)); m_DestMin = dest_min; if ((dest_max - dest_min) > (int)((1U << 30) - 4) / m_ItemSize) return false; @@ -52,13 +51,13 @@ bool CWeightTable::Calc(int dest_len, if (!m_pWeightTables) return false; - if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((float)scale) < 1.0f) { + if ((flags & FXDIB_NOSMOOTH) != 0 || fabs((float)scale) < 1.0f) { for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel++) { PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); double src_pos = dest_pixel * scale + scale / 2 + base; if (flags & FXDIB_INTERPOL) { - pixel_weights.m_SrcStart = (int)FXSYS_floor((float)src_pos - 1.0f / 2); - pixel_weights.m_SrcEnd = (int)FXSYS_floor((float)src_pos + 1.0f / 2); + pixel_weights.m_SrcStart = (int)floor((float)src_pos - 1.0f / 2); + pixel_weights.m_SrcEnd = (int)floor((float)src_pos + 1.0f / 2); if (pixel_weights.m_SrcStart < src_min) { pixel_weights.m_SrcStart = src_min; } @@ -73,8 +72,8 @@ bool CWeightTable::Calc(int dest_len, pixel_weights.m_Weights[0] = 65536 - pixel_weights.m_Weights[1]; } } else if (flags & FXDIB_BICUBIC_INTERPOL) { - pixel_weights.m_SrcStart = (int)FXSYS_floor((float)src_pos - 1.0f / 2); - pixel_weights.m_SrcEnd = (int)FXSYS_floor((float)src_pos + 1.0f / 2); + pixel_weights.m_SrcStart = (int)floor((float)src_pos - 1.0f / 2); + pixel_weights.m_SrcEnd = (int)floor((float)src_pos + 1.0f / 2); int start = pixel_weights.m_SrcStart - 1; int end = pixel_weights.m_SrcEnd + 1; if (start < src_min) { @@ -157,7 +156,7 @@ bool CWeightTable::Calc(int dest_len, } } else { pixel_weights.m_SrcStart = pixel_weights.m_SrcEnd = - (int)FXSYS_floor((float)src_pos); + (int)floor((float)src_pos); if (pixel_weights.m_SrcStart < src_min) { pixel_weights.m_SrcStart = src_min; } @@ -176,11 +175,11 @@ bool CWeightTable::Calc(int dest_len, double src_end = src_start + scale; int start_i, end_i; if (src_start < src_end) { - start_i = (int)FXSYS_floor((float)src_start); - end_i = (int)FXSYS_ceil((float)src_end); + start_i = (int)floor((float)src_start); + end_i = (int)ceil((float)src_end); } else { - start_i = (int)FXSYS_floor((float)src_end); - end_i = (int)FXSYS_ceil((float)src_start); + start_i = (int)floor((float)src_end); + end_i = (int)ceil((float)src_start); } if (start_i < src_min) { start_i = src_min; @@ -286,9 +285,9 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, m_SrcPitch = (m_SrcWidth * m_SrcBpp + 31) / 32 * 4; if ((flags & FXDIB_NOSMOOTH) == 0) { bool bInterpol = flags & FXDIB_INTERPOL || flags & FXDIB_BICUBIC_INTERPOL; - if (!bInterpol && FXSYS_abs(dest_width) != 0 && - FXSYS_abs(dest_height) / 8 < static_cast(m_SrcWidth) * - m_SrcHeight / FXSYS_abs(dest_width)) { + if (!bInterpol && abs(dest_width) != 0 && + abs(dest_height) / 8 < static_cast(m_SrcWidth) * + m_SrcHeight / abs(dest_width)) { flags = FXDIB_INTERPOL; } m_Flags = flags; @@ -316,10 +315,10 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, src_top = src_bottom; src_bottom = temp; } - m_SrcClip.left = (int)FXSYS_floor((float)src_left); - m_SrcClip.right = (int)FXSYS_ceil((float)src_right); - m_SrcClip.top = (int)FXSYS_floor((float)src_top); - m_SrcClip.bottom = (int)FXSYS_ceil((float)src_bottom); + m_SrcClip.left = (int)floor((float)src_left); + m_SrcClip.right = (int)ceil((float)src_right); + m_SrcClip.top = (int)floor((float)src_top); + m_SrcClip.bottom = (int)ceil((float)src_bottom); FX_RECT src_rect(0, 0, m_SrcWidth, m_SrcHeight); m_SrcClip.Intersect(src_rect); if (m_SrcBpp == 1) { -- cgit v1.2.3