OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/animation/CompositorAnimationPlayer.h" |
| 6 |
| 7 #include "cc/animation/animation_id_provider.h" |
| 8 #include "platform/animation/CompositorAnimation.h" |
| 9 #include "platform/animation/WebToCCAnimationDelegateAdapter.h" |
| 10 #include "public/platform/WebLayer.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 CompositorAnimationPlayer::CompositorAnimationPlayer() |
| 15 : m_animationPlayer(cc::AnimationPlayer::Create(cc::AnimationIdProvider::Nex
tPlayerId())) |
| 16 { |
| 17 } |
| 18 |
| 19 CompositorAnimationPlayer::~CompositorAnimationPlayer() |
| 20 { |
| 21 } |
| 22 |
| 23 cc::AnimationPlayer* CompositorAnimationPlayer::animationPlayer() const |
| 24 { |
| 25 return m_animationPlayer.get(); |
| 26 } |
| 27 |
| 28 void CompositorAnimationPlayer::setAnimationDelegate(WebCompositorAnimationDeleg
ate* delegate) |
| 29 { |
| 30 if (!delegate) { |
| 31 m_animationDelegateAdapter.reset(); |
| 32 m_animationPlayer->set_layer_animation_delegate(nullptr); |
| 33 return; |
| 34 } |
| 35 m_animationDelegateAdapter.reset(new WebToCCAnimationDelegateAdapter(delegat
e)); |
| 36 m_animationPlayer->set_layer_animation_delegate(m_animationDelegateAdapter.g
et()); |
| 37 } |
| 38 |
| 39 void CompositorAnimationPlayer::attachLayer(WebLayer* webLayer) |
| 40 { |
| 41 m_animationPlayer->AttachLayer(webLayer->id()); |
| 42 } |
| 43 |
| 44 void CompositorAnimationPlayer::detachLayer() |
| 45 { |
| 46 m_animationPlayer->DetachLayer(); |
| 47 } |
| 48 |
| 49 bool CompositorAnimationPlayer::isLayerAttached() const |
| 50 { |
| 51 return m_animationPlayer->layer_id() != 0; |
| 52 } |
| 53 |
| 54 void CompositorAnimationPlayer::addAnimation(CompositorAnimation* animation) |
| 55 { |
| 56 m_animationPlayer->AddAnimation(animation->passAnimation()); |
| 57 delete animation; |
| 58 } |
| 59 |
| 60 void CompositorAnimationPlayer::removeAnimation(int animationId) |
| 61 { |
| 62 m_animationPlayer->RemoveAnimation(animationId); |
| 63 } |
| 64 |
| 65 void CompositorAnimationPlayer::pauseAnimation(int animationId, double timeOffse
t) |
| 66 { |
| 67 m_animationPlayer->PauseAnimation(animationId, timeOffset); |
| 68 } |
| 69 |
| 70 void CompositorAnimationPlayer::abortAnimation(int animationId) |
| 71 { |
| 72 m_animationPlayer->AbortAnimation(animationId); |
| 73 } |
| 74 |
| 75 } // namespace blink |
OLD | NEW |