Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: Source/core/animation/AnimationPlayer.cpp

Issue 881183003: Animation: Cancel same-property animations on compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add manual test. Improve code a bit. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/AnimationPlayer.h ('k') | Source/core/animation/CompositorAnimations.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/AnimationPlayer.cpp
diff --git a/Source/core/animation/AnimationPlayer.cpp b/Source/core/animation/AnimationPlayer.cpp
index b3ad782e389f17110f27b535006eead7da0c4ec4..d400e1bdf3c1894e04b3451efde6f89e267c5050 100644
--- a/Source/core/animation/AnimationPlayer.cpp
+++ b/Source/core/animation/AnimationPlayer.cpp
@@ -246,8 +246,11 @@ void AnimationPlayer::preCommit(int compositorGroup, bool startOnCompositor)
if (shouldStart) {
m_compositorGroup = compositorGroup;
- if (startOnCompositor && maybeStartAnimationOnCompositor()) {
- m_compositorState = adoptPtr(new CompositorState(*this));
+ if (startOnCompositor) {
+ if (maybeStartAnimationOnCompositor())
+ m_compositorState = adoptPtr(new CompositorState(*this));
+ else
+ cancelIncompatibleAnimationsOnCompositor();
}
}
}
@@ -331,6 +334,15 @@ void AnimationPlayer::notifyStartTime(double timelineTime)
}
}
+bool AnimationPlayer::affects(const Element& element, CSSPropertyID property) const
+{
+ if (!m_content || !m_content->isAnimation())
+ return false;
+
+ const Animation* animation = toAnimation(m_content.get());
+ return (animation->target() == &element) && animation->affects(property);
+}
+
double AnimationPlayer::calculateStartTime(double currentTime) const
{
return m_timeline->effectiveTime() - currentTime / m_playbackRate;
@@ -690,6 +702,18 @@ void AnimationPlayer::setCompositorPending(bool sourceChanged)
}
}
+void AnimationPlayer::cancelAnimationOnCompositor()
+{
+ if (hasActiveAnimationsOnCompositor())
+ toAnimation(m_content.get())->cancelAnimationOnCompositor();
+}
+
+void AnimationPlayer::cancelIncompatibleAnimationsOnCompositor()
+{
+ if (m_content && m_content->isAnimation())
+ toAnimation(m_content.get())->cancelIncompatibleAnimationsOnCompositor();
+}
+
bool AnimationPlayer::hasActiveAnimationsOnCompositor()
{
if (!m_content || !m_content->isAnimation())
@@ -698,12 +722,6 @@ bool AnimationPlayer::hasActiveAnimationsOnCompositor()
return toAnimation(m_content.get())->hasActiveAnimationsOnCompositor();
}
-void AnimationPlayer::cancelAnimationOnCompositor()
-{
- if (hasActiveAnimationsOnCompositor())
- toAnimation(m_content.get())->cancelAnimationOnCompositor();
-}
-
bool AnimationPlayer::update(TimingUpdateReason reason)
{
if (!m_timeline)
@@ -806,7 +824,6 @@ AnimationPlayer::PlayStateUpdateScope::~PlayStateUpdateScope()
if (oldPlayState != newPlayState) {
bool wasActive = oldPlayState == Pending || oldPlayState == Running;
bool isActive = newPlayState == Pending || newPlayState == Running;
-
if (!wasActive && isActive)
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1("blink.animations," TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Animation", m_player, "data", InspectorAnimationEvent::data(*m_player));
else if (wasActive && !isActive)
« no previous file with comments | « Source/core/animation/AnimationPlayer.h ('k') | Source/core/animation/CompositorAnimations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698