summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-02-23 15:23:29 -0500
committerDan Sinclair <dsinclair@chromium.org>2016-02-23 15:23:29 -0500
commit2c8fad44315db58f5b3222161dcb699691dca904 (patch)
tree70e9bdf55e1e3197d8bd088abd103012b602e32f /core
parent2886a25b68225ad3ad70d417b01108ad1d126488 (diff)
downloadpdfium-2c8fad44315db58f5b3222161dcb699691dca904.tar.xz
Remove FXSYS_Mul.
This define just multiples the two parameters together. Inline the *'s. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1729613003 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fxcrt/fx_system.h1
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font.cpp13
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page.cpp4
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp8
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp15
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp29
-rw-r--r--core/src/fxge/dib/fx_dib_engine.cpp8
-rw-r--r--core/src/fxge/ge/fx_ge_path.cpp22
-rw-r--r--core/src/fxge/win32/fx_win32_gdipext.cpp2
9 files changed, 45 insertions, 57 deletions
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index 41dc4468a6..4eb217a094 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_Mul(a, b) ((a) * (b))
#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))
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 87c95c668e..1e9335f30f 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -1569,13 +1569,10 @@ FX_BOOL CPDF_Type3Font::_Load() {
}
CPDF_Array* pBBox = m_pFontDict->GetArrayBy("FontBBox");
if (pBBox) {
- m_FontBBox.left =
- (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(0), xscale) * 1000);
- m_FontBBox.bottom =
- (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(1), yscale) * 1000);
- m_FontBBox.right =
- (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(2), xscale) * 1000);
- m_FontBBox.top = (int32_t)(FXSYS_Mul(pBBox->GetNumberAt(3), yscale) * 1000);
+ m_FontBBox.left = (int32_t)(pBBox->GetNumberAt(0) * xscale * 1000);
+ m_FontBBox.bottom = (int32_t)(pBBox->GetNumberAt(1) * yscale * 1000);
+ m_FontBBox.right = (int32_t)(pBBox->GetNumberAt(2) * xscale * 1000);
+ m_FontBBox.top = (int32_t)(pBBox->GetNumberAt(3) * yscale * 1000);
}
int StartChar = m_pFontDict->GetIntegerBy("FirstChar");
CPDF_Array* pWidthArray = m_pFontDict->GetArrayBy("Widths");
@@ -1589,7 +1586,7 @@ FX_BOOL CPDF_Type3Font::_Load() {
}
for (FX_DWORD i = 0; i < count; i++) {
m_CharWidthL[StartChar + i] =
- FXSYS_round(FXSYS_Mul(pWidthArray->GetNumberAt(i), xscale) * 1000);
+ FXSYS_round(pWidthArray->GetNumberAt(i) * xscale * 1000);
}
}
m_pCharProcs = m_pFontDict->GetDictBy("CharProcs");
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index be038004ac..81cf92ee05 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -246,7 +246,7 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
m_nChars == 1 ? (FX_DWORD)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
if (i > 0) {
if (charcode == (FX_DWORD)-1) {
- curpos -= FXSYS_Mul(m_pCharPos[i - 1], fontsize) / 1000;
+ curpos -= (m_pCharPos[i - 1] * fontsize) / 1000;
continue;
}
m_pCharPos[i - 1] = curpos;
@@ -336,7 +336,7 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
max_x = max_x * fontsize / 1000;
} else {
if (pTextAdvanceX) {
- *pTextAdvanceX = FXSYS_Mul(curpos, horz_scale);
+ *pTextAdvanceX = curpos * horz_scale;
}
if (pTextAdvanceY) {
*pTextAdvanceY = 0;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index bee4a5b707..de3a6572f2 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -315,13 +315,13 @@ void CPDF_TextState::SetFont(CPDF_Font* pFont) {
FX_FLOAT CPDF_TextState::GetFontSizeV() const {
FX_FLOAT* pMatrix = GetMatrix();
FX_FLOAT unit = FXSYS_sqrt2(pMatrix[1], pMatrix[3]);
- FX_FLOAT size = FXSYS_Mul(unit, GetFontSize());
+ FX_FLOAT size = unit * GetFontSize();
return (FX_FLOAT)FXSYS_fabs(size);
}
FX_FLOAT CPDF_TextState::GetFontSizeH() const {
FX_FLOAT* pMatrix = GetMatrix();
FX_FLOAT unit = FXSYS_sqrt2(pMatrix[0], pMatrix[2]);
- FX_FLOAT size = FXSYS_Mul(unit, GetFontSize());
+ FX_FLOAT size = unit * GetFontSize();
return (FX_FLOAT)FXSYS_fabs(size);
}
FX_FLOAT CPDF_TextState::GetBaselineAngle() const {
@@ -449,10 +449,10 @@ void CPDF_AllStates::SetLineDash(CPDF_Array* pArray,
FX_FLOAT phase,
FX_FLOAT scale) {
CFX_GraphStateData* pData = m_GraphState.GetModify();
- pData->m_DashPhase = FXSYS_Mul(phase, scale);
+ pData->m_DashPhase = phase * scale;
pData->SetDashCount(pArray->GetCount());
for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
- pData->m_DashArray[i] = FXSYS_Mul(pArray->GetNumberAt(i), scale);
+ pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale;
}
}
void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index efe0f25a9f..fe07a63bca 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -1351,12 +1351,10 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
if (fInitKerning != 0) {
if (!pFont->IsVertWriting()) {
m_pCurStates->m_TextX -=
- FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) /
- 1000;
+ (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000;
} else {
m_pCurStates->m_TextY -=
- FXSYS_Mul(fInitKerning, m_pCurStates->m_TextState.GetFontSize()) /
- 1000;
+ (fInitKerning * m_pCurStates->m_TextState.GetFontSize()) / 1000;
}
}
if (nsegs == 0) {
@@ -1396,13 +1394,11 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
if (pKerning && pKerning[nsegs - 1] != 0) {
if (!pFont->IsVertWriting()) {
m_pCurStates->m_TextX -=
- FXSYS_Mul(pKerning[nsegs - 1],
- m_pCurStates->m_TextState.GetFontSize()) /
+ (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) /
1000;
} else {
m_pCurStates->m_TextY -=
- FXSYS_Mul(pKerning[nsegs - 1],
- m_pCurStates->m_TextState.GetFontSize()) /
+ (pKerning[nsegs - 1] * m_pCurStates->m_TextState.GetFontSize()) /
1000;
}
}
@@ -1430,8 +1426,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
if (nsegs == 0) {
for (int i = 0; i < n; i++) {
m_pCurStates->m_TextX -=
- FXSYS_Mul(pArray->GetNumberAt(i),
- m_pCurStates->m_TextState.GetFontSize()) /
+ (pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) /
1000;
}
return;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index f4ade7d48d..b9ff9f4750 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -44,8 +44,7 @@ static void DrawAxialShading(CFX_DIBitmap* pBitmap,
int height = pBitmap->GetHeight();
FX_FLOAT x_span = end_x - start_x;
FX_FLOAT y_span = end_y - start_y;
- FX_FLOAT axis_len_square =
- FXSYS_Mul(x_span, x_span) + FXSYS_Mul(y_span, y_span);
+ FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span);
CFX_Matrix matrix;
matrix.SetReverse(*pObject2Bitmap);
int total_results = 0;
@@ -85,8 +84,7 @@ static void DrawAxialShading(CFX_DIBitmap* pBitmap,
FX_FLOAT x = (FX_FLOAT)column, y = (FX_FLOAT)row;
matrix.Transform(x, y);
FX_FLOAT scale = FXSYS_Div(
- FXSYS_Mul(x - start_x, x_span) + FXSYS_Mul(y - start_y, y_span),
- axis_len_square);
+ ((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) {
@@ -165,16 +163,16 @@ static void DrawRadialShading(CFX_DIBitmap* pBitmap,
FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255),
FXSYS_round(G * 255), FXSYS_round(B * 255)));
}
- FX_FLOAT a = FXSYS_Mul(start_x - end_x, start_x - end_x) +
- FXSYS_Mul(start_y - end_y, start_y - end_y) -
- FXSYS_Mul(start_r - end_r, start_r - end_r);
+ FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) +
+ ((start_y - end_y) * (start_y - end_y)) -
+ ((start_r - end_r) * (start_r - end_r));
int width = pBitmap->GetWidth();
int height = pBitmap->GetHeight();
int pitch = pBitmap->GetPitch();
FX_BOOL bDecreasing = FALSE;
if (start_r > end_r) {
- int length = (int)FXSYS_sqrt((FXSYS_Mul(start_x - end_x, start_x - end_x) +
- FXSYS_Mul(start_y - end_y, start_y - end_y)));
+ int length = (int)FXSYS_sqrt((((start_x - end_x) * (start_x - end_x)) +
+ ((start_y - end_y) * (start_y - end_y))));
if (length < start_r - end_r) {
bDecreasing = TRUE;
}
@@ -184,17 +182,16 @@ static void DrawRadialShading(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 b = -2 * (FXSYS_Mul(x - start_x, end_x - start_x) +
- FXSYS_Mul(y - start_y, end_y - start_y) +
- FXSYS_Mul(start_r, end_r - start_r));
- FX_FLOAT c = FXSYS_Mul(x - start_x, x - start_x) +
- FXSYS_Mul(y - start_y, y - start_y) -
- FXSYS_Mul(start_r, start_r);
+ FX_FLOAT b = -2 * (((x - start_x) * (end_x - start_x)) +
+ ((y - start_y) * (end_y - start_y)) +
+ (start_r * (end_r - start_r)));
+ FX_FLOAT c = ((x - start_x) * (x - start_x)) +
+ ((y - start_y) * (y - start_y)) - (start_r * start_r);
FX_FLOAT s;
if (a == 0) {
s = FXSYS_Div(-c, b);
} else {
- FX_FLOAT b2_4ac = FXSYS_Mul(b, b) - 4 * FXSYS_Mul(a, c);
+ FX_FLOAT b2_4ac = (b * b) - 4 * (a * c);
if (b2_4ac < 0) {
continue;
}
diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp
index de56567c51..47fca79846 100644
--- a/core/src/fxge/dib/fx_dib_engine.cpp
+++ b/core/src/fxge/dib/fx_dib_engine.cpp
@@ -274,10 +274,10 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap,
double scale_y = FXSYS_Div((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 = FXSYS_Mul(scale_x, (FX_FLOAT)(clip_rect.left) + base_x);
- double src_right = FXSYS_Mul(scale_x, (FX_FLOAT)(clip_rect.right) + base_x);
- double src_top = FXSYS_Mul(scale_y, (FX_FLOAT)(clip_rect.top) + base_y);
- double src_bottom = FXSYS_Mul(scale_y, (FX_FLOAT)(clip_rect.bottom) + base_y);
+ double src_left = scale_x * ((FX_FLOAT)(clip_rect.left) + base_x);
+ double src_right = scale_x * ((FX_FLOAT)(clip_rect.right) + base_x);
+ double src_top = scale_y * ((FX_FLOAT)(clip_rect.top) + base_y);
+ double src_bottom = scale_y * ((FX_FLOAT)(clip_rect.bottom) + base_y);
if (src_left > src_right) {
double temp = src_left;
src_left = src_right;
diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp
index 23b1c2fe07..0084f092d1 100644
--- a/core/src/fxge/ge/fx_ge_path.cpp
+++ b/core/src/fxge/ge/fx_ge_path.cpp
@@ -264,14 +264,14 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
}
if (!bStartVert) {
start_k = FXSYS_Div(middle_y - start_y, middle_x - start_x);
- start_c = middle_y - FXSYS_Mul(start_k, middle_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_c = middle_y - FXSYS_Mul(end_k, 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));
@@ -284,10 +284,10 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
outside_x -= half_width;
}
FX_FLOAT outside_y;
- if (start_y < FXSYS_Mul(end_k, start_x) + end_c) {
- outside_y = FXSYS_Mul(end_k, outside_x) + end_c + end_dc;
+ if (start_y < (end_k * start_x) + end_c) {
+ outside_y = (end_k * outside_x) + end_c + end_dc;
} else {
- outside_y = FXSYS_Mul(end_k, outside_x) + end_c - end_dc;
+ outside_y = (end_k * outside_x) + end_c - end_dc;
}
rect.UpdateRect(outside_x, outside_y);
return;
@@ -300,10 +300,10 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
outside_x -= half_width;
}
FX_FLOAT outside_y;
- if (end_y < FXSYS_Mul(start_k, end_x) + start_c) {
- outside_y = FXSYS_Mul(start_k, outside_x) + start_c + start_dc;
+ if (end_y < (start_k * end_x) + start_c) {
+ outside_y = (start_k * outside_x) + start_c + start_dc;
} else {
- outside_y = FXSYS_Mul(start_k, outside_x) + start_c - start_dc;
+ outside_y = (start_k * outside_x) + start_c - start_dc;
}
rect.UpdateRect(outside_x, outside_y);
return;
@@ -320,19 +320,19 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
return;
}
FX_FLOAT start_outside_c = start_c;
- if (end_y < FXSYS_Mul(start_k, end_x) + start_c) {
+ if (end_y < (start_k * end_x) + start_c) {
start_outside_c += start_dc;
} else {
start_outside_c -= start_dc;
}
FX_FLOAT end_outside_c = end_c;
- if (start_y < FXSYS_Mul(end_k, start_x) + end_c) {
+ if (start_y < (end_k * start_x) + end_c) {
end_outside_c += end_dc;
} 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_y = FXSYS_Mul(start_k, join_x) + start_outside_c;
+ FX_FLOAT join_y = (start_k * join_x) + start_outside_c;
rect.UpdateRect(join_x, join_y);
}
CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp
index aaf7c36919..ce280948d7 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -1087,7 +1087,7 @@ static FX_BOOL IsSmallTriangle(PointF* points,
}
FX_FLOAT dx = x1 - x2;
FX_FLOAT dy = y1 - y2;
- FX_FLOAT distance_square = FXSYS_Mul(dx, dx) + FXSYS_Mul(dy, dy);
+ FX_FLOAT distance_square = (dx * dx) + (dy * dy);
if (distance_square < (1.0f * 2 + 1.0f / 4)) {
v1 = i;
v2 = pair1;