Avoid Heap allocation in UniformMap.
[platform/core/uifw/dali-core.git] / dali / internal / update / common / property-owner.cpp
index 87b3d31..bd23fe2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -24,6 +24,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
 #include <dali/internal/update/animation/scene-graph-constraint-base.h>
+#include <dali/internal/common/const-string.h>
 
 namespace Dali
 {
@@ -89,6 +90,8 @@ void PropertyOwner::Destroy()
 
 void PropertyOwner::ConnectToSceneGraph()
 {
+  mIsConnectedToSceneGraph = true;
+
   // Notification for observers
   const ConstObserverIter endIter = mObservers.End();
   for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
@@ -99,6 +102,8 @@ void PropertyOwner::ConnectToSceneGraph()
 
 void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex )
 {
+  mIsConnectedToSceneGraph = false;
+
   // Notification for observers
   const ConstObserverIter endIter = mObservers.End();
   for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter)
@@ -110,36 +115,21 @@ void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex )
   mConstraints.Clear();
 }
 
-void PropertyOwner::InstallCustomProperty(PropertyBase* property)
+void PropertyOwner::InstallCustomProperty( OwnerPointer<PropertyBase>& property )
 {
-  DALI_ASSERT_DEBUG( NULL != property );
-
-  mCustomProperties.PushBack( property );
+  mCustomProperties.PushBack( property.Release() );
 }
 
-void PropertyOwner::ResetToBaseValues( BufferIndex updateBufferIndex )
-{
-  // Reset custom properties
-  const OwnedPropertyIter endIter = mCustomProperties.End();
-  for ( OwnedPropertyIter iter = mCustomProperties.Begin(); endIter != iter; ++iter )
-  {
-    (*iter)->ResetToBaseValue( updateBufferIndex );
-  }
-
-  // Notification for derived classes, to reset default properties
-  ResetDefaultProperties( updateBufferIndex );
-}
 
 ConstraintOwnerContainer& PropertyOwner::GetConstraints()
 {
   return mConstraints;
 }
 
-void PropertyOwner::ApplyConstraint( ConstraintBase* constraint )
+void PropertyOwner::ApplyConstraint( OwnerPointer<ConstraintBase>& constraint )
 {
-  mConstraints.PushBack( constraint );
-
   constraint->OnConnect();
+  mConstraints.PushBack( constraint.Release() );
 }
 
 void PropertyOwner::RemoveConstraint( ConstraintBase* constraint )
@@ -158,15 +148,17 @@ void PropertyOwner::RemoveConstraint( ConstraintBase* constraint )
 }
 
 PropertyOwner::PropertyOwner()
+: mUpdated(false),
+  mIsConnectedToSceneGraph(false)
 {
 }
 
-void PropertyOwner::AddUniformMapping( UniformPropertyMapping* map )
+void PropertyOwner::AddUniformMapping(const UniformPropertyMapping& map)
 {
-  mUniformMaps.Add( map );
+  mUniformMaps.Add(map);
 }
 
-void PropertyOwner::RemoveUniformMapping( const std::string& uniformName )
+void PropertyOwner::RemoveUniformMapping( const ConstString& uniformName )
 {
   mUniformMaps.Remove( uniformName );
 }