summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-02-23 16:31:44 -0500
committerDan Sinclair <dsinclair@chromium.org>2016-02-23 16:31:44 -0500
commit435604d371de48044ae6c1567479b34e0d93e298 (patch)
treede6a27714d545afc11d83283b79acb17477f5b7d /core
parentaffe4b09575b297747e66bd0b807d2b1b04822fe (diff)
downloadpdfium-435604d371de48044ae6c1567479b34e0d93e298.tar.xz
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 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fxcrt/fx_system.h1
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp16
-rw-r--r--core/src/fxge/ge/fx_ge_path.cpp7
3 files changed, 9 insertions, 15 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;