[Tizen] Fix memory leak issue in dali core
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 6ca8901..4ad7d29
@@ -1056,19 +1056,7 @@ Matrix Actor::GetCurrentWorldMatrix() const
 
 void Actor::SetVisible( bool visible )
 {
-  if( mVisible != visible )
-  {
-    if( NULL != mNode )
-    {
-      // mNode is being used in a separate thread; queue a message to set the value & base value
-      SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), mNode, &mNode->mVisible, &AnimatableProperty<bool>::Bake, visible );
-    }
-
-    mVisible = visible;
-
-    // Emit the signal on this actor and all its children
-    EmitVisibilityChangedSignalRecursively( this, visible, DevelActor::VisibilityChange::SELF );
-  }
+  SetVisibleInternal( visible, SendMessage::TRUE );
 }
 
 bool Actor::IsVisible() const
@@ -1290,53 +1278,6 @@ void Actor::SetSizeInternal( const Vector3& size )
   }
 }
 
-void Actor::NotifySizeAnimation( Animation& animation, const Vector3& targetSize )
-{
-  mTargetSize = targetSize;
-
-  // Notify deriving classes
-  OnSizeAnimation( animation, mTargetSize );
-}
-
-void Actor::NotifySizeAnimation( Animation& animation, float targetSize, Property::Index property )
-{
-  if ( Dali::Actor::Property::SIZE_WIDTH == property )
-  {
-    mTargetSize.width = targetSize;
-  }
-  else if ( Dali::Actor::Property::SIZE_HEIGHT == property )
-  {
-    mTargetSize.height = targetSize;
-  }
-  else if ( Dali::Actor::Property::SIZE_DEPTH == property )
-  {
-    mTargetSize.depth = targetSize;
-  }
-  // Notify deriving classes
-  OnSizeAnimation( animation, mTargetSize );
-}
-
-void Actor::NotifyPositionAnimation( Animation& animation, const Vector3& targetPosition )
-{
-  mTargetPosition = targetPosition;
-}
-
-void Actor::NotifyPositionAnimation( Animation& animation, float targetPosition, Property::Index property )
-{
-  if ( Dali::Actor::Property::POSITION_X == property )
-  {
-    mTargetPosition.x = targetPosition;
-  }
-  else if ( Dali::Actor::Property::POSITION_Y == property )
-  {
-    mTargetPosition.y = targetPosition;
-  }
-  else if ( Dali::Actor::Property::POSITION_Z == property )
-  {
-    mTargetPosition.z = targetPosition;
-  }
-}
-
 void Actor::SetWidth( float width )
 {
   if( IsRelayoutEnabled() && !mRelayoutData->insideRelayout )
@@ -2505,6 +2446,7 @@ void Actor::RebuildDepthTree()
 
   SetDepthIndicesMessage( GetEventThreadServices().GetUpdateManager(), sceneGraphNodeDepths );
   DALI_LOG_TIMER_END(depthTimer, gLogFilter, Debug::Concise, "Depth tree create time: ");
+  rootNode->~ActorDepthTreeNode();
 }
 
 /**
@@ -3301,6 +3243,310 @@ Property::Value Actor::GetDefaultPropertyCurrentValue( Property::Index index ) c
   return value;
 }
 
+void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType )
+{
+  switch( animationType )
+  {
+    case Animation::TO:
+    case Animation::BETWEEN:
+    {
+      switch( index )
+      {
+        case Dali::Actor::Property::SIZE:
+        {
+          if( value.Get( mTargetSize ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SIZE_WIDTH:
+        {
+          if( value.Get( mTargetSize.width ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SIZE_HEIGHT:
+        {
+          if( value.Get( mTargetSize.height ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SIZE_DEPTH:
+        {
+          if( value.Get( mTargetSize.depth ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION:
+        {
+          value.Get( mTargetPosition );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_X:
+        {
+          value.Get( mTargetPosition.x );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_Y:
+        {
+          value.Get( mTargetPosition.y );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_Z:
+        {
+          value.Get( mTargetPosition.z );
+          break;
+        }
+
+        case Dali::Actor::Property::ORIENTATION:
+        {
+          value.Get( mTargetOrientation );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE:
+        {
+          value.Get( mTargetScale );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_X:
+        {
+          value.Get( mTargetScale.x );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_Y:
+        {
+          value.Get( mTargetScale.y );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_Z:
+        {
+          value.Get( mTargetScale.z );
+          break;
+        }
+
+        case Dali::Actor::Property::VISIBLE:
+        {
+          SetVisibleInternal( value.Get< bool >(), SendMessage::FALSE );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR:
+        {
+          value.Get( mTargetColor );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_RED:
+        {
+          value.Get( mTargetColor.r );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_GREEN:
+        {
+          value.Get( mTargetColor.g );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_BLUE:
+        {
+          value.Get( mTargetColor.b );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_ALPHA:
+        case Dali::DevelActor::Property::OPACITY:
+        {
+          value.Get( mTargetColor.a );
+          break;
+        }
+
+        default:
+        {
+          // Not an animatable property. Do nothing.
+          break;
+        }
+      }
+      break;
+    }
+
+    case Animation::BY:
+    {
+      switch( index )
+      {
+        case Dali::Actor::Property::SIZE:
+        {
+          if( AdjustValue< Vector3 >( mTargetSize, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SIZE_WIDTH:
+        {
+          if( AdjustValue< float >( mTargetSize.width, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SIZE_HEIGHT:
+        {
+          if( AdjustValue< float >( mTargetSize.height, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SIZE_DEPTH:
+        {
+          if( AdjustValue< float >( mTargetSize.depth, value ) )
+          {
+            // Notify deriving classes
+            OnSizeAnimation( animation, mTargetSize );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION:
+        {
+          AdjustValue< Vector3 >( mTargetPosition, value );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_X:
+        {
+          AdjustValue< float >( mTargetPosition.x, value );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_Y:
+        {
+          AdjustValue< float >( mTargetPosition.y, value );
+          break;
+        }
+
+        case Dali::Actor::Property::POSITION_Z:
+        {
+          AdjustValue< float >( mTargetPosition.z, value );
+          break;
+        }
+
+        case Dali::Actor::Property::ORIENTATION:
+        {
+          Quaternion relativeValue;
+          if( value.Get( relativeValue ) )
+          {
+            mTargetOrientation *= relativeValue;
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE:
+        {
+          AdjustValue< Vector3 >( mTargetScale, value );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_X:
+        {
+          AdjustValue< float >( mTargetScale.x, value );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_Y:
+        {
+          AdjustValue< float >( mTargetScale.y, value );
+          break;
+        }
+
+        case Dali::Actor::Property::SCALE_Z:
+        {
+          AdjustValue< float >( mTargetScale.z, value );
+          break;
+        }
+
+        case Dali::Actor::Property::VISIBLE:
+        {
+          bool relativeValue = false;
+          if( value.Get( relativeValue ) )
+          {
+            bool visible = mVisible || relativeValue;
+            SetVisibleInternal( visible, SendMessage::FALSE );
+          }
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR:
+        {
+          AdjustValue< Vector4 >( mTargetColor, value );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_RED:
+        {
+          AdjustValue< float >( mTargetColor.r, value );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_GREEN:
+        {
+          AdjustValue< float >( mTargetColor.g, value );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_BLUE:
+        {
+          AdjustValue< float >( mTargetColor.b, value );
+          break;
+        }
+
+        case Dali::Actor::Property::COLOR_ALPHA:
+        case Dali::DevelActor::Property::OPACITY:
+        {
+          AdjustValue< float >( mTargetColor.a, value );
+          break;
+        }
+
+        default:
+        {
+          // Not an animatable property. Do nothing.
+          break;
+        }
+      }
+      break;
+    }
+  }
+}
+
 const SceneGraph::PropertyOwner* Actor::GetPropertyOwner() const
 {
   return mNode;
@@ -4223,6 +4469,12 @@ bool Actor::GetCurrentPropertyValue( Property::Index index, Property::Value& val
       break;
     }
 
+    case Dali::Actor::Property::VISIBLE:
+    {
+      value = IsVisible();
+      break;
+    }
+
     default:
     {
       // Must be an event-side only property
@@ -4979,6 +5231,23 @@ Object* Actor::GetParentObject() const
   return mParent;
 }
 
+void Actor::SetVisibleInternal( bool visible, SendMessage::Type sendMessage )
+{
+  if( mVisible != visible )
+  {
+    if( sendMessage == SendMessage::TRUE && NULL != mNode )
+    {
+      // mNode is being used in a separate thread; queue a message to set the value & base value
+      SceneGraph::NodePropertyMessage<bool>::Send( GetEventThreadServices(), mNode, &mNode->mVisible, &AnimatableProperty<bool>::Bake, visible );
+    }
+
+    mVisible = visible;
+
+    // Emit the signal on this actor and all its children
+    EmitVisibilityChangedSignalRecursively( this, visible, DevelActor::VisibilityChange::SELF );
+  }
+}
+
 void Actor::SetSiblingOrder( unsigned int order )
 {
   mSiblingOrder = std::min( order, static_cast<unsigned int>( DevelLayer::SIBLING_ORDER_MULTIPLIER ) );