Merge "Fix a bug in AnimatablePropertyRegistration with default value" into devel...
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-proxy-impl.cpp
index e6d1434..22b45a3 100644 (file)
@@ -18,6 +18,9 @@
 // CLASS HEADER
 #include <dali/internal/update/manager/update-proxy-impl.h>
 
+// INTERNAL INCLUDES
+#include <dali/internal/update/manager/update-proxy-property-modifier.h>
+
 namespace Dali
 {
 
@@ -27,7 +30,7 @@ namespace Internal
 namespace
 {
 
-SceneGraph::Node* FindNodeInSceneGraph( unsigned int id, SceneGraph::Node& node )
+SceneGraph::Node* FindNodeInSceneGraph( uint32_t id, SceneGraph::Node& node )
 {
   SceneGraph::Node* matchingNode = NULL;
 
@@ -52,12 +55,14 @@ SceneGraph::Node* FindNodeInSceneGraph( unsigned int id, SceneGraph::Node& node
 
 } // unnamed namespace
 
-UpdateProxy::UpdateProxy( SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode )
+UpdateProxy::UpdateProxy( SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode )
 : mNodeContainer(),
   mLastCachedIdNodePair( { 0u, NULL } ),
   mCurrentBufferIndex( 0u ),
+  mUpdateManager( updateManager ),
   mTransformManager( transformManager ),
-  mRootNode( rootNode )
+  mRootNode( rootNode ),
+  mPropertyModifier( nullptr )
 {
 }
 
@@ -65,7 +70,7 @@ UpdateProxy::~UpdateProxy()
 {
 }
 
-bool UpdateProxy::GetPosition( unsigned int id, Vector3& position ) const
+bool UpdateProxy::GetPosition( uint32_t id, Vector3& position ) const
 {
   bool success = false;
   const SceneGraph::Node* node = GetNodeWithId( id );
@@ -77,7 +82,7 @@ bool UpdateProxy::GetPosition( unsigned int id, Vector3& position ) const
   return success;
 }
 
-bool UpdateProxy::SetPosition( unsigned int id, const Vector3& position )
+bool UpdateProxy::SetPosition( uint32_t id, const Vector3& position )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -89,7 +94,7 @@ bool UpdateProxy::SetPosition( unsigned int id, const Vector3& position )
   return success;
 }
 
-bool UpdateProxy::BakePosition( unsigned int id, const Vector3& position )
+bool UpdateProxy::BakePosition( uint32_t id, const Vector3& position )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -101,7 +106,7 @@ bool UpdateProxy::BakePosition( unsigned int id, const Vector3& position )
   return success;
 }
 
-bool UpdateProxy::GetSize( unsigned int id, Vector3& size ) const
+bool UpdateProxy::GetSize( uint32_t id, Vector3& size ) const
 {
   bool success = false;
   const SceneGraph::Node* node = GetNodeWithId( id );
@@ -113,7 +118,7 @@ bool UpdateProxy::GetSize( unsigned int id, Vector3& size ) const
   return success;
 }
 
-bool UpdateProxy::SetSize( unsigned int id, const Vector3& size )
+bool UpdateProxy::SetSize( uint32_t id, const Vector3& size )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -125,7 +130,7 @@ bool UpdateProxy::SetSize( unsigned int id, const Vector3& size )
   return success;
 }
 
-bool UpdateProxy::BakeSize( unsigned int id, const Vector3& size )
+bool UpdateProxy::BakeSize( uint32_t id, const Vector3& size )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -137,7 +142,7 @@ bool UpdateProxy::BakeSize( unsigned int id, const Vector3& size )
   return success;
 }
 
-bool UpdateProxy::GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const
+bool UpdateProxy::GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const
 {
   bool success = false;
   const SceneGraph::Node* node = GetNodeWithId( id );
@@ -150,7 +155,7 @@ bool UpdateProxy::GetPositionAndSize( unsigned int id, Vector3& position, Vector
   return success;
 }
 
-bool UpdateProxy::GetScale( unsigned int id, Vector3& scale ) const
+bool UpdateProxy::GetScale( uint32_t id, Vector3& scale ) const
 {
   bool success = false;
   const SceneGraph::Node* node = GetNodeWithId( id );
@@ -163,7 +168,7 @@ bool UpdateProxy::GetScale( unsigned int id, Vector3& scale ) const
   return success;
 }
 
-bool UpdateProxy::SetScale( unsigned int id, const Vector3& scale )
+bool UpdateProxy::SetScale( uint32_t id, const Vector3& scale )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -175,7 +180,7 @@ bool UpdateProxy::SetScale( unsigned int id, const Vector3& scale )
   return success;
 }
 
-bool UpdateProxy::BakeScale( unsigned int id, const Vector3& scale )
+bool UpdateProxy::BakeScale( uint32_t id, const Vector3& scale )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -187,7 +192,7 @@ bool UpdateProxy::BakeScale( unsigned int id, const Vector3& scale )
   return success;
 }
 
-bool UpdateProxy::GetColor( unsigned int id, Vector4& color ) const
+bool UpdateProxy::GetColor( uint32_t id, Vector4& color ) const
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -200,19 +205,21 @@ bool UpdateProxy::GetColor( unsigned int id, Vector4& color ) const
   return success;
 }
 
-bool UpdateProxy::SetColor( unsigned int id, const Vector4& color ) const
+bool UpdateProxy::SetColor( uint32_t id, const Vector4& color )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
   if( node )
   {
     node->mColor.Set( mCurrentBufferIndex, color );
+    node->SetDirtyFlag( SceneGraph::NodePropertyFlags::COLOR );
+    AddResetter( *node, node->mColor );
     success = true;
   }
   return success;
 }
 
-bool UpdateProxy::BakeColor( unsigned int id, const Vector4& color ) const
+bool UpdateProxy::BakeColor( uint32_t id, const Vector4& color )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -228,9 +235,10 @@ void UpdateProxy::NodeHierarchyChanged()
 {
   mLastCachedIdNodePair = { 0u, NULL };
   mNodeContainer.clear();
+  mPropertyModifier.reset();
 }
 
-SceneGraph::Node* UpdateProxy::GetNodeWithId( unsigned int id ) const
+SceneGraph::Node* UpdateProxy::GetNodeWithId( uint32_t id ) const
 {
   SceneGraph::Node* node = NULL;
 
@@ -267,6 +275,15 @@ SceneGraph::Node* UpdateProxy::GetNodeWithId( unsigned int id ) const
   return node;
 }
 
+void UpdateProxy::AddResetter( SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase )
+{
+  if( ! mPropertyModifier )
+  {
+    mPropertyModifier = PropertyModifierPtr( new PropertyModifier( mUpdateManager ) );
+  }
+  mPropertyModifier->AddResetter( node, propertyBase );
+}
+
 } // namespace Internal
 
 } // namespace Dali