#define __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
#include <dali/public-api/object/property-input.h>
#include <dali/public-api/object/property-types.h>
#include <dali/internal/common/message.h>
-#include <dali/internal/common/event-to-update.h>
+#include <dali/internal/event/common/event-thread-services.h>
#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-base.h>
*/
void Bake(BufferIndex bufferIndex, bool value)
{
- // check if the value actually changed to avoid dirtying nodes unnecessarily
- if( mValue[bufferIndex] != value )
+ // bake has to check the base value as current buffer value can be correct by constraint or something else
+ if( mBaseValue != value )
{
- mValue[bufferIndex] = value;
mBaseValue = value;
+ // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
+ // has never been atomically safe.
+ mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
OnBake();
}
};
+
/**
- * An float animatable property of a scene-graph object.
+ * An integer animatable property of a scene-graph object.
*/
template <>
-class AnimatableProperty<float> : public AnimatablePropertyBase
+class AnimatableProperty<int> : public AnimatablePropertyBase
{
public:
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( float initialValue )
+ AnimatableProperty( int initialValue )
: mValue( initialValue ),
mBaseValue( initialValue )
{
*/
virtual Dali::Property::Type GetType() const
{
- return Dali::PropertyTypes::Get<float>();
+ return Dali::PropertyTypes::Get<int>();
}
/**
}
/**
- * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
+ * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
*/
- virtual const float& GetFloat( BufferIndex bufferIndex ) const
+ virtual const int& GetInteger( BufferIndex bufferIndex ) const
{
return mValue[ bufferIndex ];
}
* @param[in] bufferIndex The buffer to write.
* @param[in] value The new property value.
*/
- void Set(BufferIndex bufferIndex, float value)
+ void Set(BufferIndex bufferIndex, int value)
{
mValue[bufferIndex] = value;
* @param[in] bufferIndex The buffer to write.
* @param[in] delta The property will change by this amount.
*/
- void SetRelative(BufferIndex bufferIndex, float delta)
+ void SetRelative(BufferIndex bufferIndex, int delta)
{
mValue[bufferIndex] = mValue[bufferIndex] + delta;
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- float& Get(size_t bufferIndex)
+ int& Get(size_t bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const float& Get(size_t bufferIndex) const
+ const int& Get(size_t bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- float& operator[](size_t bufferIndex)
+ int& operator[](size_t bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const float& operator[](size_t bufferIndex) const
+ const int& operator[](size_t bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to write for the property value.
* @param[in] value The new property value.
*/
- void Bake(BufferIndex bufferIndex, float value)
+ void Bake(BufferIndex bufferIndex, int value)
{
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = mValue[bufferIndex];
OnBake();
* @param[in] bufferIndex The buffer to write for the local property value.
* @param[in] delta The property will change by this amount.
*/
- void BakeRelative(BufferIndex bufferIndex, float delta)
+ void BakeRelative(BufferIndex bufferIndex, int delta)
{
mValue[bufferIndex] = mValue[bufferIndex] + delta;
mBaseValue = mValue[bufferIndex];
* This should only be used when the owning object has not been connected to the scene-graph.
* @param[in] value The new property value.
*/
- void SetInitial(const float& value)
+ void SetInitial(const int& value)
{
mValue[0] = value;
mValue[1] = mValue[0];
* This should only be used when the owning object has not been connected to the scene-graph.
* @param[in] delta The property will change by this amount.
*/
- void SetInitialRelative(const float& delta)
+ void SetInitialRelative(const int& delta)
{
mValue[0] = mValue[0] + delta;
mValue[1] = mValue[0];
private:
- DoubleBuffered<float> mValue; ///< The double-buffered property value
- float mBaseValue; ///< Reset to this base value at the beginning of each frame
+ DoubleBuffered<int> mValue; ///< The double-buffered property value
+ int mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
- * An integer animatable property of a scene-graph object.
+ * An float animatable property of a scene-graph object.
*/
template <>
-class AnimatableProperty<int> : public AnimatablePropertyBase
+class AnimatableProperty<float> : public AnimatablePropertyBase
{
public:
* Create an animatable property.
* @param [in] initialValue The initial value of the property.
*/
- AnimatableProperty( int initialValue )
+ AnimatableProperty( float initialValue )
: mValue( initialValue ),
mBaseValue( initialValue )
{
*/
virtual Dali::Property::Type GetType() const
{
- return Dali::PropertyTypes::Get<int>();
+ return Dali::PropertyTypes::Get<float>();
}
/**
}
/**
- * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
+ * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
*/
- virtual const int& GetInteger( BufferIndex bufferIndex ) const
+ virtual const float& GetFloat( BufferIndex bufferIndex ) const
{
return mValue[ bufferIndex ];
}
* @param[in] bufferIndex The buffer to write.
* @param[in] value The new property value.
*/
- void Set(BufferIndex bufferIndex, int value)
+ void Set(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex] = value;
* @param[in] bufferIndex The buffer to write.
* @param[in] delta The property will change by this amount.
*/
- void SetRelative(BufferIndex bufferIndex, int delta)
+ void SetRelative(BufferIndex bufferIndex, float delta)
{
mValue[bufferIndex] = mValue[bufferIndex] + delta;
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- int& Get(size_t bufferIndex)
+ float& Get(size_t bufferIndex)
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const int& Get(size_t bufferIndex) const
+ const float& Get(size_t bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- int& operator[](size_t bufferIndex)
+ float& operator[](size_t bufferIndex)
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const int& operator[](size_t bufferIndex) const
+ const float& operator[](size_t bufferIndex) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to write for the property value.
* @param[in] value The new property value.
*/
- void Bake(BufferIndex bufferIndex, int value)
+ void Bake(BufferIndex bufferIndex, float value)
{
+ // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
+ // has never been atomically safe.
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = mValue[bufferIndex];
OnBake();
* @param[in] bufferIndex The buffer to write for the local property value.
* @param[in] delta The property will change by this amount.
*/
- void BakeRelative(BufferIndex bufferIndex, int delta)
+ void BakeRelative(BufferIndex bufferIndex, float delta)
{
mValue[bufferIndex] = mValue[bufferIndex] + delta;
mBaseValue = mValue[bufferIndex];
* This should only be used when the owning object has not been connected to the scene-graph.
* @param[in] value The new property value.
*/
- void SetInitial(const int& value)
+ void SetInitial(const float& value)
{
mValue[0] = value;
mValue[1] = mValue[0];
* This should only be used when the owning object has not been connected to the scene-graph.
* @param[in] delta The property will change by this amount.
*/
- void SetInitialRelative(const int& delta)
+ void SetInitialRelative(const float& delta)
{
mValue[0] = mValue[0] + delta;
mValue[1] = mValue[0];
private:
- DoubleBuffered<int> mValue; ///< The double-buffered property value
- int mBaseValue; ///< Reset to this base value at the beginning of each frame
-
+ DoubleBuffered<float> mValue; ///< The double-buffered property value
+ float mBaseValue; ///< Reset to this base value at the beginning of each frame
};
/**
}
/**
+ * Set the property value. This will only persist for the current frame; the property
+ * will be reset with the base value, at the beginning of the next frame.
+ * @param[in] bufferIndex The buffer to write.
+ * @param[in] value The new X value.
+ */
+ void SetX(BufferIndex bufferIndex, float value)
+ {
+ mValue[bufferIndex].x = value;
+
+ OnSet();
+ }
+
+ /**
+ * Set the property value. This will only persist for the current frame; the property
+ * will be reset with the base value, at the beginning of the next frame.
+ * @param[in] bufferIndex The buffer to write.
+ * @param[in] value The new Y value.
+ */
+ void SetY(BufferIndex bufferIndex, float value)
+ {
+ mValue[bufferIndex].y = value;
+
+ OnSet();
+ }
+
+ /**
* Change the property value by a relative amount.
* @param[in] bufferIndex The buffer to write.
* @param[in] delta The property will change by this amount.
}
/**
+ * Change the X value by a relative amount.
+ * @param[in] bufferIndex The buffer to write.
+ * @param[in] delta The X value will change by this amount.
+ */
+ void SetXRelative(BufferIndex bufferIndex, float delta)
+ {
+ mValue[bufferIndex].x += delta;
+
+ OnSet();
+ }
+
+ /**
+ * Change the Y value by a relative amount.
+ * @param[in] bufferIndex The buffer to write.
+ * @param[in] delta The Y value will change by this amount.
+ */
+ void SetYRelative(BufferIndex bufferIndex, float delta)
+ {
+ mValue[bufferIndex].y += delta;
+
+ OnSet();
+ }
+
+ /**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
Vector2& Get(size_t bufferIndex)
*/
void Bake(BufferIndex bufferIndex, const Vector2& value)
{
+ // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
+ // has never been atomically safe.
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = value;
OnBake();
}
/**
+ * Set both the X value & base X value.
+ * @param[in] bufferIndex The buffer to write for the property value.
+ * @param[in] value The new property value.
+ */
+ void BakeX(BufferIndex bufferIndex, float value)
+ {
+ mValue[bufferIndex].x = value;
+ mValue[1-bufferIndex].x = value;
+ mBaseValue.x = value;
+
+ OnBake();
+ }
+
+ /**
+ * Set both the Y value & base Y value.
+ * @param[in] bufferIndex The buffer to write for the property value.
+ * @param[in] value The new property value.
+ */
+ void BakeY(BufferIndex bufferIndex, float value)
+ {
+ mValue[bufferIndex].y = value;
+ mValue[1-bufferIndex].y = value;
+ mBaseValue.y = value;
+
+ OnBake();
+ }
+
+ /**
* Change the property value & base value by a relative amount.
* @param[in] bufferIndex The buffer to write for the local property value.
* @param[in] delta The property will change by this amount.
OnBake();
}
+ /**
+ * Change the X value & base X value by a relative amount.
+ * @param[in] bufferIndex The buffer to write for the local property value.
+ * @param[in] delta The X value will change by this amount.
+ */
+ void BakeXRelative(BufferIndex bufferIndex, float delta)
+ {
+ mValue[bufferIndex].x += delta;
+ mBaseValue.x = mValue[bufferIndex].x;
+
+ OnBake();
+ }
+
+ /**
+ * Change the Y value & base Y value by a relative amount.
+ * @param[in] bufferIndex The buffer to write for the local property value.
+ * @param[in] delta The Y value will change by this amount.
+ */
+ void BakeYRelative(BufferIndex bufferIndex, float delta)
+ {
+ mValue[bufferIndex].y += delta;
+ mBaseValue.y = mValue[bufferIndex].y;
+
+ OnBake();
+ }
+
private:
// Undefined
void Bake(BufferIndex bufferIndex, const Vector3& value)
{
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = value;
OnBake();
void BakeX(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex].x = value;
+ mValue[1-bufferIndex].x = value;
mBaseValue.x = value;
OnBake();
void BakeY(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex].y = value;
+ mValue[1-bufferIndex].y = value;
mBaseValue.y = value;
OnBake();
void BakeZ(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex].z = value;
+ mValue[1-bufferIndex].z = value;
mBaseValue.z = value;
OnBake();
void Bake(BufferIndex bufferIndex, const Vector4& value)
{
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = mValue[bufferIndex];
OnBake();
void BakeX(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex].x = value;
+ mValue[1-bufferIndex].x = value;
mBaseValue.x = mValue[bufferIndex].x;
OnBake();
void BakeY(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex].y = value;
+ mValue[1-bufferIndex].y = value;
mBaseValue.y = mValue[bufferIndex].y;
OnBake();
void BakeZ(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex].z = value;
+ mValue[1-bufferIndex].z = value;
mBaseValue.z = mValue[bufferIndex].z;
OnBake();
void BakeW(BufferIndex bufferIndex, float value)
{
mValue[bufferIndex].w = value;
+ mValue[1-bufferIndex].w = value;
mBaseValue.w = mValue[bufferIndex].w;
OnBake();
*/
void Bake(BufferIndex bufferIndex, const Quaternion& value)
{
+ // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
+ // has never been atomically safe.
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = value;
OnBake();
*/
void Bake(BufferIndex bufferIndex, const Matrix& value)
{
+ // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
+ // has never been atomically safe.
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = mValue[bufferIndex];
OnBake();
*/
void Bake(BufferIndex bufferIndex, const Matrix3& value)
{
+ // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side
+ // has never been atomically safe.
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = mValue[bufferIndex];
OnBake();
// Messages for AnimatableProperty<T>
template <class T>
-void BakeMessage( EventToUpdate& eventToUpdate,
+void BakeMessage( EventThreadServices& eventThreadServices,
const SceneGraph::AnimatableProperty<T>& property,
typename ParameterType< T >::PassingType newValue )
{
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, T > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
new (slot) LocalType( &property,
}
template <class T>
-void BakeRelativeMessage( EventToUpdate& eventToUpdate,
+void BakeRelativeMessage( EventThreadServices& eventThreadServices,
const SceneGraph::AnimatableProperty<T>& property,
const T& delta )
{
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, const T& > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
new (slot) LocalType( &property,
}
template <class T>
-void SetXComponentMessage( EventToUpdate& eventToUpdate,
+void SetXComponentMessage( EventThreadServices& eventThreadServices,
const SceneGraph::AnimatableProperty<T>& property,
typename ParameterType< float >::PassingType newValue )
{
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
new (slot) LocalType( &property,
}
template <class T>
-void SetYComponentMessage( EventToUpdate& eventToUpdate,
+void SetYComponentMessage( EventThreadServices& eventThreadServices,
const SceneGraph::AnimatableProperty<T>& property,
typename ParameterType< float >::PassingType newValue )
{
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
new (slot) LocalType( &property,
}
template <class T>
-void SetZComponentMessage( EventToUpdate& eventToUpdate,
+void SetZComponentMessage( EventThreadServices& eventThreadServices,
const SceneGraph::AnimatableProperty<T>& property,
typename ParameterType< float >::PassingType newValue )
{
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
new (slot) LocalType( &property,
}
template <class T>
-void SetWComponentMessage( EventToUpdate& eventToUpdate,
+void SetWComponentMessage( EventThreadServices& eventThreadServices,
const SceneGraph::AnimatableProperty<T>& property,
typename ParameterType< float >::PassingType newValue )
{
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
// Construct message in the message queue memory; note that delete should not be called on the return value
new (slot) LocalType( &property,