Commit 92c1584c authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Stop using M_PI in ash/ and chrome/.

Use constants from base/numerics/math_constants.h instead. Do IWYU and
remove some unnecessary casting along the way.

Change-Id: Iee15ae1d99c643c3950d085f02cda72c64c71ea5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1827243Reviewed-by: default avatarVladislav Kaznacheev <kaznacheev@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700438}
parent c5fa92de
......@@ -4,10 +4,11 @@
#include "ash/highlighter/highlighter_gesture_util.h"
#include "ash/components/fast_ink/fast_ink_points.h"
#include <cmath>
#include "ash/components/fast_ink/fast_ink_points.h"
#include "base/numerics/math_constants.h"
namespace ash {
namespace {
......@@ -16,7 +17,7 @@ constexpr float kHorizontalStrokeLengthThreshold = 20;
constexpr float kHorizontalStrokeThicknessThreshold = 2;
constexpr float kHorizontalStrokeFlatnessThreshold = 0.1;
constexpr double kClosedShapeSweepThreshold = M_PI * 2 * 0.8;
constexpr double kClosedShapeSweepThreshold = base::kPiDouble * 2 * 0.8;
constexpr double kClosedShapeJiggleThreshold = 0.1;
bool DetectHorizontalStroke(const gfx::RectF& box,
......@@ -49,10 +50,10 @@ bool DetectClosedShape(const gfx::RectF& box,
atan2(point.location.y() - center.y(), point.location.x() - center.x());
if (has_prev_angle) {
double diff_angle = angle - prev_angle;
if (diff_angle > M_PI) {
diff_angle -= M_PI * 2;
} else if (diff_angle < -M_PI) {
diff_angle += M_PI * 2;
if (diff_angle > base::kPiDouble) {
diff_angle -= base::kPiDouble * 2;
} else if (diff_angle < -base::kPiDouble) {
diff_angle += base::kPiDouble * 2;
}
swept_angle += diff_angle;
if (diff_angle > 0)
......
......@@ -4,6 +4,12 @@
#include "chrome/browser/ui/app_list/md_icon_normalizer.h"
#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>
#include "base/numerics/math_constants.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/canvas.h"
......@@ -26,7 +32,7 @@ constexpr float kMaxSquareAreaFactor = 361.0f / 576;
// Ratio of icon visible area to full icon size for a circular shaped icon.
constexpr float kMaxCircleAreaFactor = 380.0f / 576;
constexpr float kCircleAreaByRect = static_cast<float>(M_PI) / 4;
constexpr float kCircleAreaByRect = base::kPiFloat / 4;
// Slope used to calculate icon visible area to full icon size for any generic
// shaped icon.
......@@ -86,7 +92,7 @@ float GetMdIconScale(const SkBitmap& bitmap) {
// square and scale accordingly.
if (pixmap.alphaType() == kUnknown_SkAlphaType ||
pixmap.alphaType() == kOpaque_SkAlphaType) {
return (float)std::sqrt(kMaxSquareAreaFactor);
return std::sqrt(kMaxSquareAreaFactor);
}
bool const nativeColorType = pixmap.colorType() == kN32_SkColorType;
......@@ -176,9 +182,8 @@ float GetMdIconScale(const SkBitmap& bitmap) {
float area_scale = area / (width * height);
// Use sqrt of the final ratio as the image is scaled across both width and
// height.
return area_scale > scale_required
? (float)std::sqrt(scale_required / area_scale)
: 1;
return area_scale > scale_required ? std::sqrt(scale_required / area_scale)
: 1.0f;
}
} // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment