Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / animation / SampledEffect.cpp
1 // Copyright 2014 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 "config.h"
6 #include "core/animation/SampledEffect.h"
7
8 namespace WebCore {
9
10 SampledEffect::SampledEffect(Animation* animation, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > interpolations)
11     : m_player(animation->player())
12     , m_animation(animation)
13     , m_interpolations(interpolations)
14     , m_playerSortInfo(m_player->sortInfo())
15     , m_priority(animation->priority())
16 {
17     ASSERT(m_interpolations && !m_interpolations->isEmpty());
18 }
19
20 bool SampledEffect::canChange() const
21 {
22     if (!m_animation)
23         return false;
24     // FIXME: This check won't be needed when Animation and AnimationPlayer are moved to Oilpan.
25     return !m_player->canFree();
26 }
27
28 void SampledEffect::clear()
29 {
30     m_player.clear();
31     m_animation = 0;
32     m_interpolations->clear();
33 }
34
35 void SampledEffect::removeReplacedInterpolationsIfNeeded(const BitArray<numCSSProperties>& replacedProperties)
36 {
37     if (canChange() && m_animation->isCurrent())
38         return;
39
40     size_t dest = 0;
41     for (size_t i = 0; i < m_interpolations->size(); i++) {
42         if (!replacedProperties.get(toStyleInterpolation(m_interpolations->at(i).get())->id()))
43             m_interpolations->at(dest++) = m_interpolations->at(i);
44     }
45     m_interpolations->shrink(dest);
46 }
47
48 } // namespace WebCore