Friendly janitor cleaning up unnecessary header dependencies
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.h
index 226b0a6..bc9aa1f 100644 (file)
@@ -1,32 +1,33 @@
 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
 #define __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
 
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali/public-api/actors/actor-enumerations.h>
 #include <dali/public-api/actors/draw-mode.h>
+#include <dali/public-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>
 #include <dali/internal/common/message.h>
 #include <dali/internal/common/event-to-update.h>
 #include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/double-buffered.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>
@@ -51,7 +52,6 @@ namespace SceneGraph
 
 class DiscardQueue;
 class Layer;
-class Shader;
 class NodeAttachment;
 class RenderTask;
 class UpdateManager;
@@ -66,10 +66,9 @@ enum NodePropertyFlags
   VisibleFlag          = 0x002,
   ColorFlag            = 0x004,
   SizeFlag             = 0x008,
-  ShaderFlag           = 0x010,
-  OverlayFlag          = 0x020,
-  SortModifierFlag     = 0x040,
-  ChildDeletedFlag     = 0x080
+  OverlayFlag          = 0x010,
+  SortModifierFlag     = 0x020,
+  ChildDeletedFlag     = 0x040
 };
 
 static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags
@@ -78,7 +77,7 @@ static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags
  * Size is not inherited.
  * VisibleFlag is inherited so that attachments can be synchronized with nodes after they become visible
  */
-static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | ShaderFlag | OverlayFlag;
+static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | OverlayFlag;
 
 // Flags which require the scene renderable lists to be updated
 static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | ChildDeletedFlag;
@@ -225,8 +224,10 @@ public:
    * @pre The childNode does not already have a parent.
    * @pre The childNode is not a root node.
    * @param[in] childNode The child to add.
+   * @param[in] index to insert at, if not supplied or -1 it will be appended
+   *
    */
