summaryrefslogtreecommitdiffstats
path: root/cc/blink/web_compositor_animation_timeline_impl.cc
blob: a87778331bbbc3c6c3b89fb3d1bc98d56944112a (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
// 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_timeline_impl.h"

#include "cc/animation/animation_id_provider.h"
#include "cc/animation/animation_player.h"
#include "cc/animation/animation_timeline.h"
#include "cc/blink/web_compositor_animation_player_impl.h"
#include "third_party/WebKit/public/platform/WebCompositorAnimationPlayerClient.h"

using cc::AnimationTimeline;

namespace cc_blink {

WebCompositorAnimationTimelineImpl::WebCompositorAnimationTimelineImpl()
    : animation_timeline_(AnimationTimeline::Create(
          cc::AnimationIdProvider::NextTimelineId())) {
}

WebCompositorAnimationTimelineImpl::~WebCompositorAnimationTimelineImpl() {
}

cc::AnimationTimeline* WebCompositorAnimationTimelineImpl::animation_timeline()
    const {
  return animation_timeline_.get();
}

void WebCompositorAnimationTimelineImpl::playerAttached(
    const blink::WebCompositorAnimationPlayerClient& client) {
  if (client.compositorPlayer())
    animation_timeline_->AttachPlayer(
        static_cast<WebCompositorAnimationPlayerImpl*>(
            client.compositorPlayer())->animation_player());
}

void WebCompositorAnimationTimelineImpl::playerDestroyed(
    const blink::WebCompositorAnimationPlayerClient& client) {
  if (client.compositorPlayer())
    animation_timeline_->DetachPlayer(
        static_cast<WebCompositorAnimationPlayerImpl*>(
            client.compositorPlayer())->animation_player());
}

}  // namespace cc_blink