[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / update / common / property-owner-messages.h
old mode 100644 (file)
new mode 100755 (executable)
index 0b4e23b..8668e4e
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__
+#ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H
+#define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
  *
  */
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
+#include <string>
 
+// INTERNAL INCLUDES
 #include <dali/internal/event/common/event-thread-services.h>
 #include <dali/internal/event/common/property-input-impl.h>
 #include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/double-buffered-property.h>
 #include <dali/internal/update/animation/scene-graph-constraint-base.h>
-#include <string>
 
 namespace Dali
 {
@@ -90,7 +90,7 @@ public:
                     typename ParameterType< P >::PassingType value )
   {
     // Reserve some memory inside the message queue
-    unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyMessage ) );
+    uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyMessage ) );
 
     // Construct message in the message queue memory; note that delete should not be called on the return value
     new (slot) AnimatablePropertyMessage( sceneObject, property, member, value );
@@ -108,6 +108,7 @@ public:
    */
   virtual void Process( BufferIndex updateBufferIndex )
   {
+    mSceneObject->SetPropertyDirty( true );
     (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
   }
 
@@ -169,7 +170,7 @@ public:
                     float value )
   {
     // Reserve some memory inside the message queue
-    unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyComponentMessage ) );
+    uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( AnimatablePropertyComponentMessage ) );
 
     // Construct message in the message queue memory; note that delete should not be called on the return value
     new (slot) AnimatablePropertyComponentMessage( sceneObject, property, member, value );
@@ -187,6 +188,7 @@ public:
    */
   virtual void Process( BufferIndex updateBufferIndex )
   {
+    mSceneObject->SetPropertyDirty( true );
     (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
   }
 
@@ -221,109 +223,28 @@ private:
 };
 
 
-/**
- * Template class for sending messages to double buffered properties in a PropertyOwner
- */
-template< typename P >
-class DoubleBufferedPropertyMessage : public PropertyOwnerMessageBase
-{
-public:
-
-  typedef void(DoubleBufferedProperty<P>::*MemberFunction)( BufferIndex, typename ParameterType< P >::PassingType );
-
-  /**
-   * Create a message.
-   * @note The scene object is expected to be const in the thread which sends this message.
-   * However it can be modified when Process() is called in a different thread.
-   * @param[in] eventThreadServices The object used to send messages to the scene graph
-   * @param[in] sceneObject The property owner scene object
-   * @param[in] property The property to set.
-   * @param[in] member The member function of the object.
-   * @param[in] value The new value of the property.
-   */
-  static void Send( EventThreadServices& eventThreadServices,
-                    const PropertyOwner* sceneObject,
-                    const DoubleBufferedProperty<P>* property,
-                    MemberFunction member,
-                    typename ParameterType< P >::PassingType value )
-  {
-    // Reserve some memory inside the message queue
-    unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( DoubleBufferedPropertyMessage ) );
-
-    // Construct message in the message queue memory; note that delete should not be called on the return value
-    new (slot) DoubleBufferedPropertyMessage( sceneObject, property, member, value );
-  }
-
-  /**
-   * Virtual destructor
-   */
-  virtual ~DoubleBufferedPropertyMessage()
-  {
-  }
-
-  /**
-   * @copydoc MessageBase::Process
-   */
-  virtual void Process( BufferIndex updateBufferIndex )
-  {
-    DALI_ASSERT_DEBUG( mProperty && "Message does not have an object" );
-    (mProperty->*mMemberFunction)( updateBufferIndex,
-                                   ParameterType< P >::PassObject( mParam ) );
-  }
-
-private:
-
-  /**
-   * Create a message.
-   * @note The property owner is expected to be const in the thread which sends this message.
-   * However it can be modified when Process() is called in a different thread.
-   * @param[in] sceneObject the property owner scene object
-   * @param[in] property The property to set.
-   * @param[in] member The member function of the object.
-   * @param[in] value The new value of the property.
-   */
-  DoubleBufferedPropertyMessage( const PropertyOwner* sceneObject,
-                                 const DoubleBufferedProperty<P>* property,
-                                 MemberFunction member,
-                                 typename ParameterType< P >::PassingType value )
-  : PropertyOwnerMessageBase(),
-    mSceneObject( const_cast< PropertyOwner* >( sceneObject ) ),
-    mProperty( const_cast< DoubleBufferedProperty<P>* >( property ) ),
-    mMemberFunction( member ),
-    mParam( value )
-  {
-  }
-
-private:
-  PropertyOwner* mSceneObject;
-  DoubleBufferedProperty<P>* mProperty;
-  MemberFunction mMemberFunction;
-  typename ParameterType< P >::HolderType mParam;
-};
-
-
 // Messages for PropertyOwner
 
-inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, PropertyBase* property )
+inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<PropertyBase>& property )
 {
   typedef MessageValue1< PropertyOwner, OwnerPointer<PropertyBase> > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, property );
 }
 
-inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, ConstraintBase& constraint )
+inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer<ConstraintBase>& constraint )
 {
   typedef MessageValue1< PropertyOwner, OwnerPointer<ConstraintBase> > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, &constraint );
+  new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, constraint );
 }
 
 inline void RemoveConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const ConstraintBase& constConstraint )
@@ -334,23 +255,29 @@ inline void RemoveConstraintMessage( EventThreadServices& eventThreadServices, c
   typedef MessageValue1< PropertyOwner, ConstraintBase* > LocalType;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
   new (slot) LocalType( &owner, &PropertyOwner::RemoveConstraint, &constraint );
 }
 
-inline void AddUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, UniformPropertyMapping* map )
+inline void AddUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, OwnerPointer< UniformPropertyMapping >& map )
 {
   typedef MessageValue1< PropertyOwner, OwnerPointer< UniformPropertyMapping > > LocalType;
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
   new (slot) LocalType( &owner, &PropertyOwner::AddUniformMapping, map );
 }
 
 inline void RemoveUniformMapMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const std::string& uniformName )
 {
   typedef MessageValue1< PropertyOwner, std::string > LocalType;
-  unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
   new (slot) LocalType( &owner, &PropertyOwner::RemoveUniformMapping, uniformName );
 }
 
@@ -361,4 +288,4 @@ inline void RemoveUniformMapMessage( EventThreadServices& eventThreadServices, c
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H