Fix memory leak, scene graph layers are never deleted from memory
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.h
index fab6e7e..e2ba292 100644 (file)
@@ -57,7 +57,6 @@ class DiscardQueue;
 class Layer;
 class RenderTask;
 class UpdateManager;
-class GeometryBatcher;
 
 /**
  * Flag whether property has changed, during the Update phase.
@@ -108,15 +107,9 @@ public:
   static Node* New();
 
   /**
-   * Virtual destructor
+   * Deletes a Node.
    */
-  virtual ~Node();
-
-  /**
-   * Overriden delete operator
-   * Deletes the node from its global memory pool
-   */
-  void operator delete( void* ptr );
+  static void Delete( Node* node );
 
   /**
    * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
@@ -131,7 +124,7 @@ public:
    */
   bool IsLayer()
   {
-    return (GetLayer() != NULL);
+    return mIsLayer;
   }
 
   /**
@@ -336,15 +329,6 @@ public:
   int GetDirtyFlags() const;
 
   /**
-   * Query whether a node is clean.
-   * @return True if the node is clean.
-   */
-  bool IsClean() const
-  {
-    return ( NothingFlag == GetDirtyFlags() );
-  }
-
-  /**
    * Retrieve the parent-origin of the node.
    * @return The parent-origin.
    */
@@ -721,12 +705,6 @@ public:
   }
 
   /**
-   * @brief Turns on or off being a batch parent for the node
-   * @param[in] enabled If true the node becomes a parent for batch of its children
-   */
-  void SetIsBatchParent( bool enabled );
-
-  /**
    * @brief Sets the sibling order of the node
    * @param[in] order The new order
    */
@@ -738,30 +716,6 @@ public:
    */
   unsigned int GetDepthIndex(){ return mDepthIndex; }
 
-  /**
-   * @brief Tells if the node is a batch parent
-   * @return True if node is a batch parent, false otherwise.
-   */
-  inline bool GetIsBatchParent()
-  {
-    return mIsBatchParent;
-  }
-
-  /**
-   * Set the batch parent of a Node.
-   * @param[in] batchParentNode The new batch parent.
-   */
-  void SetBatchParent( Node* batchParentNode );
-
-  /**
-   * Retrieve the batch parent of a Node.
-   * @return The batch parent node, or NULL if the Node has not been added to the scene-graph.
-   */
-  Node* GetBatchParent() const
-  {
-    return mBatchParent;
-  }
-
 public:
   /**
    * @copydoc UniformMap::Add
@@ -803,6 +757,12 @@ protected:
    */
   Node();
 
+  /**
+   * Protected virtual destructor; See also Node::Delete( Node* )
+   * Kept protected to allow destructor chaining from layer
+   */
+  virtual ~Node();
+
 private: // from NodeDataProvider
 
   /**
@@ -880,16 +840,11 @@ public: // Default properties
   TransformManagerMatrixInput        mWorldMatrix;            ///< Full inherited world matrix
   InheritedColor                     mWorldColor;             ///< Full inherited color
 
-  GeometryBatcher*                   mGeometryBatcher;        ///< A pointer to an instance of geometry batcher
-  uint32_t                           mBatchIndex;             ///< Batch 32bit handle, BATCH_NULL_HANDLE by default
   uint32_t                           mClippingSortModifier;   ///< Contains bit-packed clipping information for quick access when sorting
 
-  bool                               mIsBatchParent:1;        ///< Marks node as a batch parent
-
 protected:
 
   Node*                              mParent;                 ///< Pointer to parent node (a child is owned by its parent)
-  Node*                              mBatchParent;            ///< Pointer to batch parent node
   RenderTask*                        mExclusiveRenderTask;    ///< Nodes can be marked as exclusive to a single RenderTask
 
   RendererContainer                  mRenderer;               ///< Container of renderers; not owned
@@ -909,7 +864,7 @@ protected:
   ColorMode                          mColorMode:2;            ///< Determines whether mWorldColor is inherited, 2 bits is enough
   ClippingMode::Type                 mClippingMode:2;         ///< The clipping mode of this node
   bool                               mIsRoot:1;               ///< True if the node cannot have a parent
-
+  bool                               mIsLayer:1;              ///< True if the node is a layer
   // Changes scope, should be at end of class
   DALI_LOG_OBJECT_STRING_DECLARATION;
 };
@@ -1015,17 +970,6 @@ inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, con
   new (slot) LocalType( &node, &Node::RemoveRenderer, renderer );
 }
 
-inline void SetIsBatchParentMessage( EventThreadServices& eventThreadServices, const Node& node, bool isBatchParent )
-{
-  typedef MessageValue1< Node, bool > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* 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::SetIsBatchParent, isBatchParent );
-}
-
 inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, unsigned int depthIndex )
 {
   typedef MessageValue1< Node, unsigned int > LocalType;
@@ -1051,8 +995,16 @@ inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, co
 
 } // namespace SceneGraph
 
+// Template specialisation for OwnerPointer<Node>, because delete is protected
+template <>
+void OwnerPointer<Dali::Internal::SceneGraph::Node>::Reset();
+
 } // namespace Internal
 
+// Template specialisations for OwnerContainer<Node*>, because delete is protected
+template <>
+void OwnerContainer<Dali::Internal::SceneGraph::Node*>::Delete( Dali::Internal::SceneGraph::Node* pointer );
+
 } // namespace Dali
 
 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H