Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-proxy-impl.cpp
index 4763bc5..297391b 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
 {
 
@@ -29,7 +32,7 @@ namespace
 
 SceneGraph::Node* FindNodeInSceneGraph( uint32_t id, SceneGraph::Node& node )
 {
-  SceneGraph::Node* matchingNode = NULL;
+  SceneGraph::Node* matchingNode = nullptr;
 
   if( node.mId == id )
   {
@@ -52,18 +55,18 @@ SceneGraph::Node* FindNodeInSceneGraph( uint32_t 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 } ),
+  mLastCachedIdNodePair( { 0u, nullptr } ),
   mCurrentBufferIndex( 0u ),
+  mUpdateManager( updateManager ),
   mTransformManager( transformManager ),
-  mRootNode( rootNode )
+  mRootNode( rootNode ),
+  mPropertyModifier( nullptr )
 {
 }
 
-UpdateProxy::~UpdateProxy()
-{
-}
+UpdateProxy::~UpdateProxy() = default;
 
 bool UpdateProxy::GetPosition( uint32_t id, Vector3& position ) const
 {
@@ -200,19 +203,21 @@ bool UpdateProxy::GetColor( uint32_t id, Vector4& color ) const
   return success;
 }
 
-bool UpdateProxy::SetColor( uint32_t 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( uint32_t id, const Vector4& color ) const
+bool UpdateProxy::BakeColor( uint32_t id, const Vector4& color )
 {
   bool success = false;
   SceneGraph::Node* node = GetNodeWithId( id );
@@ -226,13 +231,14 @@ bool UpdateProxy::BakeColor( uint32_t id, const Vector4& color ) const
 
 void UpdateProxy::NodeHierarchyChanged()
 {
-  mLastCachedIdNodePair = { 0u, NULL };
+  mLastCachedIdNodePair = { 0u, nullptr };
   mNodeContainer.clear();
+  mPropertyModifier.reset();
 }
 
 SceneGraph::Node* UpdateProxy::GetNodeWithId( uint32_t id ) const
 {
-  SceneGraph::Node* node = NULL;
+  SceneGraph::Node* node = nullptr;
 
   // Cache the last accessed node so we don't have to traverse
   if( mLastCachedIdNodePair.node && mLastCachedIdNodePair.id == id )
@@ -267,6 +273,15 @@ SceneGraph::Node* UpdateProxy::GetNodeWithId( uint32_t 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