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

Unified Diff: third_party/WebKit/Source/core/animation/Animation.cpp

Issue 2570503002: Avoid conditional Animation prefinalizers. (Closed)
Patch Set: rebased upto r437900 Created 4 years 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 | « third_party/WebKit/Source/core/animation/Animation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/animation/Animation.cpp
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp
index 6638823ac509e9ddb34174cdc75f2186935c9a7c..9b95ae878d82ea9b8151041f4098f0e22e43997b 100644
--- a/third_party/WebKit/Source/core/animation/Animation.cpp
+++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -99,7 +99,6 @@ Animation::Animation(ExecutionContext* executionContext,
m_compositorState(nullptr),
m_compositorPending(false),
m_compositorGroup(0),
- m_preFinalizerRegistered(false),
m_currentTimePending(false),
m_stateIsBeingUpdated(false),
m_effectSuppressed(false) {
@@ -115,7 +114,8 @@ Animation::Animation(ExecutionContext* executionContext,
}
Animation::~Animation() {
- destroyCompositorPlayer();
+ // Verify that m_compositorPlayer has been disposed of.
+ DCHECK(!m_compositorPlayer);
}
void Animation::dispose() {
@@ -910,17 +910,9 @@ void Animation::endUpdatingState() {
void Animation::createCompositorPlayer() {
if (Platform::current()->isThreadedAnimationEnabled() &&
!m_compositorPlayer) {
- // We only need to pre-finalize if we are running animations on the
- // compositor.
- if (!m_preFinalizerRegistered) {
- ThreadState::current()->registerPreFinalizer(this);
- m_preFinalizerRegistered = true;
- }
-
DCHECK(Platform::current()->compositorSupport());
- m_compositorPlayer = CompositorAnimationPlayer::create();
+ m_compositorPlayer = CompositorAnimationPlayerHolder::create(this);
DCHECK(m_compositorPlayer);
- m_compositorPlayer->setAnimationDelegate(this);
attachCompositorTimeline();
}
@@ -932,8 +924,8 @@ void Animation::destroyCompositorPlayer() {
if (m_compositorPlayer) {
detachCompositorTimeline();
- m_compositorPlayer->setAnimationDelegate(nullptr);
- m_compositorPlayer.reset();
+ m_compositorPlayer->detach();
+ m_compositorPlayer = nullptr;
}
}
@@ -966,8 +958,8 @@ void Animation::attachCompositedLayers() {
}
void Animation::detachCompositedLayers() {
- if (m_compositorPlayer && m_compositorPlayer->isElementAttached())
- m_compositorPlayer->detachElement();
+ if (m_compositorPlayer && m_compositorPlayer->player()->isElementAttached())
+ m_compositorPlayer->player()->detachElement();
}
void Animation::notifyAnimationStarted(double monotonicTime, int group) {
@@ -1126,8 +1118,36 @@ DEFINE_TRACE(Animation) {
visitor->trace(m_pendingCancelledEvent);
visitor->trace(m_finishedPromise);
visitor->trace(m_readyPromise);
+ visitor->trace(m_compositorPlayer);
EventTargetWithInlineData::trace(visitor);
SuspendableObject::trace(visitor);
}
+Animation::CompositorAnimationPlayerHolder*
+Animation::CompositorAnimationPlayerHolder::create(Animation* animation) {
+ return new CompositorAnimationPlayerHolder(animation);
+}
+
+Animation::CompositorAnimationPlayerHolder::CompositorAnimationPlayerHolder(
+ Animation* animation)
+ : m_animation(animation) {
+ ThreadState::current()->registerPreFinalizer(this);
+ m_compositorPlayer = CompositorAnimationPlayer::create();
+ m_compositorPlayer->setAnimationDelegate(m_animation);
+}
+
+void Animation::CompositorAnimationPlayerHolder::dispose() {
+ if (!m_animation)
+ return;
+ m_animation->dispose();
+ DCHECK(!m_animation);
+ DCHECK(!m_compositorPlayer);
+}
+
+void Animation::CompositorAnimationPlayerHolder::detach() {
+ DCHECK(m_compositorPlayer);
+ m_compositorPlayer->setAnimationDelegate(nullptr);
+ m_animation = nullptr;
+ m_compositorPlayer.reset();
+}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698