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 #include "core/animation/StyleInterpolation.h" 9 10 namespace blink { 11 12 SampledEffect::SampledEffect(Animation* animation, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > interpolations) 13 : m_animation(animation) 14 #if !ENABLE(OILPAN) 15 , m_player(animation->player()) 16 #endif 17 , m_interpolations(interpolations) 18 , m_sequenceNumber(animation->player()->sequenceNumber()) 19 , m_priority(animation->priority()) 20 { 21 ASSERT(m_interpolations && !m_interpolations->isEmpty()); 22 } 23 24 bool SampledEffect::canChange() const 25 { 26 #if ENABLE(OILPAN) 27 return m_animation; 28 #else 29 if (!m_animation) 30 return false; 31 // FIXME: This check won't be needed when Animation and AnimationPlayer are moved to Oilpan. 32 return !m_player->canFree(); 33 #endif 34 } 35 36 void SampledEffect::clear() 37 { 38 #if !ENABLE(OILPAN) 39 m_player = nullptr; 40 #endif 41 m_animation = nullptr; 42 m_interpolations->clear(); 43 } 44 45 void SampledEffect::removeReplacedInterpolationsIfNeeded(const BitArray<numCSSProperties>& replacedProperties) 46 { 47 if (canChange() && m_animation->isCurrent()) 48 return; 49 50 size_t dest = 0; 51 for (size_t i = 0; i < m_interpolations->size(); i++) { 52 if (!replacedProperties.get(toStyleInterpolation(m_interpolations->at(i).get())->id())) 53 m_interpolations->at(dest++) = m_interpolations->at(i); 54 } 55 m_interpolations->shrink(dest); 56 } 57 58 void SampledEffect::trace(Visitor* visitor) 59 { 60 visitor->trace(m_animation); 61 #if ENABLE(OILPAN) 62 visitor->trace(m_interpolations); 63 #endif 64 } 65 66 } // namespace blink 67