diff options
author | Steve Block <steveblock@google.com> | 2010-02-02 14:57:50 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-04 15:06:55 +0000 |
commit | d0825bca7fe65beaee391d30da42e937db621564 (patch) | |
tree | 7461c49eb5844ffd1f35d1ba2c8b7584c1620823 /WebCore/page/animation/AnimationBase.cpp | |
parent | 3db770bd97c5a59b6c7574ca80a39e5a51c1defd (diff) | |
download | external_webkit-d0825bca7fe65beaee391d30da42e937db621564.zip external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.gz external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.bz2 |
Merge webkit.org at r54127 : Initial merge by git
Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82
Diffstat (limited to 'WebCore/page/animation/AnimationBase.cpp')
-rw-r--r-- | WebCore/page/animation/AnimationBase.cpp | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/WebCore/page/animation/AnimationBase.cpp b/WebCore/page/animation/AnimationBase.cpp index f1ee750..2a2ab4b 100644 --- a/WebCore/page/animation/AnimationBase.cpp +++ b/WebCore/page/animation/AnimationBase.cpp @@ -92,10 +92,17 @@ static inline Color blendFunc(const AnimationBase* anim, const Color& from, cons if (progress == 1 && !to.isValid()) return Color(); - return Color(blendFunc(anim, from.red(), to.red(), progress), - blendFunc(anim, from.green(), to.green(), progress), - blendFunc(anim, from.blue(), to.blue(), progress), - blendFunc(anim, from.alpha(), to.alpha(), progress)); + // Contrary to the name, RGBA32 actually stores ARGB, so we can initialize Color directly from premultipliedARGBFromColor(). + // Also, premultipliedARGBFromColor() bails on zero alpha, so special-case that. + Color premultFrom = from.alpha() ? premultipliedARGBFromColor(from) : 0; + Color premultTo = to.alpha() ? premultipliedARGBFromColor(to) : 0; + + Color premultBlended(blendFunc(anim, premultFrom.red(), premultTo.red(), progress), + blendFunc(anim, premultFrom.green(), premultTo.green(), progress), + blendFunc(anim, premultFrom.blue(), premultTo.blue(), progress), + blendFunc(anim, premultFrom.alpha(), premultTo.alpha(), progress)); + + return Color(colorFromPremultipliedARGB(premultBlended.rgb())); } static inline Length blendFunc(const AnimationBase*, const Length& from, const Length& to, double progress) @@ -407,7 +414,7 @@ public: }; template <typename T> -class FillLayerPropertyWrapperGetter : public FillLayerPropertyWrapperBase { +class FillLayerPropertyWrapperGetter : public FillLayerPropertyWrapperBase, public Noncopyable { public: FillLayerPropertyWrapperGetter(T (FillLayer::*getter)() const) : m_getter(getter) @@ -863,7 +870,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) m_pauseTime = -1; m_requestedStartTime = 0; m_nextIterationDuration = -1; - endAnimation(false); + endAnimation(); return; } @@ -875,7 +882,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) m_pauseTime = -1; m_requestedStartTime = 0; m_nextIterationDuration = -1; - endAnimation(false); + endAnimation(); if (!paused()) updateStateMachine(AnimationStateInputStartAnimation, -1); @@ -886,7 +893,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) if (m_animState == AnimationStateStartWaitStyleAvailable) m_compAnim->animationController()->removeFromStyleAvailableWaitList(this); m_animState = AnimationStateDone; - endAnimation(true); + endAnimation(); return; } @@ -894,7 +901,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) if (m_animState == AnimationStateStartWaitResponse) { // If we are in AnimationStateStartWaitResponse, the animation will get canceled before // we get a response, so move to the next state. - endAnimation(false); + endAnimation(); updateStateMachine(AnimationStateInputStartTimeSet, beginAnimationUpdateTime()); } return; @@ -903,7 +910,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) if (input == AnimationStateInputResumeOverride) { if (m_animState == AnimationStateLooping || m_animState == AnimationStateEnding) { // Start the animation - startAnimation(m_startTime); + startAnimation(beginAnimationUpdateTime() - m_startTime); } return; } @@ -956,7 +963,12 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) updateStateMachine(AnimationStateInputStartTimeSet, beginAnimationUpdateTime()); } else { - bool started = startAnimation(0); + double timeOffset = 0; + // If the value for 'animation-delay' is negative then the animation appears to have started in the past. + if (m_animation->delay() < 0) + timeOffset = -m_animation->delay(); + bool started = startAnimation(timeOffset); + m_compAnim->animationController()->addToStartTimeResponseWaitList(this, started); m_fallbackAnimating = !started; } @@ -967,8 +979,12 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) if (input == AnimationStateInputStartTimeSet) { ASSERT(param >= 0); // We have a start time, set it, unless the startTime is already set - if (m_startTime <= 0) + if (m_startTime <= 0) { m_startTime = param; + // If the value for 'animation-delay' is negative then the animation appears to have started in the past. + if (m_animation->delay() < 0) + m_startTime += m_animation->delay(); + } // Decide whether to go into looping or ending state goIntoEndingOrLoopingState(); @@ -980,7 +996,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) // We are pausing while waiting for a start response. Cancel the animation and wait. When // we unpause, we will act as though the start timer just fired m_pauseTime = -1; - endAnimation(false); + pauseAnimation(beginAnimationUpdateTime() - m_startTime); m_animState = AnimationStatePausedWaitResponse; } break; @@ -997,7 +1013,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) } else { // We are pausing while running. Cancel the animation and wait m_pauseTime = beginAnimationUpdateTime(); - endAnimation(false); + pauseAnimation(beginAnimationUpdateTime() - m_startTime); m_animState = AnimationStatePausedRun; } break; @@ -1020,7 +1036,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) } else { // We are pausing while running. Cancel the animation and wait m_pauseTime = beginAnimationUpdateTime(); - endAnimation(false); + pauseAnimation(beginAnimationUpdateTime() - m_startTime); m_animState = AnimationStatePausedRun; } // |this| may be deleted here @@ -1072,7 +1088,7 @@ void AnimationBase::updateStateMachine(AnimStateInput input, double param) updateStateMachine(AnimationStateInputStartTimeSet, beginAnimationUpdateTime()); m_fallbackAnimating = true; } else { - bool started = startAnimation(m_startTime); + bool started = startAnimation(beginAnimationUpdateTime() - m_startTime); m_compAnim->animationController()->addToStartTimeResponseWaitList(this, started); m_fallbackAnimating = !started; } |