| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 "cc/blink/web_compositor_animation_player_impl.h" | |
| 6 | |
| 7 #include "cc/animation/animation_id_provider.h" | |
| 8 #include "cc/animation/animation_player.h" | |
| 9 #include "cc/blink/web_animation_impl.h" | |
| 10 #include "cc/blink/web_to_cc_animation_delegate_adapter.h" | |
| 11 #include "third_party/WebKit/public/platform/WebLayer.h" | |
| 12 | |
| 13 using cc::AnimationPlayer; | |
| 14 | |
| 15 namespace cc_blink { | |
| 16 | |
| 17 WebCompositorAnimationPlayerImpl::WebCompositorAnimationPlayerImpl() | |
| 18 : animation_player_( | |
| 19 AnimationPlayer::Create(cc::AnimationIdProvider::NextPlayerId())) { | |
| 20 } | |
| 21 | |
| 22 WebCompositorAnimationPlayerImpl::~WebCompositorAnimationPlayerImpl() { | |
| 23 } | |
| 24 | |
| 25 CC_BLINK_EXPORT cc::AnimationPlayer* | |
| 26 WebCompositorAnimationPlayerImpl::animation_player() const { | |
| 27 return animation_player_.get(); | |
| 28 } | |
| 29 | |
| 30 void WebCompositorAnimationPlayerImpl::setAnimationDelegate( | |
| 31 blink::WebCompositorAnimationDelegate* delegate) { | |
| 32 if (!delegate) { | |
| 33 animation_delegate_adapter_.reset(); | |
| 34 animation_player_->set_layer_animation_delegate(nullptr); | |
| 35 return; | |
| 36 } | |
| 37 animation_delegate_adapter_.reset( | |
| 38 new WebToCCAnimationDelegateAdapter(delegate)); | |
| 39 animation_player_->set_layer_animation_delegate( | |
| 40 animation_delegate_adapter_.get()); | |
| 41 } | |
| 42 | |
| 43 void WebCompositorAnimationPlayerImpl::attachLayer(blink::WebLayer* web_layer) { | |
| 44 animation_player_->AttachLayer(web_layer->id()); | |
| 45 } | |
| 46 | |
| 47 void WebCompositorAnimationPlayerImpl::detachLayer() { | |
| 48 animation_player_->DetachLayer(); | |
| 49 } | |
| 50 | |
| 51 bool WebCompositorAnimationPlayerImpl::isLayerAttached() const { | |
| 52 return animation_player_->layer_id() != 0; | |
| 53 } | |
| 54 | |
| 55 void WebCompositorAnimationPlayerImpl::addAnimation( | |
| 56 blink::WebCompositorAnimation* animation) { | |
| 57 animation_player_->AddAnimation( | |
| 58 static_cast<WebCompositorAnimationImpl*>(animation)->PassAnimation()); | |
| 59 delete animation; | |
| 60 } | |
| 61 | |
| 62 void WebCompositorAnimationPlayerImpl::removeAnimation(int animation_id) { | |
| 63 animation_player_->RemoveAnimation(animation_id); | |
| 64 } | |
| 65 | |
| 66 void WebCompositorAnimationPlayerImpl::pauseAnimation(int animation_id, | |
| 67 double time_offset) { | |
| 68 animation_player_->PauseAnimation(animation_id, time_offset); | |
| 69 } | |
| 70 | |
| 71 void WebCompositorAnimationPlayerImpl::abortAnimation(int animation_id) { | |
| 72 animation_player_->AbortAnimation(animation_id); | |
| 73 } | |
| 74 | |
| 75 } // namespace cc_blink | |
| OLD | NEW |