diff options
Diffstat (limited to 'chromium/ui/gfx/animation/keyframe/keyframe_model.h')
-rw-r--r-- | chromium/ui/gfx/animation/keyframe/keyframe_model.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/chromium/ui/gfx/animation/keyframe/keyframe_model.h b/chromium/ui/gfx/animation/keyframe/keyframe_model.h index 92f9c07547a..3cb053b8136 100644 --- a/chromium/ui/gfx/animation/keyframe/keyframe_model.h +++ b/chromium/ui/gfx/animation/keyframe/keyframe_model.h @@ -7,8 +7,10 @@ #include <string> +#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gfx/animation/keyframe/animation_curve.h" #include "ui/gfx/animation/keyframe/keyframe_animation_export.h" +#include "ui/gfx/animation/keyframe/keyframed_animation_curve.h" namespace gfx { @@ -121,6 +123,21 @@ class GFX_KEYFRAME_ANIMATION_EXPORT KeyframeModel { bool HasActiveTime(base::TimeTicks monotonic_time) const; + template <typename T> + void Retarget(base::TimeTicks now, + int property_id, + const T& new_target_value) { + if (!curve_) + return; + base::TimeDelta now_delta = TrimTimeToCurrentIteration(now); + + DCHECK_EQ(CalculatePhase(now_delta), KeyframeModel::Phase::ACTIVE); + auto* keyframed_curve = AnimationTraits<T>::ToKeyframedCurve(curve_.get()); + DCHECK(keyframed_curve); + if (auto new_curve = keyframed_curve->Retarget(now_delta, new_target_value)) + curve_ = std::move(new_curve); + } + // Some clients may run threaded animations and may need to defer starting // until the animation on the other thread has been started. virtual bool StartShouldBeDeferred() const; @@ -139,7 +156,7 @@ class GFX_KEYFRAME_ANIMATION_EXPORT KeyframeModel { int target_property_id); void ForceRunState(RunState run_state) { run_state_ = run_state; } - base::Optional<base::TimeDelta> CalculateActiveTime( + absl::optional<base::TimeDelta> CalculateActiveTime( base::TimeTicks monotonic_time) const; private: |