-  void ConnectChild( Node* childNode );
+  void ConnectChild( Node* childNode, int index = -1);
 
   /**
    * Disconnect a child (& its children) from the scene-graph.
@@ -256,70 +257,6 @@ public:
     return mChildren;
   }
 
-  // Shaders
-
-  /**
-   * Set whether the node inherits a shader effect from its parent.
-   * The inherited effect can be overriden using ApplyShader()
-   * @param [in] inherit True if the parent effect is inherited.
-   */
-  void SetInheritShader(bool inherit)
-  {
-    if (inherit != mInheritShader)
-    {
-      mInheritShader = inherit;
-
-      SetDirtyFlag(ShaderFlag);
-    }
-  }
-
-  /**
-   * Query whether the node inherits a shader from its parent.
-   * @return True if the parent effect is inherited.
-   */
-  bool GetInheritShader() const
-  {
-    return mInheritShader;
-  }
-
-  /**
-   * Apply a shader object to this Node.
-   * Shader effects are weakly referenced, potentially by multiple nodes & node attachments.
-   * @param[in] shader The shader to apply.
-   */
-  void ApplyShader( Shader* shader );
-
-  /**
-   * Remove the shader object from this Node (if any).
-   */
-  void RemoveShader();
-
-  /**
-   * Retrieve the applied shader.
-   * @return The applied shader.
-   */
-  Shader* GetAppliedShader() const;
-
-  /**
-   * Sets the inherited shader of the node.
-   * @param[in] shader The new inherited shader.
-   */
-  void SetInheritedShader(Shader* shader);
-
-  /**
-   * Retrieve the inherited shader.
-   * @return The inherited shader.
-   */
-  Shader* GetInheritedShader() const;
-
-  /**
-   * Inherit a shader (if any) applied to the parent node.
-   * This method should only be called when the parents inherited shader is up-to-date.
-   * @param defaultShader pointer to the default shader, used if inherit shader is set to false
-   * @pre The node has a parent.
-   */
-  void InheritShader(Shader* defaultShader);
-
   // Update methods
 
   /**
@@ -1094,8 +1031,8 @@ private:
 
 public: // Default properties
 
-  PropertyVector3<TransformFlag> mParentOrigin;  ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
-  PropertyVector3<TransformFlag> mAnchorPoint;   ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
+  PropertyVector3                mParentOrigin;  ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
+  PropertyVector3                mAnchorPoint;   ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
 
   AnimatableProperty<Vector3>    mSize;          ///< Size is provided for layouting
   AnimatableProperty<Vector3>    mPosition;      ///< Local transform; distance between parent-origin & anchor-point
@@ -1106,40 +1043,36 @@ public: // Default properties
 
   // Inherited properties; read-only from public API
 
-  InheritedProperty<Vector3>    mWorldPosition; ///< Full inherited position
-  InheritedProperty<Quaternion> mWorldRotation; ///< Full inherited rotation
-  InheritedProperty<Vector3>    mWorldScale;    ///< Full inherited scale
-  InheritedProperty<Matrix>     mWorldMatrix;   ///< Full inherited world matrix
-  InheritedColor                mWorldColor;    ///< Full inherited color
+  InheritedVector3    mWorldPosition; ///< Full inherited position
+  InheritedQuaternion mWorldRotation; ///< Full inherited rotation
+  InheritedVector3    mWorldScale;    ///< Full inherited scale
+  InheritedMatrix     mWorldMatrix;   ///< Full inherited world matrix
+  InheritedColor      mWorldColor;    ///< Full inherited color
 
 protected:
 
-  // flags, compressed to bitfield (uses only 4 bytes)
-  bool mIsRoot:1; ///< True if the node cannot have a parent
-  bool mInheritShader:1;   ///< Whether the parent's shader should be inherited.
-  bool mInheritRotation:1; ///< Whether the parent's rotation should be inherited.
-  bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
-  bool mTransmitGeometryScaling:1; ///< Whether geometry scaling should be applied to world transform.
-  bool mInhibitLocalTransform:1;  // whether local transform should be applied.
-  bool mIsActive:1;  // When a Node is marked "active" it has been disconnected, and its properties have not been modified
-  DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
-  PositionInheritanceMode mPositionInheritanceMode:2; ///< Determines how position is inherited, 2 bits is enough
-  ColorMode mColorMode:2; ///< Determines whether mWorldColor is inherited, 2 bits is enough
+  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
 
-  Node* mParent; ///< Pointer to parent node (a child is owned by its parent)
-  NodeContainer mChildren; ///< Container of children; not owned
+  NodeAttachmentOwner mAttachment;                   ///< Optional owned attachment
+  NodeContainer       mChildren;                     ///< Container of children; not owned
 
-  NodeAttachmentOwner mAttachment; ///< Optional owned attachment
+  Vector3             mGeometryScale;                ///< Applied before calculating world transform.
+  Vector3             mInitialVolume;                ///< Initial volume... TODO - need a better name
 
-  Shader* mAppliedShader;   ///< A pointer to an applied shader
-  Shader* mInheritedShader; ///< A pointer to an inherited shader
+  // flags, compressed to bitfield
+  int  mDirtyFlags:10;                               ///< A composite set of flags for each of the Node properties
 
-  int mDirtyFlags; ///< A composite set of flags for each of the Node properties
+  bool mIsRoot:1;                                    ///< True if the node cannot have a parent
+  bool mInheritRotation:1;                           ///< Whether the parent's rotation should be inherited.
+  bool mInheritScale:1;                              ///< Whether the parent's scale should be inherited.
+  bool mTransmitGeometryScaling:1;                   ///< Whether geometry scaling should be applied to world transform.
+  bool mInhibitLocalTransform:1;                     ///< whether local transform should be applied.
+  bool mIsActive:1;                                  ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
 
-  Vector3    mGeometryScale;    ///< Applied before calculating world transform.
-  Vector3    mInitialVolume;    ///< Initial volume... TODO - need a better name
-
-  RenderTask* mExclusiveRenderTask; ///< Nodes can be marked as exclusive to a single RenderTask
+  DrawMode::Type          mDrawMode:2;               ///< How the Node and its children should be drawn
+  PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough
+  ColorMode               mColorMode:2;              ///< Determines whether mWorldColor is inherited, 2 bits is enough
 
   // Changes scope, should be at end of class
   DALI_LOG_OBJECT_STRING_DECLARATION;
@@ -1147,17 +1080,6 @@ protected:
 
 // Messages for Node
 
-inline void SetInheritShaderMessage( EventToUpdate& eventToUpdate, const Node& node, bool inherit )
-{
-  typedef MessageValue1< Node, bool > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.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::SetInheritShader, inherit );
-}
-
 inline void SetInheritRotationMessage( EventToUpdate& eventToUpdate, const Node& node, bool inherit )
 {
   typedef MessageValue1< Node, bool > LocalType;
@@ -1191,31 +1113,6 @@ inline void SetTransmitGeometryScalingMessage( EventToUpdate& eventToUpdate, con
   new (slot) LocalType( &node, &Node::SetTransmitGeometryScaling, transmitGeometryScaling );
 }
 
-inline void ApplyShaderMessage( EventToUpdate& eventToUpdate, const Node& node, const Shader& constShader )
-{
-  // Update thread can edit the object
-  Shader& shader = const_cast< Shader& >( constShader );
-
-  typedef MessageValue1< Node, Shader* > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.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::ApplyShader, &shader );
-}
-
-inline void RemoveShaderMessage( EventToUpdate& eventToUpdate, const Node& node )
-{
-  typedef Message< Node > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.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::RemoveShader );
-}
-
 inline void SetParentOriginMessage( EventToUpdate& eventToUpdate, const Node& node, const Vector3& origin )
 {
   typedef MessageValue1< Node, Vector3 > LocalType;