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