Avoid Heap allocation in UniformMap.
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.h
old mode 100755 (executable)
new mode 100644 (file)
index 37887af..77bd5ac
@@ -45,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
@@ -73,7 +72,6 @@ class Node : public PropertyOwner, public NodeDataProvider
 public:
 
   // Defaults
-  static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
   static const ColorMode DEFAULT_COLOR_MODE;
 
   // Creation methods
@@ -115,7 +113,22 @@ public:
    */
   virtual Layer* GetLayer()
   {
-    return NULL;
+    return nullptr;
+  }
+
+  /**
+   * 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).
+   */
+  void SetUpdated(bool updated) override
+  {
+    mUpdated = updated;
+
+    for (Node* child : mChildren)
+    {
+       child->SetUpdated(updated);
+    }
   }
 
   /**
@@ -616,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
    */
@@ -771,12 +798,17 @@ public:
   /**
    * @copydoc UniformMap::Add
    */
-  void AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map );
+  void AddUniformMapping(const UniformPropertyMapping& map) override;
 
   /**
    * @copydoc UniformMap::Remove
    */
-  void RemoveUniformMapping( const std::string& uniformName );
+  void RemoveUniformMapping( const ConstString& uniformName ) override;
+
+  /**
+   * @copydoc Dali::Internal::SceneGraph::PropertyOwner::IsAnimationPossible
+   */
+  bool IsAnimationPossible() const override;
 
   /**
    * Prepare the node for rendering.
@@ -817,14 +849,14 @@ protected:
    * Protected virtual destructor; See also Node::Delete( Node* )
    * Kept protected to allow destructor chaining from layer
    */
-  virtual ~Node();
+  ~Node() override;
 
 private: // from NodeDataProvider
 
   /**
    * @copydoc NodeDataProvider::GetModelMatrix
    */
-  virtual const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const
+  const Matrix& GetModelMatrix( BufferIndex bufferIndex ) const override
   {
     return GetWorldMatrix( bufferIndex );
   }
@@ -832,7 +864,7 @@ private: // from NodeDataProvider
   /**
    * @copydoc NodeDataProvider::GetRenderColor
    */
-  virtual const Vector4& GetRenderColor( BufferIndex bufferIndex ) const
+  const Vector4& GetRenderColor( BufferIndex bufferIndex ) const override
   {
     return GetWorldColor( bufferIndex );
   }
@@ -841,7 +873,7 @@ public: // From UniformMapDataProvider
   /**
    * @copydoc UniformMapDataProvider::GetUniformMapChanged
    */
-  virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const
+  bool GetUniformMapChanged( BufferIndex bufferIndex ) const override
   {
     return mUniformMapChanged[bufferIndex];
   }
@@ -849,7 +881,7 @@ public: // From UniformMapDataProvider
   /**
    * @copydoc UniformMapDataProvider::GetUniformMap
    */
-  virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const
+  const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const override
   {
     return mCollectedUniformMap[bufferIndex];
   }
@@ -883,6 +915,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
 
@@ -931,7 +965,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 ) );
@@ -942,7 +976,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 ) );
@@ -953,7 +987,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 ) );
@@ -964,7 +998,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 ) );
@@ -975,7 +1009,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 ) );
@@ -986,7 +1020,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 ) );
@@ -997,7 +1031,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 ) );
@@ -1008,7 +1042,7 @@ inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const
 
 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 ) );
@@ -1019,7 +1053,7 @@ inline void AttachRendererMessage( EventThreadServices& eventThreadServices, con
 
 inline void DetachRendererMessage( EventThreadServices& eventThreadServices, const Node& node, const Renderer& renderer )
 {
-  typedef MessageValue1< Node, const Renderer* > LocalType;
+  using LocalType = MessageValue1<Node, const Renderer*>;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
@@ -1030,7 +1064,7 @@ inline void DetachRendererMessage( EventThreadServices& eventThreadServices, con
 
 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 ) );
@@ -1041,7 +1075,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 ) );
@@ -1052,7 +1086,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 ) );
@@ -1067,10 +1101,10 @@ inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadS
 template <>
 inline void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset()
 {
-  if (mObject != NULL)
+  if (mObject != nullptr)
   {
     Dali::Internal::SceneGraph::Node::Delete(mObject);
-    mObject = NULL;
+    mObject = nullptr;
   }
 }
 } // namespace Internal