Use FXSYS_sqrt2() in more places.
Use FXSYS_sqrt2() rather than reimplementing it.
Change-Id: I6016f21be49cfccbb9d432217c4fc1f597b23fe5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83894
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/render/cpdf_rendershading.cpp b/core/fpdfapi/render/cpdf_rendershading.cpp
index 9a61113..eb51287 100644
--- a/core/fpdfapi/render/cpdf_rendershading.cpp
+++ b/core/fpdfapi/render/cpdf_rendershading.cpp
@@ -202,8 +202,7 @@
int height = pBitmap->GetHeight();
int pitch = pBitmap->GetPitch();
- bool bDecreasing =
- (dr < 0 && static_cast<int>(sqrt(dx * dx + dy * dy)) < -dr);
+ bool bDecreasing = dr < 0 && static_cast<int>(FXSYS_sqrt2(dx, dy)) < -dr;
CFX_Matrix matrix = mtObject2Bitmap.GetInverse();
for (int row = 0; row < height; row++) {
diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp
index ba5d92f..dbdb5de 100644
--- a/core/fxcrt/fx_coordinates.cpp
+++ b/core/fxcrt/fx_coordinates.cpp
@@ -413,7 +413,7 @@
return (a > 0 ? a : -a);
if (a == 0)
return (b > 0 ? b : -b);
- return sqrt(a * a + b * b);
+ return FXSYS_sqrt2(a, b);
}
float CFX_Matrix::GetYUnit() const {
@@ -421,7 +421,7 @@
return (d > 0 ? d : -d);
if (d == 0)
return (c > 0 ? c : -c);
- return sqrt(c * c + d * d);
+ return FXSYS_sqrt2(c, d);
}
CFX_FloatRect CFX_Matrix::GetUnitRect() const {
@@ -431,7 +431,7 @@
float CFX_Matrix::TransformXDistance(float dx) const {
float fx = a * dx;
float fy = b * dx;
- return sqrt(fx * fx + fy * fy);
+ return FXSYS_sqrt2(fx, fy);
}
float CFX_Matrix::TransformDistance(float distance) const {
diff --git a/xfa/fxfa/parser/cxfa_radial.cpp b/xfa/fxfa/parser/cxfa_radial.cpp
index 09f5fc2..7910868 100644
--- a/xfa/fxfa/parser/cxfa_radial.cpp
+++ b/xfa/fxfa/parser/cxfa_radial.cpp
@@ -66,10 +66,8 @@
if (!IsToEdge())
std::swap(crStart, crEnd);
- float endRadius = sqrt(rtFill.Width() * rtFill.Width() +
- rtFill.Height() * rtFill.Height()) /
- 2;
- CFGAS_GEShading shading(rtFill.Center(), rtFill.Center(), 0, endRadius, true,
+ float end_radius = FXSYS_sqrt2(rtFill.Width(), rtFill.Height()) / 2;
+ CFGAS_GEShading shading(rtFill.Center(), rtFill.Center(), 0, end_radius, true,
true, crStart, crEnd);
pGS->SaveGraphState();