summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-03 14:51:45 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-03 20:36:56 +0000
commit669a418f75c05d4a39e2bcaff2b7b93dec1c5764 (patch)
treeb76f5025c8e70b1ef449f317ff60a8eef7317ab9 /core/fpdfapi/render
parentac978f83392e309488601eb382d5f318b6d366ad (diff)
downloadpdfium-669a418f75c05d4a39e2bcaff2b7b93dec1c5764.tar.xz
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 <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_devicebuffer.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp7
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp81
-rw-r--r--core/fpdfapi/render/cpdf_type3cache.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_type3glyphs.cpp2
5 files changed, 46 insertions, 50 deletions
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp
index 67641676ae..605e09bb5b 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.cpp
+++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp
@@ -44,7 +44,7 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext,
}
#endif
CFX_Matrix ctm = m_pDevice->GetCTM();
- m_Matrix.Concat(CFX_Matrix(FXSYS_fabs(ctm.a), 0, 0, FXSYS_fabs(ctm.d), 0, 0));
+ m_Matrix.Concat(CFX_Matrix(fabs(ctm.a), 0, 0, fabs(ctm.d), 0, 0));
CFX_FloatRect rect(*pRect);
m_Matrix.TransformRect(rect);
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 858b3c83c6..c42c781dc2 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -433,8 +433,8 @@ bool CPDF_ImageRenderer::StartDIBSource() {
FX_RECT image_rect = image_rect_f.GetOuterRect();
int dest_width = image_rect.Width();
int dest_height = image_rect.Height();
- if ((FXSYS_fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) ||
- (FXSYS_fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) {
+ if ((fabs(m_ImageMatrix.b) >= 0.5f || m_ImageMatrix.a == 0) ||
+ (fabs(m_ImageMatrix.c) >= 0.5f || m_ImageMatrix.d == 0)) {
if (NotDrawing()) {
m_Result = false;
return false;
@@ -510,8 +510,7 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() {
else
pAlphaMask = m_pDIBSource->CloneAlphaMask();
- if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f ||
- FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) {
+ if (fabs(m_ImageMatrix.b) >= 0.5f || fabs(m_ImageMatrix.c) >= 0.5f) {
int left;
int top;
CFX_RetainPtr<CFX_DIBitmap> pTransformed =
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 5320422b41..f2d888bdeb 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -248,8 +248,8 @@ void DrawRadialShading(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap,
int pitch = pBitmap->GetPitch();
bool bDecreasing = false;
if (start_r > end_r) {
- int length = (int)FXSYS_sqrt((((start_x - end_x) * (start_x - end_x)) +
- ((start_y - end_y) * (start_y - end_y))));
+ int length = (int)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;
}
@@ -272,7 +272,7 @@ void DrawRadialShading(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap,
if (b2_4ac < 0) {
continue;
}
- float root = FXSYS_sqrt(b2_4ac);
+ float root = sqrt(b2_4ac);
float s1, s2;
if (a > 0) {
s1 = (-b - root) / (2 * a);
@@ -403,8 +403,8 @@ void DrawGouraud(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap,
if (min_y == max_y)
return;
- int min_yi = std::max(static_cast<int>(FXSYS_floor(min_y)), 0);
- int max_yi = static_cast<int>(FXSYS_ceil(max_y));
+ int min_yi = std::max(static_cast<int>(floor(min_y)), 0);
+ int max_yi = static_cast<int>(ceil(max_y));
if (max_yi >= pBitmap->GetHeight())
max_yi = pBitmap->GetHeight() - 1;
@@ -436,13 +436,13 @@ void DrawGouraud(const CFX_RetainPtr<CFX_DIBitmap>& pBitmap,
int min_x, max_x, start_index, end_index;
if (inter_x[0] < inter_x[1]) {
- min_x = (int)FXSYS_floor(inter_x[0]);
- max_x = (int)FXSYS_ceil(inter_x[1]);
+ min_x = (int)floor(inter_x[0]);
+ max_x = (int)ceil(inter_x[1]);
start_index = 0;
end_index = 1;
} else {
- min_x = (int)FXSYS_floor(inter_x[1]);
- max_x = (int)FXSYS_ceil(inter_x[0]);
+ min_x = (int)floor(inter_x[1]);
+ max_x = (int)ceil(inter_x[0]);
start_index = 1;
end_index = 0;
}
@@ -701,9 +701,8 @@ struct Coon_Color {
}
int Distance(Coon_Color& o) {
- return std::max({FXSYS_abs(comp[0] - o.comp[0]),
- FXSYS_abs(comp[1] - o.comp[1]),
- FXSYS_abs(comp[2] - o.comp[2])});
+ return std::max({abs(comp[0] - o.comp[0]), abs(comp[1] - o.comp[1]),
+ abs(comp[2] - o.comp[2])});
}
};
@@ -1130,15 +1129,13 @@ bool CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj,
FX_RECT rtClip = m_pDevice->GetClipBox();
if (!bLogical) {
CFX_Matrix dCTM = m_pDevice->GetCTM();
- float a = FXSYS_fabs(dCTM.a);
- float d = FXSYS_fabs(dCTM.d);
+ float a = fabs(dCTM.a);
+ float d = fabs(dCTM.d);
if (a != 1.0f || d != 1.0f) {
- rect.right = rect.left + (int32_t)FXSYS_ceil((float)rect.Width() * a);
- rect.bottom = rect.top + (int32_t)FXSYS_ceil((float)rect.Height() * d);
- rtClip.right =
- rtClip.left + (int32_t)FXSYS_ceil((float)rtClip.Width() * a);
- rtClip.bottom =
- rtClip.top + (int32_t)FXSYS_ceil((float)rtClip.Height() * d);
+ rect.right = rect.left + (int32_t)ceil((float)rect.Width() * a);
+ rect.bottom = rect.top + (int32_t)ceil((float)rect.Height() * d);
+ rtClip.right = rtClip.left + (int32_t)ceil((float)rtClip.Width() * a);
+ rtClip.bottom = rtClip.top + (int32_t)ceil((float)rtClip.Height() * d);
}
}
rect.Intersect(rtClip);
@@ -1196,8 +1193,8 @@ bool CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj,
void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix& matrix) const {
CFX_Matrix dCTM = m_pDevice->GetCTM();
- matrix.a *= FXSYS_fabs(dCTM.a);
- matrix.d *= FXSYS_fabs(dCTM.d);
+ matrix.a *= fabs(dCTM.a);
+ matrix.d *= fabs(dCTM.d);
}
void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj,
@@ -1534,8 +1531,8 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
return true;
CFX_Matrix deviceCTM = m_pDevice->GetCTM();
- float scaleX = FXSYS_fabs(deviceCTM.a);
- float scaleY = FXSYS_fabs(deviceCTM.d);
+ float scaleX = fabs(deviceCTM.a);
+ float scaleY = fabs(deviceCTM.d);
int width = FXSYS_round((float)rect.Width() * scaleX);
int height = FXSYS_round((float)rect.Height() * scaleY);
CFX_FxgeDevice bitmap_device;
@@ -1631,8 +1628,8 @@ CFX_RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::GetBackdrop(
left = bbox.left;
top = bbox.top;
CFX_Matrix deviceCTM = m_pDevice->GetCTM();
- float scaleX = FXSYS_fabs(deviceCTM.a);
- float scaleY = FXSYS_fabs(deviceCTM.d);
+ float scaleX = fabs(deviceCTM.a);
+ float scaleY = fabs(deviceCTM.d);
int width = FXSYS_round(bbox.Width() * scaleX);
int height = FXSYS_round(bbox.Height() * scaleY);
auto pBackdrop = pdfium::MakeRetain<CFX_DIBitmap>();
@@ -1813,8 +1810,8 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
return true;
CFX_Matrix dCTM = m_pDevice->GetCTM();
- float sa = FXSYS_fabs(dCTM.a);
- float sd = FXSYS_fabs(dCTM.d);
+ float sa = fabs(dCTM.a);
+ float sd = fabs(dCTM.d);
CFX_Matrix text_matrix = textobj->GetTextMatrix();
CFX_Matrix char_matrix = pType3Font->GetFontMatrix();
float font_size = textobj->m_TextState.GetFontSize();
@@ -2196,10 +2193,10 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
return;
}
CFX_Matrix dCTM = m_pDevice->GetCTM();
- float sa = FXSYS_fabs(dCTM.a);
- float sd = FXSYS_fabs(dCTM.d);
- clip_box.right = clip_box.left + (int32_t)FXSYS_ceil(clip_box.Width() * sa);
- clip_box.bottom = clip_box.top + (int32_t)FXSYS_ceil(clip_box.Height() * sd);
+ float sa = fabs(dCTM.a);
+ float sd = fabs(dCTM.d);
+ clip_box.right = clip_box.left + (int32_t)ceil(clip_box.Width() * sa);
+ clip_box.bottom = clip_box.top + (int32_t)ceil(clip_box.Height() * sd);
CFX_Matrix mtPattern2Device = *pPattern->pattern_to_form();
mtPattern2Device.Concat(*pObj2Device);
GetScaledMatrix(mtPattern2Device);
@@ -2212,8 +2209,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
}
CFX_FloatRect cell_bbox = pPattern->bbox();
mtPattern2Device.TransformRect(cell_bbox);
- int width = (int)FXSYS_ceil(cell_bbox.Width());
- int height = (int)FXSYS_ceil(cell_bbox.Height());
+ int width = (int)ceil(cell_bbox.Width());
+ int height = (int)ceil(cell_bbox.Height());
if (width == 0) {
width = 1;
}
@@ -2227,14 +2224,14 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
CFX_FloatRect clip_box_p(clip_box);
mtDevice2Pattern.TransformRect(clip_box_p);
- min_col = (int)FXSYS_ceil((clip_box_p.left - pPattern->bbox().right) /
- pPattern->x_step());
- max_col = (int)FXSYS_floor((clip_box_p.right - pPattern->bbox().left) /
- pPattern->x_step());
- min_row = (int)FXSYS_ceil((clip_box_p.bottom - pPattern->bbox().top) /
- pPattern->y_step());
- max_row = (int)FXSYS_floor((clip_box_p.top - pPattern->bbox().bottom) /
- pPattern->y_step());
+ min_col = (int)ceil((clip_box_p.left - pPattern->bbox().right) /
+ pPattern->x_step());
+ max_col = (int)floor((clip_box_p.right - pPattern->bbox().left) /
+ pPattern->x_step());
+ min_row = (int)ceil((clip_box_p.bottom - pPattern->bbox().top) /
+ pPattern->y_step());
+ max_row = (int)floor((clip_box_p.top - pPattern->bbox().bottom) /
+ pPattern->y_step());
if (width > clip_box.Width() || height > clip_box.Height() ||
width * height > clip_box.Width() * clip_box.Height()) {
diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp
index 1ba9f66203..d11103d014 100644
--- a/core/fpdfapi/render/cpdf_type3cache.cpp
+++ b/core/fpdfapi/render/cpdf_type3cache.cpp
@@ -131,8 +131,8 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize,
CFX_RetainPtr<CFX_DIBitmap> pResBitmap;
int left = 0;
int top = 0;
- if (FXSYS_fabs(image_matrix.b) < FXSYS_fabs(image_matrix.a) / 100 &&
- FXSYS_fabs(image_matrix.c) < FXSYS_fabs(image_matrix.d) / 100) {
+ if (fabs(image_matrix.b) < fabs(image_matrix.a) / 100 &&
+ fabs(image_matrix.c) < fabs(image_matrix.d) / 100) {
int top_line = DetectFirstLastScan(pBitmap, true);
int bottom_line = DetectFirstLastScan(pBitmap, false);
if (top_line == 0 && bottom_line == pBitmap->GetHeight() - 1) {
diff --git a/core/fpdfapi/render/cpdf_type3glyphs.cpp b/core/fpdfapi/render/cpdf_type3glyphs.cpp
index 33d8ef1253..5fce32ce93 100644
--- a/core/fpdfapi/render/cpdf_type3glyphs.cpp
+++ b/core/fpdfapi/render/cpdf_type3glyphs.cpp
@@ -22,7 +22,7 @@ static int _AdjustBlue(float pos, int& count, int blues[]) {
float min_distance = 1000000.0f;
int closest_pos = -1;
for (int i = 0; i < count; i++) {
- float distance = FXSYS_fabs(pos - static_cast<float>(blues[i]));
+ float distance = fabs(pos - static_cast<float>(blues[i]));
if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) {
min_distance = distance;
closest_pos = i;