X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fanimation%2Fkey-frames-impl.cpp;h=bd486e5f489d5eaa6eab3120ae9461c5f496b782;hb=9311c4e66c2fd3625455f29e6568c4292fac409d;hp=a111c17d2acf71a9bad3923f92951c54ecda7b70;hpb=a7e2c4cea2d831cbd5538e34b7a2227a9dc12d58;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/animation/key-frames-impl.cpp b/dali/internal/event/animation/key-frames-impl.cpp index a111c17..bd486e5 100644 --- a/dali/internal/event/animation/key-frames-impl.cpp +++ b/dali/internal/event/animation/key-frames-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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,23 +22,11 @@ namespace Dali { namespace Internal { - KeyFrames* KeyFrames::New() { return new KeyFrames(); } -KeyFrames::KeyFrames() - : mType(Property::NONE), - mKeyFrames(NULL) -{ -} - -KeyFrames::~KeyFrames() -{ -} - - void KeyFrames::CreateKeyFramesSpec(Property::Type type) { mType = type; @@ -47,42 +35,42 @@ void KeyFrames::CreateKeyFramesSpec(Property::Type type) { case Property::BOOLEAN: { - mKeyFrames = Internal::KeyFrameBoolean::New(); + mKeyFrames = std::make_unique(); break; } case Property::INTEGER: { - mKeyFrames = Internal::KeyFrameInteger::New(); + mKeyFrames = std::make_unique(); break; } case Property::FLOAT: { - mKeyFrames = Internal::KeyFrameNumber::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR2: { - mKeyFrames = Internal::KeyFrameVector2::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR3: { - mKeyFrames = Internal::KeyFrameVector3::New(); + mKeyFrames = std::make_unique(); break; } case Property::VECTOR4: { - mKeyFrames = Internal::KeyFrameVector4::New(); + mKeyFrames = std::make_unique(); break; } case Property::ROTATION: { - mKeyFrames = Internal::KeyFrameQuaternion::New(); + mKeyFrames = std::make_unique(); break; } default: { - DALI_ABORT( "Type not animateable" ); + DALI_ABORT("Property type is not animatable"); break; } } @@ -93,7 +81,7 @@ Property::Type KeyFrames::GetType() const return mType; } -void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) +void KeyFrames::Add(float time, const Property::Value& value, AlphaFunction alpha) { if(mType == Property::NONE) { @@ -101,51 +89,53 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) } // Once we have created a type, can only add values of the same type - DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" ); + DALI_ASSERT_ALWAYS(mType == value.GetType() && "Can only add values of the same type to a KeyFrame"); + + auto keyframes = mKeyFrames.get(); - DALI_ASSERT_DEBUG(mKeyFrames); + DALI_ASSERT_DEBUG(keyframes); switch(mType) { case Property::BOOLEAN: { - Internal::KeyFrameBoolean* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameBoolean* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::INTEGER: { - Internal::KeyFrameInteger* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameInteger* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::FLOAT: { - Internal::KeyFrameNumber* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameNumber* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR2: { - Internal::KeyFrameVector2* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector2* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR3: { - Internal::KeyFrameVector3* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector3* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::VECTOR4: { - Internal::KeyFrameVector4* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameVector4* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } case Property::ROTATION: { - Internal::KeyFrameQuaternion* kf = static_cast(mKeyFrames.Get()); + Internal::KeyFrameQuaternion* kf = static_cast(keyframes); kf->AddKeyFrame(time, value.Get(), alpha); break; } @@ -157,21 +147,35 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) KeyFrameSpec* KeyFrames::GetKeyFramesBase() const { - return mKeyFrames.Get(); + return mKeyFrames.get(); } Property::Value KeyFrames::GetLastKeyFrameValue() const { Property::Value value; - unsigned int noOfKeyFrames = mKeyFrames->GetNumberOfKeyFrames(); - if( noOfKeyFrames ) + std::size_t noOfKeyFrames = mKeyFrames->GetNumberOfKeyFrames(); + if(noOfKeyFrames) { - mKeyFrames->GetKeyFrameAsValue( noOfKeyFrames - 1, value ); + float time; + mKeyFrames->GetKeyFrameAsValue(noOfKeyFrames - 1, time, value); } return value; } -} // Internal -} // Dali +std::size_t KeyFrames::GetKeyFrameCount() const +{ + return mKeyFrames->GetNumberOfKeyFrames(); +} + +void KeyFrames::GetKeyFrame(std::size_t index, float& time, Property::Value& value) const +{ + if(index < mKeyFrames->GetNumberOfKeyFrames()) + { + mKeyFrames->GetKeyFrameAsValue(index, time, value); + } +} + +} // namespace Internal +} // namespace Dali