Merge "Reduce Render::Renderer size" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-property-notification.cpp
index 82464fc..6fecc5e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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/internal/event/common/object-impl.h>
 #include <dali/internal/event/animation/property-constraint.h>
 #include <dali/internal/event/animation/property-input-accessor.h>
 #include <dali/internal/event/animation/property-input-indexer.h>
+#include <dali/internal/event/common/object-impl.h>
 #include <dali/internal/update/common/property-base.h>
+#include <dali/internal/update/common/property-condition-functions.h>
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/common/scene-graph-property-notification.h>
-#include <dali/internal/update/common/property-condition-functions.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-
 namespace SceneGraph
 {
-
-PropertyNotification* PropertyNotification::New(Object& object,
-                                                Property::Index propertyIndex,
-                                                Property::Type propertyType,
-                                                int componentIndex,
-                                                ConditionType condition,
-                                                RawArgumentContainer& arguments,
-                                                NotifyMode notifyMode)
+PropertyNotification* PropertyNotification::New(const PropertyInputImpl* property,
+                                                Property::Index          propertyIndex,
+                                                Property::Type           propertyType,
+                                                int                      componentIndex,
+                                                ConditionType            condition,
+                                                RawArgumentContainer&    arguments,
+                                                NotifyMode               notifyMode,
+                                                bool                     compare)
 {
-  return new PropertyNotification( object, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode );
+  return new PropertyNotification(property, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode, compare);
 }
 
-
-PropertyNotification::PropertyNotification(Object& object,
-                                           Property::Index propertyIndex,
-                                           Property::Type propertyType,
-                                           int componentIndex,
-                                           ConditionType condition,
-                                           RawArgumentContainer& arguments,
-                                           NotifyMode notifyMode)
-: mObject(&object),
-  mPropertyIndex(propertyIndex),
+PropertyNotification::PropertyNotification(const PropertyInputImpl* property,
+                                           Property::Index          propertyIndex,
+                                           Property::Type           propertyType,
+                                           int                      componentIndex,
+                                           ConditionType            condition,
+                                           RawArgumentContainer&    arguments,
+                                           NotifyMode               notifyMode,
+                                           bool                     compare)
+: mPropertyIndex(propertyIndex),
   mPropertyType(propertyType),
-  mProperty(NULL),
+  mProperty(property),
   mComponentIndex(componentIndex),
   mConditionType(condition),
   mArguments(arguments),
   mValid(false),
-  mNotifyMode( Dali::PropertyNotification::Disabled ),
-  mConditionFunction(NULL)
+  mNotifyMode(Dali::PropertyNotification::DISABLED),
+  mConditionFunction(nullptr)
 {
   SetNotifyMode(notifyMode);
 
@@ -89,7 +86,14 @@ PropertyNotification::PropertyNotification(Object& object,
     }
     case PropertyCondition::Step:
     {
-      mConditionFunction = Step::GetFunction(mPropertyType);
+      if(compare == true)
+      {
+        mConditionFunction = Step::GetCompareFunction(mPropertyType);
+      }
+      else
+      {
+        mConditionFunction = Step::GetFunction(mPropertyType);
+      }
       break;
     }
     case PropertyCondition::VariableStep:
@@ -103,73 +107,61 @@ PropertyNotification::PropertyNotification(Object& object,
       break;
     }
   }
-
-  mProperty = mObject->GetSceneObjectInputProperty( mPropertyIndex );
-  int internalComponentIndex = mObject->GetPropertyComponentIndex(mPropertyIndex);
-  if( internalComponentIndex != Property::INVALID_COMPONENT_INDEX )
-  {
-    // override the one passed in
-    mComponentIndex = internalComponentIndex;
-  }
 }
 
-PropertyNotification::~PropertyNotification()
-{
-}
+PropertyNotification::~PropertyNotification() = default;
 
-bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg )
+bool PropertyNotification::EvalFalse(const Dali::PropertyInput& value, RawArgumentContainer& arg)
 {
   return false;
 }
 
-void PropertyNotification::SetNotifyMode( NotifyMode notifyMode )
+void PropertyNotification::SetNotifyMode(NotifyMode notifyMode)
 {
   mNotifyMode = notifyMode;
 }
 
-bool PropertyNotification::Check( BufferIndex bufferIndex )
+bool PropertyNotification::Check(BufferIndex bufferIndex)
 {
   bool notifyRequired = false;
-  bool currentValid = false;
+  bool currentValid   = false;
 
-  if ( Property::INVALID_COMPONENT_INDEX != mComponentIndex )
+  if(Property::INVALID_COMPONENT_INDEX != mComponentIndex)
   {
     // Evaluate Condition
-    const PropertyInputAccessor component( mProperty, mComponentIndex );
-    const PropertyInputIndexer< PropertyInputAccessor > input( bufferIndex, &component );
+    const PropertyInputAccessor                       component(mProperty, mComponentIndex);
+    const PropertyInputIndexer<PropertyInputAccessor> input(bufferIndex, &component);
     currentValid = mConditionFunction(input, mArguments);
   }
   else
   {
     // Evaluate Condition
-    const PropertyInputIndexer< PropertyInputImpl > input( bufferIndex, mProperty );
+    const PropertyInputIndexer<PropertyInputImpl> input(bufferIndex, mProperty);
     currentValid = mConditionFunction(input, mArguments);
   }
 
-  if( mValid != currentValid
-      || (currentValid && ((mConditionType == PropertyCondition::Step)
-                        || (mConditionType == PropertyCondition::VariableStep))) )
+  if(mValid != currentValid || (currentValid && ((mConditionType == PropertyCondition::Step) || (mConditionType == PropertyCondition::VariableStep))))
   {
     mValid = currentValid;
     //  means don't notify so notifyRequired stays false
-    switch( mNotifyMode )
+    switch(mNotifyMode)
     {
-      case Dali::PropertyNotification::Disabled:
+      case Dali::PropertyNotification::DISABLED:
       {
         // notify never, already initialized to false
         break;
       }
-      case Dali::PropertyNotification::NotifyOnTrue:
+      case Dali::PropertyNotification::NOTIFY_ON_TRUE:
       {
         notifyRequired = mValid; // notify if value is true
         break;
       }
-      case Dali::PropertyNotification::NotifyOnFalse:
+      case Dali::PropertyNotification::NOTIFY_ON_FALSE:
       {
         notifyRequired = !mValid; // notify when its false
         break;
       }
-      case Dali::PropertyNotification::NotifyOnChanged:
+      case Dali::PropertyNotification::NOTIFY_ON_CHANGED:
       {
         notifyRequired = true; // notify whenever changed
         break;