Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.h
old mode 100755 (executable)
new mode 100644 (file)
index 4ba53e3..037f6ed
@@ -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
 
   /**
@@ -116,6 +117,21 @@ public:
   }
 
   /**
+   * Mark an node and its sub tree according to the updated flag.
+   * @param[in] updated The updated flag
+   * (used for partial rendering to mark an animating sub tree for example).
+   */
+  virtual void SetUpdated(bool updated)
+  {
+    mUpdated = updated;
+
+    for (Node* child : mChildren)
+    {
+       child->SetUpdated(updated);
+    }
+  }
+
+  /**
    * This method sets clipping information on the node based on its hierarchy in the scene-graph.
    * A value is calculated that can be used during sorting to increase sort speed.
    * @param[in] clippingId The Clipping ID of the node to set
@@ -203,7 +219,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 +277,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.
@@ -605,6 +629,20 @@ public:
   }
 
   /**
+   * Retrieve the update size hint of the node.
+   * @return The update size hint.
+   */
+  const Vector3& GetUpdateSizeHint() const
+  {
+    if( mTransformId != INVALID_TRANSFORM_ID )
+    {
+      return mUpdateSizeHint.Get(0);
+    }
+
+    return Vector3::ZERO;
+  }
+
+  /**
    * Retrieve the bounding sphere of the node
    * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
    */
@@ -799,9 +837,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* )
@@ -873,6 +910,8 @@ public: // Default properties
   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.
   AnimatableProperty<Vector4>        mColor;                  ///< Color can be inherited from the Node hierarchy
+  AnimatableProperty<Vector3>        mUpdateSizeHint;         ///< Update size hint is provided for damaged area calculation. This is not animatable. It is just double-buffered. (Because all these bloody properties are).
+
 
   // Inherited properties; read-only from public API
 
@@ -887,6 +926,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 +951,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;
 };
@@ -918,7 +960,7 @@ protected:
 
 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
 {
-  typedef MessageValue1< Node, bool > LocalType;
+  using LocalType = MessageValue1<Node, bool>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -929,7 +971,7 @@ inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServic
 
 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
 {
-  typedef MessageValue1< Node, Vector3 > LocalType;
+  using LocalType = MessageValue1<Node, Vector3>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -940,7 +982,7 @@ inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, co
 
 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
 {
-  typedef MessageValue1< Node, Vector3 > LocalType;
+  using LocalType = MessageValue1<Node, Vector3>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -951,7 +993,7 @@ inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, con
 
 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
 {
-  typedef MessageValue1< Node, bool > LocalType;
+  using LocalType = MessageValue1<Node, bool>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -962,7 +1004,7 @@ inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices,
 
 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
 {
-  typedef MessageValue1< Node, bool > LocalType;
+  using LocalType = MessageValue1<Node, bool>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -973,7 +1015,7 @@ inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, co
 
 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
 {
-  typedef MessageValue1< Node, ColorMode > LocalType;
+  using LocalType = MessageValue1<Node, ColorMode>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -984,7 +1026,7 @@ inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const
 
 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
 {
-  typedef MessageValue1< Node, DrawMode::Type > LocalType;
+  using LocalType = MessageValue1<Node, DrawMode::Type>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -993,31 +1035,31 @@ 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;
+  using LocalType = MessageValue1<Node, Renderer*>;
 
   // 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::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;
+  using LocalType = MessageValue1<Node, const Renderer*>;
 
   // 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 )
 {
-  typedef MessageValue1< Node, uint32_t > LocalType;
+  using LocalType = MessageValue1<Node, uint32_t>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -1028,7 +1070,7 @@ inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, cons
 
 inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode )
 {
-  typedef MessageValue1< Node, ClippingMode::Type > LocalType;
+  using LocalType = MessageValue1<Node, ClippingMode::Type>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -1039,7 +1081,7 @@ inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, co
 
 inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint )
 {
-  typedef MessageValue1< Node, bool > LocalType;
+  using LocalType = MessageValue1<Node, bool>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );