- take Property::Value and std::string by value.
- use vector::push_back(T&&) version to avoid copy.
- this patch reduces 300,000 memory allocation.
Change-Id: I2da12f4b18cef5967ada18d6c9c58d2bc406d8ea
mPlaylist.OnClear( *this );
}
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue)
{
- AnimateBy( target, relativeValue, mDefaultAlpha, TimePeriod(mDurationSeconds) );
+ AnimateBy(target, std::move(relativeValue), mDefaultAlpha, TimePeriod(mDurationSeconds));
}
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue, AlphaFunction alpha )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha)
{
- AnimateBy( target, relativeValue, alpha, TimePeriod(mDurationSeconds) );
+ AnimateBy(target, std::move(relativeValue), alpha, TimePeriod(mDurationSeconds));
}
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue, TimePeriod period )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, TimePeriod period)
{
- AnimateBy( target, relativeValue, mDefaultAlpha, period );
+ AnimateBy(target, std::move(relativeValue), mDefaultAlpha, period);
}
-void Animation::AnimateBy( Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period )
+void Animation::AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
{
Object& object = GetImplementation(target.object);
const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
ExtendDuration(period);
- // Store data to later notify the object that its property is being animated
- ConnectorTargetValues connectorPair;
- connectorPair.targetValue = relativeValue;
- connectorPair.connectorIndex = mConnectors.Count();
- connectorPair.timePeriod = period;
- connectorPair.animatorType = Animation::BY;
- mConnectorTargetValues.push_back( connectorPair );
+ // keep the current count.
+ auto connectorIndex = mConnectors.Count();
// using destination type so component animation gets correct type
switch ( destinationType )
default:
{
- // non animatable types handled already
+ DALI_ASSERT_DEBUG(false && "Property not supported");
}
}
+ // Store data to later notify the object that its property is being animated
+ mConnectorTargetValues.push_back({std::move(relativeValue), period, connectorIndex, Animation::BY});
}
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue)
{
- AnimateTo( target, destinationValue, mDefaultAlpha, TimePeriod(mDurationSeconds) );
+ AnimateTo(target, std::move(destinationValue), mDefaultAlpha, TimePeriod(mDurationSeconds));
}
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue, AlphaFunction alpha )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha)
{
- AnimateTo( target, destinationValue, alpha, TimePeriod(mDurationSeconds));
+ AnimateTo(target, std::move(destinationValue), alpha, TimePeriod(mDurationSeconds));
}
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue, TimePeriod period )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, TimePeriod period)
{
- AnimateTo( target, destinationValue, mDefaultAlpha, period );
+ AnimateTo(target, std::move(destinationValue), mDefaultAlpha, period);
}
-void Animation::AnimateTo( Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period )
+void Animation::AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
{
Object& object = GetImplementation( target.object );
const Property::Type propertyType = object.GetPropertyType( target.propertyIndex );
ExtendDuration( period );
- // Store data to later notify the object that its property is being animated
- ConnectorTargetValues connectorPair;
- connectorPair.targetValue = destinationValue;
- connectorPair.connectorIndex = mConnectors.Count();
- connectorPair.timePeriod = period;
- connectorPair.animatorType = Animation::TO;
- mConnectorTargetValues.push_back( connectorPair );
+ // keep the current count.
+ auto connectorIndex = mConnectors.Count();
// using destination type so component animation gets correct type
switch ( destinationType )
default:
{
- // non animatable types handled already
+ DALI_ASSERT_DEBUG(false && "Property not supported");
}
}
+ // Store data to later notify the object that its property is being animated
+ mConnectorTargetValues.push_back({std::move(destinationValue), period, connectorIndex, Animation::TO});
}
void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames )
ExtendDuration( period );
// Store data to later notify the object that its property is being animated
- ConnectorTargetValues connectorPair;
- connectorPair.targetValue = keyFrames.GetLastKeyFrameValue();
- connectorPair.connectorIndex = mConnectors.Count();
- connectorPair.timePeriod = period;
- connectorPair.animatorType = BETWEEN;
- mConnectorTargetValues.push_back( connectorPair );
+ mConnectorTargetValues.push_back({keyFrames.GetLastKeyFrameValue(), period, mConnectors.Count(), BETWEEN});
// using destination type so component animation gets correct type
switch( destinationType )
default:
{
- // non animatable types handled by keyframes
+ DALI_ASSERT_DEBUG(false && "Property not supported");
}
}
}
/**
* @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue)
*/
- void AnimateBy(Property& target, Property::Value& relativeValue);
+ void AnimateBy(Property& target, Property::Value relativeValue);
/**
* @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
*/
- void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha);
+ void AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha);
/**
* @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
*/
- void AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period);
+ void AnimateBy(Property& target, Property::Value relativeValue, TimePeriod period);
/**
* @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
*/
- void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period);
+ void AnimateBy(Property& target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period);
/**
* @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue)
*/
- void AnimateTo(Property& target, Property::Value& destinationValue);
+ void AnimateTo(Property& target, Property::Value destinationValue);
/**
* @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
*/
- void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha);
+ void AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha);
/**
* @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
*/
- void AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period);
+ void AnimateTo(Property& target, Property::Value destinationValue, TimePeriod period);
/**
* @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
*/
- void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
+ void AnimateTo(Property& target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period);
/**
* @copydoc Dali::Animation::AnimateBetween(Property target, KeyFrames& keyFrames)
struct ConnectorTargetValues
{
- ConnectorTargetValues()
- : targetValue(),
- timePeriod( 0.0f ),
- connectorIndex( 0 ),
- animatorType( TO )
+ ConnectorTargetValues() = default;
+
+ ConnectorTargetValues(Property::Value value, TimePeriod time, std::size_t index, Animation::Type type)
+ : targetValue(std::move(value)),
+ timePeriod(time),
+ connectorIndex(index),
+ animatorType(type)
{
}
Property::Value targetValue;
- TimePeriod timePeriod;
- std::size_t connectorIndex;
- Animation::Type animatorType;
+ TimePeriod timePeriod{0.f};
+ std::size_t connectorIndex{0};
+ Animation::Type animatorType{TO};
};
enum class Notify
index = PROPERTY_CUSTOM_START_INDEX + static_cast<Property::Index>( mCustomProperties.Count() );
CustomPropertyMetadata* customProperty =
- new CustomPropertyMetadata(name, std::move(propertyValue), accessMode);
+ new CustomPropertyMetadata(std::move(name), std::move(propertyValue), accessMode);
// Resolve index for the child property
Object* parent = GetParentObject();
const TypeInfo* parentTypeInfo( parent->GetTypeInfo() );
if( parentTypeInfo )
{
- Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex( name );
+ Property::Index childPropertyIndex = parentTypeInfo->GetChildPropertyIndex( customProperty->name );
if( childPropertyIndex != Property::INVALID_INDEX )
{
customProperty->childPropertyIndex = childPropertyIndex;
return nullptr;
}
-Property::Index Object::RegisterSceneGraphProperty( const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue ) const
+Property::Index Object::RegisterSceneGraphProperty( std::string name, Property::Index key, Property::Index index, Property::Value propertyValue ) const
{
// Create a new property
Dali::Internal::OwnerPointer<PropertyBase> newProperty;
{
DALI_ASSERT_ALWAYS( index <= PROPERTY_CUSTOM_MAX_INDEX && "Too many custom properties have been registered" );
- mCustomProperties.PushBack( new CustomPropertyMetadata( name, key, propertyValue, property ) );
+ mCustomProperties.PushBack( new CustomPropertyMetadata( std::move(name), key, std::move(propertyValue), property ) );
}
else
{
- mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, propertyValue, property ) );
+ mAnimatableProperties.PushBack( new AnimatablePropertyMetadata( index, std::move(propertyValue), property ) );
}
// queue a message to add the property
* @param [in] value The value of the property.
* @return The index of the registered property or Property::INVALID_INDEX if registration failed.
*/
- Property::Index RegisterSceneGraphProperty( const std::string& name, Property::Index key, Property::Index index, const Property::Value& propertyValue ) const;
+ Property::Index RegisterSceneGraphProperty( std::string name, Property::Index key, Property::Index index, Property::Value propertyValue ) const;
/**
* Registers animatable scene property
* @param[in] sceneGraphProperty A pointer to the scene-graph owned property
* @param[in] writable Whether the property is writable
*/
- PropertyMetadata( const Property::Value& propertyValue,
+ PropertyMetadata( Property::Value propertyValue,
const SceneGraph::PropertyBase* sceneGraphProperty,
bool writable )
: value( mStoredValue ),
componentIndex( Property::INVALID_COMPONENT_INDEX ),
- mStoredValue( propertyValue ),
+ mStoredValue( std::move(propertyValue) ),
mSceneGraphProperty( sceneGraphProperty ),
mWritable( writable )
{
*
* @note A valid sceneGraphProperty is mandatory otherwise this will debug assert.
*/
- CustomPropertyMetadata( const std::string& propertyName,
+ CustomPropertyMetadata( std::string propertyName,
Property::Index propertyKey,
- const Property::Value& propertyValue,
+ Property::Value propertyValue,
const SceneGraph::PropertyBase* sceneGraphProperty )
- : PropertyMetadata( propertyValue, sceneGraphProperty, true ),
- name( propertyName ),
+ : PropertyMetadata( std::move(propertyValue), sceneGraphProperty, true ),
+ name( std::move(propertyName) ),
key( propertyKey ),
childPropertyIndex( Property::INVALID_INDEX )
{
*
* @note The access mode MUST NOT be animatable otherwise this will debug assert.
*/
- CustomPropertyMetadata( const std::string& propertyName,
- const Property::Value& propertyValue,
+ CustomPropertyMetadata( std::string propertyName,
+ Property::Value propertyValue,
Property::AccessMode accessMode )
- : PropertyMetadata( propertyValue, nullptr, ( accessMode != Property::READ_ONLY ) ),
- name( propertyName ),
+ : PropertyMetadata( std::move(propertyValue), nullptr, ( accessMode != Property::READ_ONLY ) ),
+ name( std::move(propertyName) ),
key( Property::INVALID_KEY ),
childPropertyIndex( Property::INVALID_INDEX )
{
void Animation::AnimateBy(Property target, Property::Value relativeValue)
{
- GetImplementation(*this).AnimateBy(target, relativeValue);
+ GetImplementation(*this).AnimateBy(target, std::move(relativeValue));
}
void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
{
- GetImplementation(*this).AnimateBy(target, relativeValue, alpha);
+ GetImplementation(*this).AnimateBy(target, std::move(relativeValue), alpha);
}
void Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
{
- GetImplementation(*this).AnimateBy(target, relativeValue, period);
+ GetImplementation(*this).AnimateBy(target, std::move(relativeValue), period);
}
void Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
{
- GetImplementation(*this).AnimateBy(target, relativeValue, alpha, period);
+ GetImplementation(*this).AnimateBy(target, std::move(relativeValue), alpha, period);
}
void Animation::AnimateTo(Property target, Property::Value destinationValue)
{
- GetImplementation(*this).AnimateTo(target, destinationValue);
+ GetImplementation(*this).AnimateTo(target, std::move(destinationValue));
}
void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
{
- GetImplementation(*this).AnimateTo(target, destinationValue, alpha);
+ GetImplementation(*this).AnimateTo(target, std::move(destinationValue), alpha);
}
void Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
{
- GetImplementation(*this).AnimateTo(target, destinationValue, period);
+ GetImplementation(*this).AnimateTo(target, std::move(destinationValue), period);
}
void Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
{
- GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period);
+ GetImplementation(*this).AnimateTo(target, std::move(destinationValue), alpha, period);
}
void Animation::AnimateBetween(Property target, KeyFrames& keyFrames)