From 435604d371de48044ae6c1567479b34e0d93e298 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 23 Feb 2016 16:31:44 -0500 Subject: Remove FXSYS_MulDiv(a, b, c). This is a wrapper which does (a) * (b) / (c). Inline the operations. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1726893002 . --- core/include/fxcrt/fx_system.h | 1 - core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp | 16 ++++++---------- core/src/fxge/ge/fx_ge_path.cpp | 7 +++---- third_party/agg23/agg_math.h | 6 +++--- third_party/agg23/agg_math_stroke.h | 8 ++++---- third_party/agg23/agg_vcgen_stroke.cpp | 15 +++++++-------- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h index 920c821916..8471610864 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_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_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 43ce995f05..4ad6f81d5e 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -319,7 +319,7 @@ FX_BOOL _GetScanlineIntersect(int y, return FALSE; } } - x = x1 + FXSYS_MulDiv(x2 - x1, y - y1, y2 - y1); + x = x1 + ((x2 - x1) * (y - y1) / (y2 - y1)); return TRUE; } static void DrawGouraud(CFX_DIBitmap* pBitmap, @@ -355,15 +355,11 @@ static void DrawGouraud(CFX_DIBitmap* pBitmap, if (!bIntersect) { continue; } - r[nIntersects] = - vertex1.r + FXSYS_MulDiv(vertex2.r - vertex1.r, y - vertex1.y, - vertex2.y - vertex1.y); - g[nIntersects] = - vertex1.g + FXSYS_MulDiv(vertex2.g - vertex1.g, y - vertex1.y, - vertex2.y - vertex1.y); - b[nIntersects] = - vertex1.b + FXSYS_MulDiv(vertex2.b - vertex1.b, y - vertex1.y, - vertex2.y - vertex1.y); + + FX_FLOAT y_dist = (y - vertex1.y) / (vertex2.y - vertex1.y); + r[nIntersects] = vertex1.r + ((vertex2.r - vertex1.r) * y_dist); + g[nIntersects] = vertex1.g + ((vertex2.g - vertex1.g) * y_dist); + b[nIntersects] = vertex1.b + ((vertex2.b - vertex1.b) * y_dist); nIntersects++; } if (nIntersects != 2) { diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp index 0c24c0ff64..0b52cdf9e4 100644 --- a/core/src/fxge/ge/fx_ge_path.cpp +++ b/core/src/fxge/ge/fx_ge_path.cpp @@ -266,15 +266,14 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect, 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)); + start_dc = + (FX_FLOAT)FXSYS_fabs(half_width * start_len / (start_x - middle_x)); } if (!bEndVert) { 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( - FXSYS_MulDiv(half_width, end_len, end_x - middle_x)); + end_dc = (FX_FLOAT)FXSYS_fabs(half_width * end_len / (end_x - middle_x)); } if (bStartVert) { FX_FLOAT outside_x = start_x; diff --git a/third_party/agg23/agg_math.h b/third_party/agg23/agg_math.h index c0d9570aa9..e003297dff 100644 --- a/third_party/agg23/agg_math.h +++ b/third_party/agg23/agg_math.h @@ -44,7 +44,7 @@ AGG_INLINE FX_FLOAT calc_line_point_distance(FX_FLOAT x1, FX_FLOAT y1, if(d < intersection_epsilon) { return calc_distance(x1, y1, x, y); } - return FXSYS_MulDiv(x - x2, dy, d) - FXSYS_MulDiv(y - y2, dx, d); + return ((x - x2) * dy / d) - ((y - y2) * dx / d); } AGG_INLINE bool calc_intersection(FX_FLOAT ax, FX_FLOAT ay, FX_FLOAT bx, FX_FLOAT by, FX_FLOAT cx, FX_FLOAT cy, FX_FLOAT dx, FX_FLOAT dy, @@ -55,8 +55,8 @@ AGG_INLINE bool calc_intersection(FX_FLOAT ax, FX_FLOAT ay, FX_FLOAT bx, FX_FLOA if (FXSYS_fabs(den) < intersection_epsilon) { return false; } - *x = ax + FXSYS_MulDiv(bx - ax, num, den); - *y = ay + FXSYS_MulDiv(by - ay, num, den); + *x = ax + ((bx - ax) * num / den); + *y = ay + ((by - ay) * num / den); return true; } } diff --git a/third_party/agg23/agg_math_stroke.h b/third_party/agg23/agg_math_stroke.h index 402028ba67..6d7ba8a96e 100644 --- a/third_party/agg23/agg_math_stroke.h +++ b/third_party/agg23/agg_math_stroke.h @@ -198,10 +198,10 @@ void stroke_calc_join(VertexConsumer& out_vertices, { typedef typename VertexConsumer::value_type coord_type; FX_FLOAT dx1, dy1, dx2, dy2; - dx1 = FXSYS_MulDiv(width, v1.y - v0.y, len1); - dy1 = FXSYS_MulDiv(width, v1.x - v0.x, len1); - dx2 = FXSYS_MulDiv(width, v2.y - v1.y, len2); - dy2 = FXSYS_MulDiv(width, v2.x - v1.x, len2); + dx1 = width * (v1.y - v0.y) / len1; + dy1 = width * (v1.x - v0.x) / len1; + dx2 = width * (v2.y - v1.y) / len2; + dy2 = width * (v2.x - v1.x) / len2; out_vertices.remove_all(); if(calc_point_location(v0.x, v0.y, v1.x, v1.y, v2.x, v2.y) > 0) { switch(inner_join) { diff --git a/third_party/agg23/agg_vcgen_stroke.cpp b/third_party/agg23/agg_vcgen_stroke.cpp index ef8bc27864..afc4ee6f9b 100644 --- a/third_party/agg23/agg_vcgen_stroke.cpp +++ b/third_party/agg23/agg_vcgen_stroke.cpp @@ -68,14 +68,13 @@ static inline void calc_butt_cap(FX_FLOAT* cap, const vertex_dist& v0, const vertex_dist& v1, FX_FLOAT len, - FX_FLOAT width) -{ - FX_FLOAT dx = FXSYS_MulDiv(v1.y - v0.y, width, len); - FX_FLOAT dy = FXSYS_MulDiv(v1.x - v0.x, width, len); - cap[0] = v0.x - dx; - cap[1] = v0.y + dy; - cap[2] = v0.x + dx; - cap[3] = v0.y - dy; + FX_FLOAT width) { + FX_FLOAT dx = (v1.y - v0.y) * width / len; + FX_FLOAT dy = (v1.x - v0.x) * width / len; + cap[0] = v0.x - dx; + cap[1] = v0.y + dy; + cap[2] = v0.x + dx; + cap[3] = v0.y - dy; } void vcgen_stroke::rewind(unsigned) { -- cgit v1.2.3