-#ifndef __DALI_INTERNAL_KEY_FRAME_CHANNEL_H__
-#define __DALI_INTERNAL_KEY_FRAME_CHANNEL_H__
+#ifndef DALI_INTERNAL_KEY_FRAME_CHANNEL_H
+#define DALI_INTERNAL_KEY_FRAME_CHANNEL_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.
*/
// INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
#include <dali/internal/event/animation/progress-value.h>
+#include <dali/public-api/animation/animation.h>
+#include <dali/public-api/common/vector-wrapper.h>
namespace Dali
{
bool IsActive (float progress);
- V GetValue(float progress) const;
+ V GetValue(float progress, Dali::Animation::Interpolation interpolation) const;
bool FindInterval(typename ProgressValues::iterator& start,
typename ProgressValues::iterator& end,
/**
* Use a linear search to find the interval containing progress
- * TODO: Use binary search instead
*/
template <class V>
bool KeyFrameChannel<V>::FindInterval(
}
template <class V>
-V KeyFrameChannel<V>::GetValue (float progress) const
+V KeyFrameChannel<V>::GetValue (float progress, Dali::Animation::Interpolation interpolation) const
{
ProgressValue<V>& firstPV = mValues.front();
{
float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress());
- interpolatedV = Interpolate(*start, *end, frameProgress);
+ if( interpolation == Dali::Animation::LINEAR )
+ {
+ Interpolate(interpolatedV, start->GetValue(), end->GetValue(), frameProgress);
+ }
+ else
+ {
+ //Calculate prev and next values
+ V prev;
+ if( start != mValues.begin() )
+ {
+ prev = (start-1)->GetValue();
+ }
+ else
+ {
+ //Project next value through start point
+ prev = start->GetValue() + (start->GetValue()-(start+1)->GetValue());
+ }
+
+ V next;
+ if( end != mValues.end()-1)
+ {
+ next = (end+1)->GetValue();
+ }
+ else
+ {
+ //Project prev value through end point
+ next = end->GetValue() + (end->GetValue()-(end-1)->GetValue());
+ }
+
+ CubicInterpolate(interpolatedV, prev, start->GetValue(), end->GetValue(), next, frameProgress);
+ }
}
return interpolatedV;
} // Internal
} // namespace Dali
-#endif // __DALI_INTERNAL_KEY_FRAME_CHANNEL_H__
+#endif // DALI_INTERNAL_KEY_FRAME_CHANNEL_H