[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.h
index 903f8c2..5600523 100755 (executable)
@@ -30,7 +30,6 @@
 #include <dali/internal/render/data-providers/node-data-provider.h>
 #include <dali/internal/update/common/animatable-property.h>
 #include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/property-vector3.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/internal/update/common/inherited-property.h>
 #include <dali/internal/update/manager/transform-manager.h>
@@ -46,7 +45,6 @@ namespace Internal
 
 // Value types used by messages.
 template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
-template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {};
 template <> struct ParameterType< ClippingMode::Type > : public BasicType< ClippingMode::Type > {};
 
 namespace SceneGraph
@@ -74,16 +72,14 @@ class Node : public PropertyOwner, public NodeDataProvider
 public:
 
   // Defaults
-  static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
   static const ColorMode DEFAULT_COLOR_MODE;
 
   // Creation methods
 
   /**
    * Construct a new Node.
-   * @param[in] id The unique ID of the node
    */
-  static Node* New( uint32_t id );
+  static Node* New();
 
   /**
    * Deletes a Node.
@@ -95,6 +91,11 @@ public:
    */
   void OnDestroy();
 
+  /**
+   * @return the unique ID of the node
+   */
+  uint32_t GetId() const;
+
   // Layer interface
 
   /**
@@ -181,6 +182,7 @@ public:
    */
   void SetClippingMode( const ClippingMode::Type clippingMode )
   {
+    SetPropertyDirty( true );
     mClippingMode = clippingMode;
   }
 
@@ -203,7 +205,7 @@ public:
    * Remove a renderer from the node
    * @param[in] renderer The renderer to be removed
    */
-  void RemoveRenderer( Renderer* renderer );
+  void RemoveRenderer( const Renderer* renderer );
 
   /*
    * Get the renderer at the given index
@@ -261,6 +263,14 @@ public:
   }
 
   /**
+   * @return true if the node is connected to SceneGraph
+   */
+  bool ConnectedToScene()
+  {
+    return IsRoot() || GetParent();
+  }
+
+  /**
    * Connect a node to the scene-graph.
    * @pre A node cannot be added to itself.
    * @pre The parent node is connected to the scene-graph.
@@ -304,6 +314,7 @@ public:
    */
   void SetDirtyFlag( NodePropertyFlags flag )
   {
+    SetPropertyDirty( true );
     mDirtyFlags |= flag;
   }
 
@@ -312,6 +323,7 @@ public:
    */
   void SetAllDirtyFlags()
   {
+    SetPropertyDirty( true );
     mDirtyFlags = NodePropertyFlags::ALL;
   }
 
@@ -675,6 +687,7 @@ public:
    */
   void SetDrawMode( const DrawMode::Type& drawMode )
   {
+    SetPropertyDirty( true );
     mDrawMode = drawMode;
   }
 
@@ -711,6 +724,7 @@ public:
    */
   void SetDepthIndex( uint32_t depthIndex )
   {
+    SetPropertyDirty( true );
     mDepthIndex = depthIndex;
   }
 
@@ -718,7 +732,7 @@ public:
    * @brief Get the depth index of the node
    * @return Current depth index
    */
-  uint32_t GetDepthIndex()
+  uint32_t GetDepthIndex() const
   {
     return mDepthIndex;
   }
@@ -756,6 +770,42 @@ public:
     return mCulled[bufferIndex];
   }
 
+  /**
+ * @Is component changed
+ * @Return true if component is changed else false
+ */
+  bool IsComponentChanged()
+  {
+    return (mTransformId != INVALID_TRANSFORM_ID) &&
+           (mTransformManager->IsComponentChanged( mTransformId ));
+  }
+
+  /**
+   * Retrieve the update size hint of the node
+   * @return A vector3 describing the update size hint
+   */
+  const Vector3& GetUpdateSizeHint( BufferIndex bufferIndex ) const
+  {
+    if( mTransformId != INVALID_TRANSFORM_ID )
+    {
+      return mTransformManager->GetUpdateSizeHint( mTransformId );
+    }
+
+    return Vector3::ZERO;
+  }
+
+  /**
+   * Set whether partial update needs to run following a render.
+   * @param[in] value Set to true if an partial update is required to be run
+   */
+  virtual void SetPropertyDirty( bool value );
+
+  /**
+   * Query the property status following rendering of a frame.
+   * @return True if the property has changed
+   */
+  virtual bool IsPropertyDirty() const;
+
 public:
   /**
    * @copydoc UniformMap::Add
@@ -799,9 +849,8 @@ protected:
 
   /**
    * Protected constructor; See also Node::New()
-   * @param[in] id The Unique ID of the actor creating the node
    */
-  Node( uint32_t id );
+  Node();
 
   /**
    * Protected virtual destructor; See also Node::Delete( Node* )
@@ -869,6 +918,7 @@ public: // Default properties
   TransformManagerPropertyVector3    mPosition;               ///< Local transform; distance between parent-origin & anchor-point
   TransformManagerPropertyQuaternion mOrientation;            ///< Local transform; rotation relative to parent node
   TransformManagerPropertyVector3    mScale;                  ///< Local transform; scale relative to parent node
+  TransformManagerPropertyVector3    mUpdateSizeHint;         ///< Local transform; update size hint is provided for partial update
 
   AnimatableProperty<bool>           mVisible;                ///< Visibility can be inherited from the Node hierachy
   AnimatableProperty<bool>           mCulled;                 ///< True if the node is culled. This is not animatable. It is just double-buffered.
@@ -887,6 +937,8 @@ public: // Default properties
 
 protected:
 
+  static uint32_t                    mNodeCounter;            ///< count of total nodes, used for unique ids
+
   Node*                              mParent;                 ///< Pointer to parent node (a child is owned by its parent)
   RenderTask*                        mExclusiveRenderTask;    ///< Nodes can be marked as exclusive to a single RenderTask
 
@@ -910,6 +962,7 @@ protected:
   bool                               mIsRoot:1;               ///< True if the node cannot have a parent
   bool                               mIsLayer:1;              ///< True if the node is a layer
   bool                               mPositionUsesAnchorPoint:1; ///< True if the node should use the anchor-point when calculating the position
+
   // Changes scope, should be at end of class
   DALI_LOG_OBJECT_STRING_DECLARATION;
 };
@@ -993,7 +1046,7 @@ inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const
   new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
 }
 
-inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
+inline void AttachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
 {
   typedef MessageValue1< Node, Renderer* > LocalType;
 
@@ -1001,18 +1054,18 @@ inline void AddRendererMessage( EventThreadServices& eventThreadServices, const
   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( &node, &Node::AddRenderer, renderer );
+  new (slot) LocalType( &node, &Node::AddRenderer, const_cast<Renderer*>( &renderer ) );
 }
 
-inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
+inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
 {
-  typedef MessageValue1< Node, Renderer* > LocalType;
+  typedef MessageValue1< Node, const Renderer* > LocalType;
 
   // Reserve some memory inside the message queue
   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( &node, &Node::RemoveRenderer, renderer );
+  new (slot) LocalType( &node, &Node::RemoveRenderer, &renderer );
 }
 
 inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, uint32_t depthIndex )