18abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)/*
28abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * Copyright (C) 2009 Apple Inc. All rights reserved.
38abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * Copyright (C) 2013 Intel Corporation. All rights reserved.
48abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) *
58abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
68abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * modification, are permitted provided that the following conditions
78abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * are met:
88abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright
98abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer.
108abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright
118abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) *    notice, this list of conditions and the following disclaimer in the
128abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) *    documentation and/or other materials provided with the distribution.
138abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) *
148abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
158abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
168abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
178abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
188abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
198abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
208abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
218abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
228abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
248abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles) */
268abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
278abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#ifndef KeyframeValueList_h
288abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#define KeyframeValueList_h
298abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
3009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)#include "platform/animation/AnimationValue.h"
318abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
328abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#include "wtf/OwnPtr.h"
338abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#include "wtf/PassOwnPtr.h"
348abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#include "wtf/Vector.h"
358abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
36c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
378abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
388abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)enum AnimatedPropertyID {
398abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    AnimatedPropertyInvalid,
40aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch    AnimatedPropertyTransform,
418abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    AnimatedPropertyOpacity,
428abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    AnimatedPropertyBackgroundColor,
438abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    AnimatedPropertyWebkitFilter
448abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)};
458abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
468abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)// Used to store a series of values in a keyframe list.
478abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)// Values will all be of the same type, which can be inferred from the property.
4809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class PLATFORM_EXPORT KeyframeValueList {
498abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)public:
508abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    explicit KeyframeValueList(AnimatedPropertyID property)
518abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        : m_property(property)
528abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    {
538abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    }
548abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
558abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    KeyframeValueList(const KeyframeValueList& other)
568abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        : m_property(other.property())
578abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    {
588abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        for (size_t i = 0; i < other.m_values.size(); ++i)
598abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)            m_values.append(other.m_values[i]->clone());
608abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    }
618abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
628abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    KeyframeValueList& operator=(const KeyframeValueList& other)
638abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    {
648abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        KeyframeValueList copy(other);
658abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        swap(copy);
668abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        return *this;
678abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    }
688abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
698abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    void swap(KeyframeValueList& other)
708abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    {
718abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        std::swap(m_property, other.m_property);
728abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)        m_values.swap(other.m_values);
738abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    }
748abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
758abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    AnimatedPropertyID property() const { return m_property; }
768abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
778abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    size_t size() const { return m_values.size(); }
788abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    const AnimationValue* at(size_t i) const { return m_values.at(i).get(); }
798abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
808abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    // Insert, sorted by keyTime.
818abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    void insert(PassOwnPtr<const AnimationValue>);
828abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
838abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)protected:
848abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    Vector<OwnPtr<const AnimationValue> > m_values;
858abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)    AnimatedPropertyID m_property;
868abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)};
878abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
88c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
898abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)
908abfc5808a4e34d6e03867af8bc440dee641886fTorne (Richard Coles)#endif // KeyframeValueList_h
91