Commit b1e08ce5 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Use TimeDelta::operator/() more, ash/ edition.

Bug: 1104532
Change-Id: Iea05cc80dbcee0f2aa84c777cded4e07e7cb1311
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2354989
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797941}
parent 8ec3090d
...@@ -115,7 +115,7 @@ void AccessibilityFocusRingGroup::AnimateFocusRings(base::TimeTicks timestamp) { ...@@ -115,7 +115,7 @@ void AccessibilityFocusRingGroup::AnimateFocusRings(base::TimeTicks timestamp) {
return; return;
} }
double fraction = delta.InSecondsF() / transition_time.InSecondsF(); double fraction = delta / transition_time;
// Ease-in effect. // Ease-in effect.
fraction = pow(fraction, 0.3); fraction = pow(fraction, 0.3);
......
...@@ -27,12 +27,10 @@ void ComputeOpacity(LayerAnimationInfo* animation_info, ...@@ -27,12 +27,10 @@ void ComputeOpacity(LayerAnimationInfo* animation_info,
} }
float opacity; float opacity;
if (start_delta < fade_in_time) { if (start_delta < fade_in_time)
opacity = start_delta.InSecondsF() / fade_in_time.InSecondsF(); opacity = start_delta / fade_in_time;
} else { else
opacity = 1.0 - (change_delta.InSecondsF() / opacity = 1.0 - (change_delta / (fade_in_time + fade_out_time));
(fade_in_time + fade_out_time).InSecondsF());
}
// Layer::SetOpacity will throw an error if we're not within 0...1. // Layer::SetOpacity will throw an error if we're not within 0...1.
opacity = base::ClampToRange(opacity, 0.0f, 1.0f); opacity = base::ClampToRange(opacity, 0.0f, 1.0f);
......
...@@ -335,11 +335,10 @@ void ExpandArrowView::AnimationProgressed(const gfx::Animation* animation) { ...@@ -335,11 +335,10 @@ void ExpandArrowView::AnimationProgressed(const gfx::Animation* animation) {
} }
// Update pulse radius. // Update pulse radius.
pulse_radius_ = base::ClampRound( pulse_radius_ =
(kPulseMaxRadius - kPulseMinRadius) * base::ClampRound((kPulseMaxRadius - kPulseMinRadius) *
gfx::Tween::CalculateValue( gfx::Tween::CalculateValue(gfx::Tween::EASE_IN_OUT,
gfx::Tween::EASE_IN_OUT, time / kCycleDuration));
time.InMillisecondsF() / kCycleDuration.InMillisecondsF()));
// Update y position offset of the arrow. // Update y position offset of the arrow.
constexpr auto kArrowMoveOutBeginTime = constexpr auto kArrowMoveOutBeginTime =
...@@ -348,16 +347,14 @@ void ExpandArrowView::AnimationProgressed(const gfx::Animation* animation) { ...@@ -348,16 +347,14 @@ void ExpandArrowView::AnimationProgressed(const gfx::Animation* animation) {
constexpr auto kArrowMoveInBeginTime = base::TimeDelta::FromMilliseconds(500); constexpr auto kArrowMoveInBeginTime = base::TimeDelta::FromMilliseconds(500);
constexpr auto kArrowMoveInEndTime = base::TimeDelta::FromMilliseconds(900); constexpr auto kArrowMoveInEndTime = base::TimeDelta::FromMilliseconds(900);
if (time > kArrowMoveOutBeginTime && time <= kArrowMoveOutEndTime) { if (time > kArrowMoveOutBeginTime && time <= kArrowMoveOutEndTime) {
const double progress = const double progress = (time - kArrowMoveOutBeginTime) /
(time - kArrowMoveOutBeginTime).InMillisecondsF() / (kArrowMoveOutEndTime - kArrowMoveOutBeginTime);
(kArrowMoveOutEndTime - kArrowMoveOutBeginTime).InMillisecondsF();
arrow_y_offset_ = base::ClampRound( arrow_y_offset_ = base::ClampRound(
-kTotalArrowYOffset * -kTotalArrowYOffset *
gfx::Tween::CalculateValue(gfx::Tween::EASE_IN, progress)); gfx::Tween::CalculateValue(gfx::Tween::EASE_IN, progress));
} else if (time > kArrowMoveInBeginTime && time <= kArrowMoveInEndTime) { } else if (time > kArrowMoveInBeginTime && time <= kArrowMoveInEndTime) {
const double progress = const double progress = (time - kArrowMoveInBeginTime) /
(time - kArrowMoveInBeginTime).InMillisecondsF() / (kArrowMoveInEndTime - kArrowMoveInBeginTime);
(kArrowMoveInEndTime - kArrowMoveInBeginTime).InMillisecondsF();
arrow_y_offset_ = base::ClampRound( arrow_y_offset_ = base::ClampRound(
kTotalArrowYOffset * kTotalArrowYOffset *
(1 - gfx::Tween::CalculateValue(gfx::Tween::EASE_OUT, progress))); (1 - gfx::Tween::CalculateValue(gfx::Tween::EASE_OUT, progress)));
......
...@@ -97,8 +97,7 @@ float FastInkPoints::GetFadeoutFactor(int index) const { ...@@ -97,8 +97,7 @@ float FastInkPoints::GetFadeoutFactor(int index) const {
DCHECK(!life_duration_.is_zero()); DCHECK(!life_duration_.is_zero());
DCHECK(0 <= index && index < GetNumberOfPoints()); DCHECK(0 <= index && index < GetNumberOfPoints());
base::TimeDelta age = collection_latest_time_ - points_[index].time; base::TimeDelta age = collection_latest_time_ - points_[index].time;
return std::min(age.InMillisecondsF() / life_duration_.InMillisecondsF(), return std::min(age / life_duration_, 1.0);
1.0);
} }
void FastInkPoints::Predict(const FastInkPoints& real_points, void FastInkPoints::Predict(const FastInkPoints& real_points,
......
...@@ -72,29 +72,25 @@ constexpr auto kShowAnimationDuration = kPositionAnimationDuration; ...@@ -72,29 +72,25 @@ constexpr auto kShowAnimationDuration = kPositionAnimationDuration;
// Value of |tablet_mode_animation_| showing to begin animating alpha of // Value of |tablet_mode_animation_| showing to begin animating alpha of
// |size_button_|. // |size_button_|.
float SizeButtonShowStartValue() { float SizeButtonShowStartValue() {
return kShowAnimationAlphaDelay.InMillisecondsF() / return kShowAnimationAlphaDelay / kShowAnimationDuration;
kShowAnimationDuration.InMillisecondsF();
} }
// Amount of |tablet_mode_animation_| showing to animate the alpha of // Amount of |tablet_mode_animation_| showing to animate the alpha of
// |size_button_|. // |size_button_|.
float SizeButtonShowDuration() { float SizeButtonShowDuration() {
return kAlphaAnimationDuration.InMillisecondsF() / return kAlphaAnimationDuration / kShowAnimationDuration;
kShowAnimationDuration.InMillisecondsF();
} }
// Amount of |tablet_mode_animation_| hiding to animate the alpha of // Amount of |tablet_mode_animation_| hiding to animate the alpha of
// |size_button_|. // |size_button_|.
float SizeButtonHideDuration() { float SizeButtonHideDuration() {
return kAlphaAnimationDuration.InMillisecondsF() / return kAlphaAnimationDuration / kHideAnimationDuration;
kHideAnimationDuration.InMillisecondsF();
} }
// Value of |tablet_mode_animation_| hiding to begin animating the position of // Value of |tablet_mode_animation_| hiding to begin animating the position of
// buttons to the left of |size_button_|. // buttons to the left of |size_button_|.
float HidePositionStartValue() { float HidePositionStartValue() {
return 1.0f - kHidePositionDelay.InMillisecondsF() / return 1.0f - kHidePositionDelay / kHideAnimationDuration;
kHideAnimationDuration.InMillisecondsF();
} }
// Bounds animation values to the range 0.0 - 1.0. Allows for mapping of offset // Bounds animation values to the range 0.0 - 1.0. Allows for mapping of offset
......
...@@ -769,8 +769,7 @@ void SplitViewController::SnapWindow(aura::Window* window, ...@@ -769,8 +769,7 @@ void SplitViewController::SnapWindow(aura::Window* window,
// Apply the transform that |window| will undergo when the divider spawns. // Apply the transform that |window| will undergo when the divider spawns.
static const double value = gfx::Tween::CalculateValue( static const double value = gfx::Tween::CalculateValue(
gfx::Tween::FAST_OUT_SLOW_IN, gfx::Tween::FAST_OUT_SLOW_IN,
kSplitviewDividerSpawnDelay.InMillisecondsF() / kSplitviewDividerSpawnDelay / kSplitviewWindowTransformDuration);
kSplitviewWindowTransformDuration.InMillisecondsF());
gfx::TransformAboutPivot(bounds.origin(), gfx::TransformAboutPivot(bounds.origin(),
gfx::Tween::TransformValueBetween( gfx::Tween::TransformValueBetween(
value, window->transform(), gfx::Transform())) value, window->transform(), gfx::Transform()))
......
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