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 "cc/animation/animation_timeline.h" |
9 #include "platform/animation/CompositorAnimation.h" | 9 #include "platform/animation/CompositorAnimation.h" |
10 #include "platform/animation/CompositorAnimationDelegate.h" | 10 #include "platform/animation/CompositorAnimationDelegate.h" |
11 #include "public/platform/WebLayer.h" | |
12 | 11 |
13 namespace blink { | 12 namespace blink { |
14 | 13 |
15 CompositorAnimationPlayer::CompositorAnimationPlayer() | 14 CompositorAnimationPlayer::CompositorAnimationPlayer() |
16 : m_animationPlayer(cc::AnimationPlayer::Create(cc::AnimationIdProvider::Nex
tPlayerId())) | 15 : m_animationPlayer(cc::AnimationPlayer::Create(cc::AnimationIdProvider::Nex
tPlayerId())) |
17 , m_delegate() | 16 , m_delegate() |
18 { | 17 { |
19 } | 18 } |
20 | 19 |
21 CompositorAnimationPlayer::~CompositorAnimationPlayer() | 20 CompositorAnimationPlayer::~CompositorAnimationPlayer() |
22 { | 21 { |
23 setAnimationDelegate(nullptr); | 22 setAnimationDelegate(nullptr); |
24 // Detach player from timeline, otherwise it stays there (leaks) until | 23 // Detach player from timeline, otherwise it stays there (leaks) until |
25 // compositor shutdown. | 24 // compositor shutdown. |
26 if (m_animationPlayer->animation_timeline()) | 25 if (m_animationPlayer->animation_timeline()) |
27 m_animationPlayer->animation_timeline()->DetachPlayer(m_animationPlayer)
; | 26 m_animationPlayer->animation_timeline()->DetachPlayer(m_animationPlayer)
; |
28 } | 27 } |
29 | 28 |
30 cc::AnimationPlayer* CompositorAnimationPlayer::animationPlayer() const | 29 cc::AnimationPlayer* CompositorAnimationPlayer::ccAnimationPlayer() const |
31 { | 30 { |
32 return m_animationPlayer.get(); | 31 return m_animationPlayer.get(); |
33 } | 32 } |
34 | 33 |
35 void CompositorAnimationPlayer::setAnimationDelegate(CompositorAnimationDelegate
* delegate) | 34 void CompositorAnimationPlayer::setAnimationDelegate(CompositorAnimationDelegate
* delegate) |
36 { | 35 { |
37 m_delegate = delegate; | 36 m_delegate = delegate; |
38 m_animationPlayer->set_animation_delegate(delegate ? this : nullptr); | 37 m_animationPlayer->set_animation_delegate(delegate ? this : nullptr); |
39 } | 38 } |
40 | 39 |
41 void CompositorAnimationPlayer::attachElement(const CompositorElementId& id) | 40 void CompositorAnimationPlayer::attachElement(const CompositorElementId& id) |
42 { | 41 { |
43 m_animationPlayer->AttachElement(id); | 42 m_animationPlayer->AttachElement(id); |
44 } | 43 } |
45 | 44 |
46 void CompositorAnimationPlayer::detachElement() | 45 void CompositorAnimationPlayer::detachElement() |
47 { | 46 { |
48 m_animationPlayer->DetachElement(); | 47 m_animationPlayer->DetachElement(); |
49 } | 48 } |
50 | 49 |
51 bool CompositorAnimationPlayer::isElementAttached() const | 50 bool CompositorAnimationPlayer::isElementAttached() const |
52 { | 51 { |
53 return !!m_animationPlayer->element_id(); | 52 return !!m_animationPlayer->element_id(); |
54 } | 53 } |
55 | 54 |
56 void CompositorAnimationPlayer::addAnimation(CompositorAnimation* animation) | 55 void CompositorAnimationPlayer::addAnimation(std::unique_ptr<CompositorAnimation
> animation) |
57 { | 56 { |
58 m_animationPlayer->AddAnimation(animation->passAnimation()); | 57 m_animationPlayer->AddAnimation(animation->releaseCcAnimation()); |
59 delete animation; | |
60 } | 58 } |
61 | 59 |
62 void CompositorAnimationPlayer::removeAnimation(uint64_t animationId) | 60 void CompositorAnimationPlayer::removeAnimation(int animationId) |
63 { | 61 { |
64 m_animationPlayer->RemoveAnimation(animationId); | 62 m_animationPlayer->RemoveAnimation(animationId); |
65 } | 63 } |
66 | 64 |
67 void CompositorAnimationPlayer::pauseAnimation(uint64_t animationId, double time
Offset) | 65 void CompositorAnimationPlayer::pauseAnimation(int animationId, double timeOffse
t) |
68 { | 66 { |
69 m_animationPlayer->PauseAnimation(animationId, timeOffset); | 67 m_animationPlayer->PauseAnimation(animationId, timeOffset); |
70 } | 68 } |
71 | 69 |
72 void CompositorAnimationPlayer::abortAnimation(uint64_t animationId) | 70 void CompositorAnimationPlayer::abortAnimation(int animationId) |
73 { | 71 { |
74 m_animationPlayer->AbortAnimation(animationId); | 72 m_animationPlayer->AbortAnimation(animationId); |
75 } | 73 } |
76 | 74 |
77 void CompositorAnimationPlayer::NotifyAnimationStarted( | 75 void CompositorAnimationPlayer::NotifyAnimationStarted( |
78 base::TimeTicks monotonicTime, | 76 base::TimeTicks monotonicTime, |
79 cc::TargetProperty::Type targetProperty, | 77 cc::TargetProperty::Type targetProperty, |
80 int group) | 78 int group) |
81 { | 79 { |
82 if (m_delegate) | 80 if (m_delegate) |
(...skipping 26 matching lines...) Expand all Loading... |
109 { | 107 { |
110 if (m_delegate) { | 108 if (m_delegate) { |
111 m_delegate->notifyAnimationTakeover( | 109 m_delegate->notifyAnimationTakeover( |
112 (monotonicTime - base::TimeTicks()).InSecondsF(), | 110 (monotonicTime - base::TimeTicks()).InSecondsF(), |
113 animationStartTime, | 111 animationStartTime, |
114 std::move(curve)); | 112 std::move(curve)); |
115 } | 113 } |
116 } | 114 } |
117 | 115 |
118 } // namespace blink | 116 } // namespace blink |
OLD | NEW |