-#ifndef __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H
+#define DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H
/*
- * Copyright (c) 2015 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.
* However if the property was only "Set" (and not "Baked"), then typically the base value and previous value will not match.
* In this case the reset operation is equivalent to a "Bake", and the value is considered "dirty" for an additional frame.
*/
-static const unsigned int CLEAN_FLAG = 0x00; ///< Indicates that the value did not change in this, or the previous frame
-static const unsigned int BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame
-static const unsigned int SET_FLAG = 0x02; ///< Indicates that the value was Set during the previous frame
+static const uint32_t CLEAN_FLAG = 0x00; ///< Indicates that the value did not change in this, or the previous frame
+static const uint32_t BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame
+static const uint32_t SET_FLAG = 0x02; ///< Indicates that the value was Set during the previous frame
template <class T>
class AnimatableProperty;
protected: // so that ResetToBaseValue can set it directly
- unsigned int mDirtyFlags; ///< Flag whether value changed during previous 2 frames
+ uint32_t mDirtyFlags; ///< Flag whether value changed during previous 2 frames
};
// false + false does not change value, true + false does not either
if( delta && !mValue[bufferIndex] )
{
- mValue[bufferIndex] += delta;
+ mValue[bufferIndex] = delta;
OnSet();
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- bool& Get(size_t bufferIndex)
+ bool& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const bool& Get(size_t bufferIndex) const
+ const bool& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- bool& operator[](size_t bufferIndex)
+ bool& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const bool& operator[](size_t bufferIndex) const
+ const bool& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
if( mBaseValue != 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();
}
*/
void BakeRelative(BufferIndex bufferIndex, bool delta)
{
- mValue[bufferIndex] += delta;
+ mValue[bufferIndex] = mValue[bufferIndex] || delta;
mBaseValue = mValue[bufferIndex];
OnBake();
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- int& Get(size_t bufferIndex)
+ int& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const int& Get(size_t bufferIndex) const
+ const int& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- int& operator[](size_t bufferIndex)
+ int& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const int& operator[](size_t bufferIndex) const
+ const int& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
void Bake(BufferIndex bufferIndex, int value)
{
mValue[bufferIndex] = value;
+ mValue[1-bufferIndex] = value;
mBaseValue = mValue[bufferIndex];
OnBake();
};
/**
- * An unsigned integer animatable property of a scene-graph object.
- */
-template <>
-class AnimatableProperty<unsigned int> : public AnimatablePropertyBase
-{
-public:
-
- /**
- * Create an animatable property.
- * @param [in] initialValue The initial value of the property.
- */
- AnimatableProperty( unsigned int initialValue )
- : mValue( initialValue ),
- mBaseValue( initialValue )
- {
- }
-
- /**
- * Virtual destructor.
- */
- virtual ~AnimatableProperty()
- {
- }
-
- /**
- * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
- */
- virtual Dali::Property::Type GetType() const
- {
- return Dali::PropertyTypes::Get<unsigned int>();
- }
-
- /**
- * @copydoc Dali::Internal::SceneGraph::PropertyBase::ResetToBaseValue()
- */
- virtual void ResetToBaseValue(BufferIndex updateBufferIndex)
- {
- if (CLEAN_FLAG != mDirtyFlags)
- {
- mValue[updateBufferIndex] = mBaseValue;
-
- mDirtyFlags = ( mDirtyFlags >> 1 );
- }
- }
-
- /**
- * @copydoc Dali::Internal::PropertyInputImpl::GetUnsignedInteger()
- */
- virtual const unsigned int& GetUnsignedInteger( BufferIndex bufferIndex ) const
- {
- return mValue[ bufferIndex ];
- }
-
- /**
- * 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 property value.
- */
- void Set(BufferIndex bufferIndex, unsigned int value)
- {
- mValue[bufferIndex] = 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.
- */
- void SetRelative(BufferIndex bufferIndex, unsigned int delta)
- {
- mValue[bufferIndex] = mValue[bufferIndex] + delta;
-
- OnSet();
- }
-
- /**
- * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
- */
- unsigned int& Get(size_t bufferIndex)
- {
- return mValue[bufferIndex];
- }
-
- /**
- * @copydoc Dali::SceneGraph::AnimatableProperty::Get()
- */
- const unsigned int& Get(size_t bufferIndex) const
- {
- return mValue[bufferIndex];
- }
-
- /**
- * Retrieve the property value.
- * @param[in] bufferIndex The buffer to read.
- * @return The property value.
- */
- unsigned int& operator[](size_t bufferIndex)
- {
- return mValue[bufferIndex];
- }
-
- /**
- * Retrieve the property value.
- * @param[in] bufferIndex The buffer to read.
- * @return The property value.
- */
- const unsigned int& operator[](size_t bufferIndex) const
- {
- return mValue[bufferIndex];
- }
-
- /**
- * Set both the property value & base value.
- * @param[in] bufferIndex The buffer to write for the property value.
- * @param[in] value The new property value.
- */
- void Bake(BufferIndex bufferIndex, unsigned int value)
- {
- mValue[bufferIndex] = value;
- mBaseValue = mValue[bufferIndex];
-
- 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.
- */
- void BakeRelative(BufferIndex bufferIndex, unsigned int delta)
- {
- mValue[bufferIndex] = mValue[bufferIndex] + delta;
- mBaseValue = mValue[bufferIndex];
-
- OnBake();
- }
-
- /**
- * Sets both double-buffered values & the base value.
- * 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 unsigned int& value)
- {
- mValue[0] = value;
- mValue[1] = mValue[0];
- mBaseValue = mValue[0];
- }
-
- /**
- * Change both double-buffered values & the base value by a relative amount.
- * 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 unsigned int& delta)
- {
- mValue[0] = mValue[0] + delta;
- mValue[1] = mValue[0];
- mBaseValue = mValue[0];
- }
-
-private:
-
- // Undefined
- AnimatableProperty(const AnimatableProperty& property);
-
- // Undefined
- AnimatableProperty& operator=(const AnimatableProperty& rhs);
-
-private:
- DoubleBuffered<unsigned int> mValue; ///< The double-buffered property value
- unsigned int mBaseValue; ///< Reset to this base value at the beginning of each frame
-};
-
-
-/**
* An float animatable property of a scene-graph object.
*/
template <>
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- float& Get(size_t bufferIndex)
+ float& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const float& Get(size_t bufferIndex) const
+ const float& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- float& operator[](size_t bufferIndex)
+ float& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const float& operator[](size_t bufferIndex) const
+ const float& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
*/
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();
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Vector2& Get(size_t bufferIndex)
+ Vector2& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Vector2& Get(size_t bufferIndex) const
+ const Vector2& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Vector2& operator[](size_t bufferIndex)
+ Vector2& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector2& operator[](size_t bufferIndex) const
+ const Vector2& operator[]( BufferIndex bufferIndex ) const
{
return mValue[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();
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();
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Vector3& Get(size_t bufferIndex)
+ Vector3& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Vector3& Get(size_t bufferIndex) const
+ const Vector3& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Vector3& operator[](size_t bufferIndex)
+ Vector3& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector3& operator[](size_t bufferIndex) const
+ const Vector3& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
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();
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Vector4& Get(size_t bufferIndex)
+ Vector4& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Vector4& Get(size_t bufferIndex) const
+ const Vector4& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Vector4& operator[](size_t bufferIndex)
+ Vector4& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Vector4& operator[](size_t bufferIndex) const
+ const Vector4& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
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();
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Quaternion& Get(size_t bufferIndex)
+ Quaternion& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Quaternion& Get(size_t bufferIndex) const
+ const Quaternion& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Quaternion& operator[](size_t bufferIndex)
+ Quaternion& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Quaternion& operator[](size_t bufferIndex) const
+ const Quaternion& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
*/
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();
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Matrix& Get(size_t bufferIndex)
+ Matrix& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Matrix& Get(size_t bufferIndex) const
+ const Matrix& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Matrix& operator[](size_t bufferIndex)
+ Matrix& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Matrix& operator[](size_t bufferIndex) const
+ const Matrix& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
*/
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();
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- Matrix3& Get(size_t bufferIndex)
+ Matrix3& Get( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
/**
* @copydoc Dali::SceneGraph::AnimatableProperty::Get()
*/
- const Matrix3& Get(size_t bufferIndex) const
+ const Matrix3& Get( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- Matrix3& operator[](size_t bufferIndex)
+ Matrix3& operator[]( BufferIndex bufferIndex )
{
return mValue[bufferIndex];
}
* @param[in] bufferIndex The buffer to read.
* @return The property value.
*/
- const Matrix3& operator[](size_t bufferIndex) const
+ const Matrix3& operator[]( BufferIndex bufferIndex ) const
{
return mValue[bufferIndex];
}
*/
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();
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, T > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* 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,
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, const T& > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* 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,
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* 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,
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* 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,
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* 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,
typedef MessageDoubleBuffered1< SceneGraph::AnimatableProperty<T>, float > LocalType;
// Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+ uint32_t* 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,
} // namespace Dali
-#endif // __DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H