OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/animation/CompositorAnimationPlayer.h" | 5 #include "platform/animation/CompositorAnimationPlayer.h" |
6 | 6 |
7 #include "cc/animation/animation_id_provider.h" | 7 #include "cc/animation/animation_id_provider.h" |
| 8 #include "cc/animation/animation_timeline.h" |
8 #include "platform/animation/CompositorAnimation.h" | 9 #include "platform/animation/CompositorAnimation.h" |
9 #include "platform/animation/CompositorAnimationDelegate.h" | 10 #include "platform/animation/CompositorAnimationDelegate.h" |
10 #include "public/platform/WebLayer.h" | 11 #include "public/platform/WebLayer.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 CompositorAnimationPlayer::CompositorAnimationPlayer() | 15 CompositorAnimationPlayer::CompositorAnimationPlayer() |
15 : m_animationPlayer(cc::AnimationPlayer::Create(cc::AnimationIdProvider::Nex
tPlayerId())) | 16 : m_animationPlayer(cc::AnimationPlayer::Create(cc::AnimationIdProvider::Nex
tPlayerId())) |
16 , m_delegate() | 17 , m_delegate() |
17 { | 18 { |
18 } | 19 } |
19 | 20 |
20 CompositorAnimationPlayer::~CompositorAnimationPlayer() | 21 CompositorAnimationPlayer::~CompositorAnimationPlayer() |
21 { | 22 { |
| 23 setAnimationDelegate(nullptr); |
| 24 // Detach player from timeline, otherwise it stays there (leaks) until |
| 25 // compositor shutdown. |
| 26 if (m_animationPlayer->animation_timeline()) |
| 27 m_animationPlayer->animation_timeline()->DetachPlayer(m_animationPlayer)
; |
22 } | 28 } |
23 | 29 |
24 cc::AnimationPlayer* CompositorAnimationPlayer::animationPlayer() const | 30 cc::AnimationPlayer* CompositorAnimationPlayer::animationPlayer() const |
25 { | 31 { |
26 return m_animationPlayer.get(); | 32 return m_animationPlayer.get(); |
27 } | 33 } |
28 | 34 |
29 void CompositorAnimationPlayer::setAnimationDelegate(CompositorAnimationDelegate
* delegate) | 35 void CompositorAnimationPlayer::setAnimationDelegate(CompositorAnimationDelegate
* delegate) |
30 { | 36 { |
31 m_delegate = delegate; | 37 m_delegate = delegate; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 { | 109 { |
104 if (m_delegate) { | 110 if (m_delegate) { |
105 m_delegate->notifyAnimationTakeover( | 111 m_delegate->notifyAnimationTakeover( |
106 (monotonicTime - base::TimeTicks()).InSecondsF(), | 112 (monotonicTime - base::TimeTicks()).InSecondsF(), |
107 animationStartTime, | 113 animationStartTime, |
108 std::move(curve)); | 114 std::move(curve)); |
109 } | 115 } |
110 } | 116 } |
111 | 117 |
112 } // namespace blink | 118 } // namespace blink |
OLD | NEW |