X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fanimation%2Fkey-frames-impl.h;h=989e4811e8867755563fe94efc11a3c0e5cb653c;hb=53f9fe2ef16f8124ab976c9995146a0fd342775e;hp=4f55c9ff863f1cb7f4ffa36702f99e247a107516;hpb=86cc77228aed6d24b06b6ee61bd41d555d4f5451;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/animation/key-frames-impl.h b/dali/internal/event/animation/key-frames-impl.h index 4f55c9f..989e481 100644 --- a/dali/internal/event/animation/key-frames-impl.h +++ b/dali/internal/event/animation/key-frames-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_KEY_FRAMES_H__ -#define __DALI_INTERNAL_KEY_FRAMES_H__ +#ifndef DALI_INTERNAL_KEY_FRAMES_H +#define DALI_INTERNAL_KEY_FRAMES_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include @@ -32,8 +32,7 @@ namespace Internal { class KeyFrameSpec; class KeyFrames; -typedef IntrusivePtr KeyFramesPtr; - +using KeyFramesPtr = IntrusivePtr; /** * KeyFrames class is responsible for creating and building a specialized KeyFrame class @@ -50,7 +49,7 @@ public: KeyFrames(); protected: - virtual ~KeyFrames(); + ~KeyFrames() override; private: /** @@ -95,6 +94,11 @@ public: */ KeyFrameSpec* GetKeyFramesBase() const; + /** + * Return the value of the last key frame. + */ + Dali::Property::Value GetLastKeyFrameValue() const; + private: Dali::Property::Type mType; // Type of the specialization IntrusivePtr mKeyFrames; // Pointer to the specialized key frame object @@ -111,17 +115,23 @@ private: class KeyFrameSpec : public RefObject { public: + KeyFrameSpec() = default; - KeyFrameSpec() {} + virtual std::size_t GetNumberOfKeyFrames() const = 0; - virtual unsigned int GetNumberOfKeyFrames() const = 0; + /** + * Get the key frame value as a Property::Value. + * @param[in] index The index of the key frame to fetch + * @param[out] value The value of the given key frame + */ + virtual void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) = 0; protected: /** * A reference counted object may only be deleted by calling Unreference() */ - virtual ~KeyFrameSpec() {} + ~KeyFrameSpec() override = default; }; @@ -129,14 +139,13 @@ protected: * The base template class for each key frame specialization. It stores a vector of * ProgressValue pairs in mPVs, and uses the existing interface for KeyFrameChannel * to point at this vector. - * TODO: Incorporate KeyFrameChannel into this base template */ template class KeyFrameBaseSpec : public KeyFrameSpec { private: - typedef ProgressValue PV; - typedef std::vector PVContainer; + using PV = ProgressValue; + using PVContainer = std::vector; PVContainer mPVs; // The ProgressValue pairs KeyFrameChannel* mKeyFrames; // The key frame interpolator @@ -171,10 +180,22 @@ protected: mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); } + KeyFrameBaseSpec& operator=( const KeyFrameBaseSpec& keyFrames ) + { + if( this != &keyFrames ) + { + mPVs.clear(); + mPVs = keyFrames.mPVs; + delete mKeyFrames; + mKeyFrames = new KeyFrameChannel(KeyFrameChannelBase::Translate, mPVs); + } + return *this; + } + /** * Destructor. Ensure progress value pairs are cleared down */ - virtual ~KeyFrameBaseSpec() + ~KeyFrameBaseSpec() override { delete mKeyFrames; mPVs.clear(); @@ -190,7 +211,6 @@ public: */ void AddKeyFrame(float t, V v, AlphaFunction alpha) { - // TODO:: Support alpha mPVs.push_back(PV(t, v)); } @@ -198,7 +218,7 @@ public: * Get the number of key frames * @return The size of the progress value vector */ - virtual unsigned int GetNumberOfKeyFrames() const + std::size_t GetNumberOfKeyFrames() const override { return mPVs.size(); } @@ -217,6 +237,14 @@ public: } /** + * @copydoc KeyFrameSpec::GetKeyFrameAsValue() + */ + void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) override + { + value = mPVs[index].mValue; + } + + /** * Return whether the progress is valid for the range of keyframes. (The first * keyframe doesn't have to start at 0, and the last doesn't have to end at 1.0) * @param[in] progress The progress to test @@ -238,22 +266,21 @@ public: } }; -typedef KeyFrameBaseSpec KeyFrameNumber; -typedef KeyFrameBaseSpec KeyFrameBoolean; -typedef KeyFrameBaseSpec KeyFrameInteger; -typedef KeyFrameBaseSpec KeyFrameVector2; -typedef KeyFrameBaseSpec KeyFrameVector3; -typedef KeyFrameBaseSpec KeyFrameVector4; -typedef KeyFrameBaseSpec KeyFrameQuaternion; - -typedef IntrusivePtr KeyFrameBooleanPtr; -typedef IntrusivePtr KeyFrameNumberPtr; -typedef IntrusivePtr KeyFrameIntegerPtr; -typedef IntrusivePtr KeyFrameVector2Ptr; -typedef IntrusivePtr KeyFrameVector3Ptr; -typedef IntrusivePtr KeyFrameVector4Ptr; -typedef IntrusivePtr KeyFrameQuaternionPtr; - +using KeyFrameNumber = KeyFrameBaseSpec; +using KeyFrameBoolean = KeyFrameBaseSpec; +using KeyFrameInteger = KeyFrameBaseSpec; +using KeyFrameVector2 = KeyFrameBaseSpec; +using KeyFrameVector3 = KeyFrameBaseSpec; +using KeyFrameVector4 = KeyFrameBaseSpec; +using KeyFrameQuaternion = KeyFrameBaseSpec; + +using KeyFrameBooleanPtr = IntrusivePtr; +using KeyFrameNumberPtr = IntrusivePtr; +using KeyFrameIntegerPtr = IntrusivePtr; +using KeyFrameVector2Ptr = IntrusivePtr; +using KeyFrameVector3Ptr = IntrusivePtr; +using KeyFrameVector4Ptr = IntrusivePtr; +using KeyFrameQuaternionPtr = IntrusivePtr; inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameBoolean*& keyFrameSpec) { @@ -346,4 +373,4 @@ inline const Internal::KeyFrames& GetImplementation(const Dali::KeyFrames& keyFr } // Dali -#endif //__DALI_INTERNAL_KEY_FRAMES_H__ +#endif // DALI_INTERNAL_KEY_FRAMES_H