Revert "[Tizen] Add codes for Dali Windows Backend"
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.h
index 6e3f98d..71102fb 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_NODE_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -21,7 +21,6 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/actors/actor-enumerations.h>
 #include <dali/public-api/actors/draw-mode.h>
-#include <dali/devel-api/common/set-wrapper.h>
 #include <dali/public-api/math/quaternion.h>
 #include <dali/public-api/math/math-utils.h>
 #include <dali/public-api/math/vector3.h>
@@ -57,7 +56,6 @@ class DiscardQueue;
 class Layer;
 class RenderTask;
 class UpdateManager;
-class GeometryBatcher;
 
 /**
  * Flag whether property has changed, during the Update phase.
@@ -108,15 +106,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 +123,7 @@ public:
    */
   bool IsLayer()
   {
-    return (GetLayer() != NULL);
+    return mIsLayer;
   }
 
   /**
@@ -148,13 +140,14 @@ public:
    * 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
    * @param[in] clippingDepth The Clipping Depth of the node to set
+   * @param[in] scissorDepth The Scissor Clipping Depth of the node to set
    */
-  void SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth )
+  void SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth, const uint32_t scissorDepth )
   {
-    // We only set up the sort value if we have a clipping depth, IE. At least 1 clipping node has been hit.
+    // We only set up the sort value if we have a stencil clipping depth, IE. At least 1 clipping node has been hit.
     // If not, if we traverse down a clipping tree and back up, and there is another
     // node on the parent, this will have a non-zero clipping ID that must be ignored
-    if( DALI_LIKELY( clippingDepth > 0u ) )
+    if( clippingDepth > 0u )
     {
       mClippingDepth = clippingDepth;
 
@@ -164,6 +157,15 @@ public:
       // clipping enabled flag and set it as the least significant bit.
       mClippingSortModifier = ( clippingId << 1u ) | ( mClippingMode == ClippingMode::DISABLED ? 1u : 0u );
     }
+    else
+    {
+      // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either.
+      mClippingSortModifier = 0u;
+    }
+
+    // The scissor depth does not modify the clipping sort modifier (as scissor clips are 2D only).
+    // For this reason we can always update the member variable.
+    mScissorDepth = scissorDepth;
   }
 
   /**
@@ -185,6 +187,15 @@ public:
   }
 
   /**
+   * Gets the Scissor Clipping Depth for this node.
+   * @return The Scissor Clipping Depth for this node.
+   */
+  uint32_t GetScissorDepth() const
+  {
+    return mScissorDepth;
+  }
+
+  /**
    * Sets the clipping mode for this node.
    * @param[in] clippingMode The ClippingMode to set
    */
@@ -331,15 +342,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.
    */
@@ -716,12 +718,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
    */
@@ -734,34 +730,23 @@ 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.
+   * @brief Sets the boolean which states whether the position should use the anchor-point.
+   * @param[in] positionUsesAnchorPoint True if the position should use the anchor-point
    */
-  inline bool GetIsBatchParent()
+  void SetPositionUsesAnchorPoint( bool positionUsesAnchorPoint )
   {
-    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;
+    if( mTransformId != INVALID_TRANSFORM_ID && mPositionUsesAnchorPoint != positionUsesAnchorPoint )
+    {
+      mPositionUsesAnchorPoint = positionUsesAnchorPoint;
+      mTransformManager->SetPositionUsesAnchorPoint( mTransformId, mPositionUsesAnchorPoint );
+    }
   }
 
 public:
   /**
    * @copydoc UniformMap::Add
    */
-  void AddUniformMapping( UniformPropertyMapping* map );
+  void AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map );
 
   /**
    * @copydoc UniformMap::Remove
@@ -783,6 +768,11 @@ public:
    */
   void CreateTransform( SceneGraph::TransformManager* transformManager );
 
+  /**
+   * Reset dirty flags
+   */
+  void ResetDirtyFlags( BufferIndex updateBufferIndex );
+
 protected:
 
   /**
@@ -798,6 +788,12 @@ protected:
    */
   Node();
 
+  /**
+   * Protected virtual destructor; See also Node::Delete( Node* )
+   * Kept protected to allow destructor chaining from layer
+   */
+  virtual ~Node();
+
 private: // from NodeDataProvider
 
   /**
@@ -842,11 +838,6 @@ private:
   Node& operator=(const Node& rhs);
 
   /**
-   * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
-   */
-  virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
-
-  /**
    * Recursive helper to disconnect a Node and its children.
    * Disconnected Nodes have no parent or children.
    * @param[in] updateBufferIndex The current update buffer index.
@@ -875,16 +866,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
@@ -893,7 +879,8 @@ protected:
 
   CollectedUniformMap                mCollectedUniformMap[2]; ///< Uniform maps of the node
   unsigned int                       mUniformMapChanged[2];   ///< Records if the uniform map has been altered this frame
-  uint32_t                           mClippingDepth;          ///< The number of clipping nodes deep this node is
+  uint32_t                           mClippingDepth;          ///< The number of stencil clipping nodes deep this node is
+  uint32_t                           mScissorDepth;           ///< The number of scissor clipping nodes deep this node is
 
   uint32_t                           mDepthIndex;             ///< Depth index of the node
 
@@ -904,7 +891,8 @@ 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
+  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;
 };
@@ -1010,44 +998,51 @@ inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, con
   new (slot) LocalType( &node, &Node::RemoveRenderer, renderer );
 }
 
-inline void SetIsBatchParentMessage( EventThreadServices& eventThreadServices, const Node& node, bool isBatchParent )
+inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, unsigned int depthIndex )
 {
-  typedef MessageValue1< Node, bool > LocalType;
+  typedef MessageValue1< Node, unsigned int > 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 );
+  new (slot) LocalType( &node, &Node::SetDepthIndex, depthIndex );
 }
 
-inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, unsigned int depthIndex )
+inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode )
 {
-  typedef MessageValue1< Node, unsigned int > LocalType;
+  typedef MessageValue1< Node, ClippingMode::Type > 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::SetDepthIndex, depthIndex );
+  new (slot) LocalType( &node, &Node::SetClippingMode, clippingMode );
 }
 
-inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode )
+inline void SetPositionUsesAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, bool positionUsesAnchorPoint )
 {
-  typedef MessageValue1< Node, ClippingMode::Type > LocalType;
+  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::SetClippingMode, clippingMode );
+  new (slot) LocalType( &node, &Node::SetPositionUsesAnchorPoint, positionUsesAnchorPoint );
 }
 
-
 } // 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