diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/include/fxcrt/fx_system.h | 1 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page.cpp | 9 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp | 32 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_progress.cpp | 6 | ||||
-rw-r--r-- | core/src/fxge/agg/src/fx_agg_driver.cpp | 4 | ||||
-rw-r--r-- | core/src/fxge/dib/fx_dib_engine.cpp | 10 | ||||
-rw-r--r-- | core/src/fxge/ge/fx_ge_path.cpp | 6 | ||||
-rw-r--r-- | core/src/fxge/win32/fx_win32_gdipext.cpp | 5 | ||||
-rw-r--r-- | core/src/fxge/win32/fx_win32_print.cpp | 3 |
9 files changed, 37 insertions, 39 deletions
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h index 4eb217a094..920c821916 100644 --- a/core/include/fxcrt/fx_system.h +++ b/core/include/fxcrt/fx_system.h @@ -269,7 +269,6 @@ int64_t FXSYS_atoi64(const FX_CHAR* str); int64_t FXSYS_wtoi64(const FX_WCHAR* str); const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix); int FXSYS_round(FX_FLOAT f); -#define FXSYS_Div(a, b) ((a) / (b)) #define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c)) #define FXSYS_sqrt2(a, b) (FX_FLOAT) FXSYS_sqrt((a) * (a) + (b) * (b)) #ifdef __cplusplus diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp index 81cf92ee05..d589d5809f 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp @@ -752,11 +752,10 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, y2 = yPos; break; } - display_matrix.Set(FXSYS_Div((FX_FLOAT)(x2 - x0), m_PageWidth), - FXSYS_Div((FX_FLOAT)(y2 - y0), m_PageWidth), - FXSYS_Div((FX_FLOAT)(x1 - x0), m_PageHeight), - FXSYS_Div((FX_FLOAT)(y1 - y0), m_PageHeight), (FX_FLOAT)x0, - (FX_FLOAT)y0); + display_matrix.Set( + ((FX_FLOAT)(x2 - x0)) / m_PageWidth, ((FX_FLOAT)(y2 - y0)) / m_PageWidth, + ((FX_FLOAT)(x1 - x0)) / m_PageHeight, + ((FX_FLOAT)(y1 - y0)) / m_PageHeight, (FX_FLOAT)x0, (FX_FLOAT)y0); matrix = m_PageMatrix; matrix.Concat(display_matrix); } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index b9ff9f4750..43ce995f05 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -83,8 +83,8 @@ static void DrawAxialShading(CFX_DIBitmap* pBitmap, for (int column = 0; column < width; column++) { FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row; matrix.Transform(x, y); - FX_FLOAT scale = FXSYS_Div( - ((x - start_x) * x_span) + ((y - start_y) * y_span), axis_len_square); + FX_FLOAT scale = (((x - start_x) * x_span) + ((y - start_y) * y_span)) / + axis_len_square; int index = (int32_t)(scale * (SHADING_STEPS - 1)); if (index < 0) { if (!bStartExtend) { @@ -189,7 +189,7 @@ static void DrawRadialShading(CFX_DIBitmap* pBitmap, ((y - start_y) * (y - start_y)) - (start_r * start_r); FX_FLOAT s; if (a == 0) { - s = FXSYS_Div(-c, b); + s = -c / b; } else { FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); if (b2_4ac < 0) { @@ -198,11 +198,11 @@ static void DrawRadialShading(CFX_DIBitmap* pBitmap, FX_FLOAT root = FXSYS_sqrt(b2_4ac); FX_FLOAT s1, s2; if (a > 0) { - s1 = FXSYS_Div(-b - root, 2 * a); - s2 = FXSYS_Div(-b + root, 2 * a); + s1 = (-b - root) / (2 * a); + s2 = (-b + root) / (2 * a); } else { - s2 = FXSYS_Div(-b - root, 2 * a); - s1 = FXSYS_Div(-b + root, 2 * a); + s2 = (-b - root) / (2 * a); + s1 = (-b + root) / (2 * a); } if (bDecreasing) { if (s1 >= 0 || bStartExtend) { @@ -1044,14 +1044,16 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, mtDevice2Pattern.SetReverse(mtPattern2Device); CFX_FloatRect clip_box_p(clip_box); clip_box_p.Transform(&mtDevice2Pattern); - min_col = (int)FXSYS_ceil( - FXSYS_Div(clip_box_p.left - pPattern->m_BBox.right, pPattern->m_XStep)); - max_col = (int)FXSYS_floor( - FXSYS_Div(clip_box_p.right - pPattern->m_BBox.left, pPattern->m_XStep)); - min_row = (int)FXSYS_ceil( - FXSYS_Div(clip_box_p.bottom - pPattern->m_BBox.top, pPattern->m_YStep)); - max_row = (int)FXSYS_floor( - FXSYS_Div(clip_box_p.top - pPattern->m_BBox.bottom, pPattern->m_YStep)); + + min_col = (int)FXSYS_ceil((clip_box_p.left - pPattern->m_BBox.right) / + pPattern->m_XStep); + max_col = (int)FXSYS_floor((clip_box_p.right - pPattern->m_BBox.left) / + pPattern->m_XStep); + min_row = (int)FXSYS_ceil((clip_box_p.bottom - pPattern->m_BBox.top) / + pPattern->m_YStep); + max_row = (int)FXSYS_floor((clip_box_p.top - pPattern->m_BBox.bottom) / + pPattern->m_YStep); + if (width > clip_box.Width() || height > clip_box.Height() || width * height > clip_box.Width() * clip_box.Height()) { CPDF_GraphicStates* pStates = NULL; diff --git a/core/src/fxcodec/codec/fx_codec_progress.cpp b/core/src/fxcodec/codec/fx_codec_progress.cpp index 2e9b1dce3e..1b46c4eb22 100644 --- a/core/src/fxcodec/codec/fx_codec_progress.cpp +++ b/core/src/fxcodec/codec/fx_codec_progress.cpp @@ -18,7 +18,7 @@ void CFXCODEC_WeightTable::Calc(int dest_len, FX_Free(m_pWeightTables); } double scale, base; - scale = FXSYS_Div((FX_FLOAT)(src_len), (FX_FLOAT)(dest_len)); + scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; if (dest_len < 0) { base = (FX_FLOAT)(src_len); } else { @@ -88,8 +88,8 @@ void CFXCODEC_WeightTable::Calc(int dest_len, pixel_weights.m_SrcStart = start_i; pixel_weights.m_SrcEnd = end_i; for (int j = start_i; j <= end_i; j++) { - double dest_start = FXSYS_Div((FX_FLOAT)(j)-base, scale); - double dest_end = FXSYS_Div((FX_FLOAT)(j + 1) - base, scale); + double dest_start = ((FX_FLOAT)j - base) / scale; + double dest_end = ((FX_FLOAT)(j + 1) - base) / scale; if (dest_start > dest_end) { double temp = dest_start; dest_start = dest_end; diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp index 50062541b1..8b0e3f94f4 100644 --- a/core/src/fxge/agg/src/fx_agg_driver.cpp +++ b/core/src/fxge/agg/src/fx_agg_driver.cpp @@ -144,8 +144,8 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, FX_FLOAT width = pGraphState->m_LineWidth * scale; FX_FLOAT unit = 1.f; if (pObject2Device) { - unit = FXSYS_Div( - 1.0f, (pObject2Device->GetXUnit() + pObject2Device->GetYUnit()) / 2); + unit = + 1.0f / ((pObject2Device->GetXUnit() + pObject2Device->GetYUnit()) / 2); } if (width < unit) { width = unit; diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp index 47fca79846..322040539e 100644 --- a/core/src/fxge/dib/fx_dib_engine.cpp +++ b/core/src/fxge/dib/fx_dib_engine.cpp @@ -20,7 +20,7 @@ void CWeightTable::Calc(int dest_len, FX_Free(m_pWeightTables); m_pWeightTables = NULL; double scale, base; - scale = FXSYS_Div((FX_FLOAT)(src_len), (FX_FLOAT)(dest_len)); + scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; if (dest_len < 0) { base = (FX_FLOAT)(src_len); } else { @@ -188,8 +188,8 @@ void CWeightTable::Calc(int dest_len, pixel_weights.m_SrcStart = start_i; pixel_weights.m_SrcEnd = end_i; for (int j = start_i; j <= end_i; j++) { - double dest_start = FXSYS_Div((FX_FLOAT)(j)-base, scale); - double dest_end = FXSYS_Div((FX_FLOAT)(j + 1) - base, scale); + double dest_start = ((FX_FLOAT)j - base) / scale; + double dest_end = ((FX_FLOAT)(j + 1) - base) / scale; if (dest_start > dest_end) { double temp = dest_start; dest_start = dest_end; @@ -270,8 +270,8 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, m_Flags |= FXDIB_DOWNSAMPLE; } } - double scale_x = FXSYS_Div((FX_FLOAT)(m_SrcWidth), (FX_FLOAT)(m_DestWidth)); - double scale_y = FXSYS_Div((FX_FLOAT)(m_SrcHeight), (FX_FLOAT)(m_DestHeight)); + double scale_x = (FX_FLOAT)m_SrcWidth / (FX_FLOAT)m_DestWidth; + double scale_y = (FX_FLOAT)m_SrcHeight / (FX_FLOAT)m_DestHeight; double base_x = m_DestWidth > 0 ? 0.0f : (FX_FLOAT)(m_DestWidth); double base_y = m_DestHeight > 0 ? 0.0f : (FX_FLOAT)(m_DestHeight); double src_left = scale_x * ((FX_FLOAT)(clip_rect.left) + base_x); diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp index 0084f092d1..0c24c0ff64 100644 --- a/core/src/fxge/ge/fx_ge_path.cpp +++ b/core/src/fxge/ge/fx_ge_path.cpp @@ -263,14 +263,14 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect, return; } if (!bStartVert) { - start_k = FXSYS_Div(middle_y - start_y, middle_x - start_x); + start_k = (middle_y - start_y) / (middle_x - start_x); start_c = middle_y - (start_k * middle_x); start_len = FXSYS_sqrt2(start_x - middle_x, start_y - middle_y); start_dc = (FX_FLOAT)FXSYS_fabs( FXSYS_MulDiv(half_width, start_len, start_x - middle_x)); } if (!bEndVert) { - end_k = FXSYS_Div(end_y - middle_y, end_x - middle_x); + end_k = (end_y - middle_y) / (end_x - middle_x); end_c = middle_y - (end_k * middle_x); end_len = FXSYS_sqrt2(end_x - middle_x, end_y - middle_y); end_dc = (FX_FLOAT)FXSYS_fabs( @@ -331,7 +331,7 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect, } else { end_outside_c -= end_dc; } - FX_FLOAT join_x = FXSYS_Div(end_outside_c - start_outside_c, start_k - end_k); + FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); FX_FLOAT join_y = (start_k * join_x) + start_outside_c; rect.UpdateRect(join_x, join_y); } diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp index ce280948d7..e71d94d310 100644 --- a/core/src/fxge/win32/fx_win32_gdipext.cpp +++ b/core/src/fxge/win32/fx_win32_gdipext.cpp @@ -973,9 +973,8 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f; if (!bTextMode) { FX_FLOAT unit = - pMatrix - ? FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2) - : 1.0f; + pMatrix ? 1.0f / ((pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2) + : 1.0f; if (width < unit) { width = unit; } diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp index 4816c03e2c..6c262d83dc 100644 --- a/core/src/fxge/win32/fx_win32_print.cpp +++ b/core/src/fxge/win32/fx_win32_print.cpp @@ -149,8 +149,7 @@ static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc, uint8_t* src_buf = pSrcBitmap->GetBuffer(); FX_DWORD src_pitch = pSrcBitmap->GetPitch(); FX_FLOAT dest_area = pDestMatrix->GetUnitArea(); - FX_FLOAT area_scale = - FXSYS_Div((FX_FLOAT)(src_width * src_height), dest_area); + FX_FLOAT area_scale = ((FX_FLOAT)(src_width * src_height)) / dest_area; FX_FLOAT size_scale = FXSYS_sqrt(area_scale); CFX_Matrix adjusted_matrix(*pDestMatrix); adjusted_matrix.Scale(size_scale, size_scale); |