summaryrefslogtreecommitdiffstats
path: root/cc/blink/web_compositor_animation_player_impl.cc
blob: fd146de856fc4ae3d0d41c969ce9bcc23aaa1282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/blink/web_compositor_animation_player_impl.h"

#include "cc/animation/animation_id_provider.h"
#include "cc/animation/animation_player.h"
#include "cc/blink/web_animation_impl.h"
#include "cc/blink/web_to_cc_animation_delegate_adapter.h"
#include "third_party/WebKit/public/platform/WebLayer.h"

using cc::AnimationPlayer;

namespace cc_blink {

WebCompositorAnimationPlayerImpl::WebCompositorAnimationPlayerImpl()
    : animation_player_(
          AnimationPlayer::Create(cc::AnimationIdProvider::NextPlayerId())) {
}

WebCompositorAnimationPlayerImpl::~WebCompositorAnimationPlayerImpl() {
}

CC_BLINK_EXPORT cc::AnimationPlayer*
WebCompositorAnimationPlayerImpl::animation_player() const {
  return animation_player_.get();
}

void WebCompositorAnimationPlayerImpl::setAnimationDelegate(
    blink::WebCompositorAnimationDelegate* delegate) {
  animation_delegate_adapter_.reset(
      new WebToCCAnimationDelegateAdapter(delegate));
  animation_player_->set_layer_animation_delegate(
      animation_delegate_adapter_.get());
}

void WebCompositorAnimationPlayerImpl::attachLayer(blink::WebLayer* web_layer) {
  animation_player_->AttachLayer(web_layer->id());
}

void WebCompositorAnimationPlayerImpl::detachLayer() {
  animation_player_->DetachLayer();
}

bool WebCompositorAnimationPlayerImpl::isLayerAttached() const {
  return animation_player_->layer_id() != 0;
}

void WebCompositorAnimationPlayerImpl::addAnimation(
    blink::WebCompositorAnimation* animation) {
  animation_player_->AddAnimation(
      static_cast<WebCompositorAnimationImpl*>(animation)->PassAnimation());
  delete animation;
}

void WebCompositorAnimationPlayerImpl::removeAnimation(int animation_id) {
  animation_player_->RemoveAnimation(animation_id);
}

void WebCompositorAnimationPlayerImpl::pauseAnimation(int animation_id,
                                                      double time_offset) {
  animation_player_->PauseAnimation(animation_id, time_offset);
}

}  // namespace cc_blink