Revert "[3.0] Clipping API feature in Actor"
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / node.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/actor-enumerations.h>
23 #include <dali/public-api/actors/draw-mode.h>
24 #include <dali/devel-api/common/set-wrapper.h>
25 #include <dali/public-api/math/quaternion.h>
26 #include <dali/public-api/math/math-utils.h>
27 #include <dali/public-api/math/vector3.h>
28 #include <dali/integration-api/debug.h>
29 #include <dali/internal/common/message.h>
30 #include <dali/internal/event/common/event-thread-services.h>
31 #include <dali/internal/render/data-providers/node-data-provider.h>
32 #include <dali/internal/update/common/animatable-property.h>
33 #include <dali/internal/update/common/property-owner.h>
34 #include <dali/internal/update/common/property-vector3.h>
35 #include <dali/internal/update/common/scene-graph-buffers.h>
36 #include <dali/internal/update/common/inherited-property.h>
37 #include <dali/internal/update/manager/transform-manager.h>
38 #include <dali/internal/update/manager/transform-manager-property.h>
39 #include <dali/internal/update/nodes/node-declarations.h>
40 #include <dali/internal/update/rendering/scene-graph-renderer.h>
41
42 namespace Dali
43 {
44
45 namespace Internal
46 {
47
48 // value types used by messages
49 template <> struct ParameterType< ColorMode > : public BasicType< ColorMode > {};
50 template <> struct ParameterType< PositionInheritanceMode > : public BasicType< PositionInheritanceMode > {};
51
52 namespace SceneGraph
53 {
54
55 class DiscardQueue;
56 class Layer;
57 class RenderTask;
58 class UpdateManager;
59
60 /**
61  * Flag whether property has changed, during the Update phase.
62  */
63 enum NodePropertyFlags
64 {
65   NothingFlag          = 0x000,
66   TransformFlag        = 0x001,
67   VisibleFlag          = 0x002,
68   ColorFlag            = 0x004,
69   SizeFlag             = 0x008,
70   OverlayFlag          = 0x010,
71   SortModifierFlag     = 0x020,
72   ChildDeletedFlag     = 0x040
73 };
74
75 static const int AllFlags = ( ChildDeletedFlag << 1 ) - 1; // all the flags
76
77 /**
78  * Size is not inherited. VisibleFlag is inherited
79  */
80 static const int InheritedDirtyFlags = TransformFlag | VisibleFlag | ColorFlag | OverlayFlag;
81
82 // Flags which require the scene renderable lists to be updated
83 static const int RenderableUpdateFlags = TransformFlag | SortModifierFlag | ChildDeletedFlag;
84
85 /**
86  * Node is the base class for all nodes in the Scene Graph.
87  *
88  * Each node provides a transformation which applies to the node and
89  * its children.  Node data is double-buffered. This allows an update
90  * thread to modify node data, without interferring with another
91  * thread reading the values from the previous update traversal.
92  */
93 class Node : public PropertyOwner, public NodeDataProvider
94 {
95 public:
96
97   // Defaults
98   static const PositionInheritanceMode DEFAULT_POSITION_INHERITANCE_MODE;
99   static const ColorMode DEFAULT_COLOR_MODE;
100
101   // Creation methods
102
103   /**
104    * Construct a new Node.
105    */
106   static Node* New();
107
108   /**
109    * Virtual destructor
110    */
111   virtual ~Node();
112
113   /**
114    * Overriden delete operator
115    * Deletes the node from its global memory pool
116    */
117   void operator delete( void* ptr );
118
119   /**
120    * Called during UpdateManager::DestroyNode shortly before Node is destroyed.
121    */
122   void OnDestroy();
123
124   // Layer interface
125
126   /**
127    * Query whether the node is a layer.
128    * @return True if the node is a layer.
129    */
130   bool IsLayer()
131   {
132     return (GetLayer() != NULL);
133   }
134
135   /**
136    * Convert a node to a layer.
137    * @return A pointer to the layer, or NULL.
138    */
139   virtual Layer* GetLayer()
140   {
141     return NULL;
142   }
143
144   /**
145    * Add a renderer to the node
146    * @param[in] renderer The renderer added to the node
147    */
148   void AddRenderer( Renderer* renderer )
149   {
150     //Check that it has not been already added
151     unsigned int rendererCount( mRenderer.Size() );
152     for( unsigned int i(0); i<rendererCount; ++i )
153     {
154       if( mRenderer[i] == renderer )
155       {
156         //Renderer already in the list
157         return;
158       }
159     }
160
161     //If it is the first renderer added, make sure the world transform will be calculated
162     //in the next update as world transform is not computed if node has no renderers
163     if( rendererCount == 0 )
164     {
165       mDirtyFlags |= TransformFlag;
166     }
167
168     mRenderer.PushBack( renderer );
169   }
170
171   /**
172    * Remove a renderer from the node
173    * @param[in] renderer The renderer to be removed
174    */
175   void RemoveRenderer( Renderer* renderer );
176
177   /*
178    * Get the renderer at the given index
179    * @param[in] index
180    */
181   Renderer* GetRendererAt( unsigned int index )
182   {
183     return mRenderer[index];
184   }
185
186   /**
187    * Retrieve the number of renderers for the node
188    */
189   unsigned int GetRendererCount()
190   {
191     return mRenderer.Size();
192   }
193
194   // Containment methods
195
196   /**
197    * Query whether a node is the root node. Root nodes cannot have a parent node.
198    * A node becomes a root node, when it is installed by UpdateManager.
199    * @return True if the node is a root node.
200    */
201   bool IsRoot() const
202   {
203     return mIsRoot;
204   }
205
206   /**
207    * Set whether a node is the root node. Root nodes cannot have a parent node.
208    * This method should only be called by UpdateManager.
209    * @pre When isRoot is true, the node must not have a parent.
210    * @param[in] isRoot Whether the node is now a root node.
211    */
212   void SetRoot(bool isRoot);
213
214   /**
215    * Retrieve the parent of a Node.
216    * @return The parent node, or NULL if the Node has not been added to the scene-graph.
217    */
218   Node* GetParent()
219   {
220     return mParent;
221   }
222
223   /**
224    * Retrieve the parent of a Node.
225    * @return The parent node, or NULL if the Node has not been added to the scene-graph.
226    */
227   const Node* GetParent() const
228   {
229     return mParent;
230   }
231
232   /**
233    * Connect a node to the scene-graph.
234    * @pre A node cannot be added to itself.
235    * @pre The parent node is connected to the scene-graph.
236    * @pre The childNode does not already have a parent.
237    * @pre The childNode is not a root node.
238    * @param[in] childNode The child to add.
239    */
240   void ConnectChild( Node* childNode );
241
242   /**
243    * Disconnect a child (& its children) from the scene-graph.
244    * @pre childNode is a child of this Node.
245    * @param[in] updateBufferIndex The current update buffer index.
246    * @param[in] childNode The node to disconnect.
247    */
248   void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode );
249
250   /**
251    * Retrieve the children a Node.
252    * @return The container of children.
253    */
254   const NodeContainer& GetChildren() const
255   {
256     return mChildren;
257   }
258
259   /**
260    * Retrieve the children a Node.
261    * @return The container of children.
262    */
263   NodeContainer& GetChildren()
264   {
265     return mChildren;
266   }
267
268   // Update methods
269
270   /**
271    * Flag that one of the node values has changed in the current frame.
272    * @param[in] flag The flag to set.
273    */
274   void SetDirtyFlag(NodePropertyFlags flag)
275   {
276     mDirtyFlags |= flag;
277   }
278
279   /**
280    * Flag that all of the node values are dirty.
281    */
282   void SetAllDirtyFlags()
283   {
284     mDirtyFlags = AllFlags;
285   }
286
287   /**
288    * Query whether a node is dirty.
289    * @return The dirty flags
290    */
291   int GetDirtyFlags() const;
292
293   /**
294    * Query whether a node is clean.
295    * @return True if the node is clean.
296    */
297   bool IsClean() const
298   {
299     return ( NothingFlag == GetDirtyFlags() );
300   }
301
302   /**
303    * Retrieve the parent-origin of the node.
304    * @return The parent-origin.
305    */
306   const Vector3& GetParentOrigin() const
307   {
308     return mParentOrigin.Get(0);
309   }
310
311   /**
312    * Sets both the local & base parent-origins of the node.
313    * @param[in] origin The new local & base parent-origins.
314    */
315   void SetParentOrigin(const Vector3& origin)
316   {
317     mParentOrigin.Set(0,origin );
318   }
319
320   /**
321    * Retrieve the anchor-point of the node.
322    * @return The anchor-point.
323    */
324   const Vector3& GetAnchorPoint() const
325   {
326     return mAnchorPoint.Get(0);
327   }
328
329   /**
330    * Sets both the local & base anchor-points of the node.
331    * @param[in] anchor The new local & base anchor-points.
332    */
333   void SetAnchorPoint(const Vector3& anchor)
334   {
335     mAnchorPoint.Set(0, anchor );
336   }
337
338   /**
339    * Retrieve the local position of the node, relative to its parent.
340    * @param[in] bufferIndex The buffer to read from.
341    * @return The local position.
342    */
343   const Vector3& GetPosition(BufferIndex bufferIndex) const
344   {
345     if( mTransformId != INVALID_TRANSFORM_ID )
346     {
347       return mPosition.Get(bufferIndex);
348     }
349
350     return Vector3::ZERO;
351   }
352
353   /**
354    * Retrieve the position of the node derived from the position of all its parents.
355    * @return The world position.
356    */
357   const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
358   {
359     return mWorldPosition.Get(bufferIndex);
360   }
361
362   /**
363    * Set whether the Node inherits position.
364    * @param[in] inherit True if the parent position is inherited.
365    */
366   void SetInheritPosition(bool inherit)
367   {
368     if( mTransformId != INVALID_TRANSFORM_ID )
369     {
370       mTransformManager->SetInheritPosition( mTransformId, inherit );
371     }
372   }
373
374   /**
375    * Retrieve the local orientation of the node, relative to its parent.
376    * @param[in] bufferIndex The buffer to read from.
377    * @return The local orientation.
378    */
379   const Quaternion& GetOrientation(BufferIndex bufferIndex) const
380   {
381     if( mTransformId != INVALID_TRANSFORM_ID )
382     {
383       return mOrientation.Get(0);
384     }
385
386     return Quaternion::IDENTITY;
387   }
388
389   /**
390    * Retrieve the orientation of the node derived from the rotation of all its parents.
391    * @param[in] bufferIndex The buffer to read from.
392    * @return The world rotation.
393    */
394   const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
395   {
396     return mWorldOrientation.Get(0);
397   }
398
399   /**
400    * Set whether the Node inherits orientation.
401    * @param[in] inherit True if the parent orientation is inherited.
402    */
403   void SetInheritOrientation(bool inherit)
404   {
405     if( mTransformId != INVALID_TRANSFORM_ID )
406     {
407       mTransformManager->SetInheritOrientation(mTransformId, inherit );
408     }
409   }
410
411   /**
412    * Retrieve the local scale of the node, relative to its parent.
413    * @param[in] bufferIndex The buffer to read from.
414    * @return The local scale.
415    */
416   const Vector3& GetScale(BufferIndex bufferIndex) const
417   {
418     if( mTransformId != INVALID_TRANSFORM_ID )
419     {
420       return mScale.Get(0);
421     }
422
423     return Vector3::ONE;
424   }
425
426
427   /**
428    * Retrieve the scale of the node derived from the scale of all its parents.
429    * @param[in] bufferIndex The buffer to read from.
430    * @return The world scale.
431    */
432   const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
433   {
434     return mWorldScale.Get(0);
435   }
436
437   /**
438    * Set whether the Node inherits scale.
439    * @param inherit True if the Node inherits scale.
440    */
441   void SetInheritScale( bool inherit )
442   {
443     if( mTransformId != INVALID_TRANSFORM_ID )
444     {
445       mTransformManager->SetInheritScale(mTransformId, inherit );
446     }
447   }
448
449   /**
450    * Retrieve the visibility of the node.
451    * @param[in] bufferIndex The buffer to read from.
452    * @return True if the node is visible.
453    */
454   bool IsVisible(BufferIndex bufferIndex) const
455   {
456     return mVisible[bufferIndex];
457   }
458
459   /**
460    * Retrieve the opacity of the node.
461    * @param[in] bufferIndex The buffer to read from.
462    * @return The opacity.
463    */
464   float GetOpacity(BufferIndex bufferIndex) const
465   {
466     return mColor[bufferIndex].a;
467   }
468
469   /**
470    * Retrieve the color of the node.
471    * @param[in] bufferIndex The buffer to read from.
472    * @return The color.
473    */
474   const Vector4& GetColor(BufferIndex bufferIndex) const
475   {
476     return mColor[bufferIndex];
477   }
478
479   /**
480    * Sets the color of the node derived from the color of all its parents.
481    * @param[in] color The world color.
482    * @param[in] updateBufferIndex The current update buffer index.
483    */
484   void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
485   {
486     mWorldColor.Set( updateBufferIndex, color );
487   }
488
489   /**
490    * Sets the color of the node derived from the color of all its parents.
491    * This method should only be called when the parents world color is up-to-date.
492    * @pre The node has a parent.
493    * @param[in] updateBufferIndex The current update buffer index.
494    */
495   void InheritWorldColor( BufferIndex updateBufferIndex )
496   {
497     DALI_ASSERT_DEBUG(mParent != NULL);
498
499     // default first
500     if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
501     {
502       const Vector4& ownColor = mColor[updateBufferIndex];
503       mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
504     }
505     else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
506     {
507       mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
508     }
509     else if( mColorMode == USE_PARENT_COLOR )
510     {
511       mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
512     }
513     else // USE_OWN_COLOR
514     {
515       mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
516     }
517   }
518
519   /**
520    * Copies the previous inherited scale, if this changed in the previous frame.
521    * This method should be called instead of InheritWorldScale i.e. if the inherited scale
522    * does not need to be recalculated in the current frame.
523    * @param[in] updateBufferIndex The current update buffer index.
524    */
525   void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
526   {
527     mWorldColor.CopyPrevious( updateBufferIndex );
528   }
529
530   /**
531    * Retrieve the color of the node, possibly derived from the color
532    * of all its parents, depending on the value of mColorMode.
533    * @param[in] bufferIndex The buffer to read from.
534    * @return The world color.
535    */
536   const Vector4& GetWorldColor(BufferIndex bufferIndex) const
537   {
538     return mWorldColor[bufferIndex];
539   }
540
541   /**
542    * Set the color mode. This specifies whether the Node uses its own color,
543    * or inherits its parent color.
544    * @param[in] colorMode The new color mode.
545    */
546   void SetColorMode(ColorMode colorMode)
547   {
548     mColorMode = colorMode;
549
550     SetDirtyFlag(ColorFlag);
551   }
552
553   /**
554    * Retrieve the color mode.
555    * @return The color mode.
556    */
557   ColorMode GetColorMode() const
558   {
559     return mColorMode;
560   }
561
562   /**
563    * Retrieve the size of the node.
564    * @param[in] bufferIndex The buffer to read from.
565    * @return The size.
566    */
567   const Vector3& GetSize(BufferIndex bufferIndex) const
568   {
569     if( mTransformId != INVALID_TRANSFORM_ID )
570     {
571       return mSize.Get(0);
572     }
573
574     return Vector3::ZERO;
575   }
576
577   /**
578    * Retrieve the bounding sphere of the node
579    * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
580    */
581   const Vector4& GetBoundingSphere() const
582   {
583     if( mTransformId != INVALID_TRANSFORM_ID )
584     {
585       return mTransformManager->GetBoundingSphere( mTransformId );
586     }
587
588     return Vector4::ZERO;
589   }
590
591   /**
592    * Retrieve world matrix and size of the node
593    * @param[out] The local to world matrix of the node
594    * @param[out] size The current size of the node
595    */
596   void GetWorldMatrixAndSize( Matrix& worldMatrix, Vector3& size ) const
597   {
598     if( mTransformId != INVALID_TRANSFORM_ID )
599     {
600       mTransformManager->GetWorldMatrixAndSize( mTransformId, worldMatrix, size );
601     }
602   }
603
604   /**
605    * Checks if local matrix has changed since last update
606    * @return true if local matrix has changed, false otherwise
607    */
608   bool IsLocalMatrixDirty() const
609   {
610     return (mTransformId != INVALID_TRANSFORM_ID) &&
611            (mTransformManager->IsLocalMatrixDirty( mTransformId ));
612   }
613
614
615   /**
616    * Retrieve the cached world-matrix of a node.
617    * @param[in] bufferIndex The buffer to read from.
618    * @return The world-matrix.
619    */
620   const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
621   {
622     return mWorldMatrix.Get(bufferIndex);
623   }
624
625   /**
626    * Mark the node as exclusive to a single RenderTask.
627    * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
628    */
629   void SetExclusiveRenderTask( RenderTask* renderTask )
630   {
631     mExclusiveRenderTask = renderTask;
632   }
633
634   /**
635    * Query whether the node is exclusive to a single RenderTask.
636    * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
637    */
638   RenderTask* GetExclusiveRenderTask() const
639   {
640     return mExclusiveRenderTask;
641   }
642
643   /**
644    * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
645    * @param[in] drawMode The new draw-mode to use.
646    */
647   void SetDrawMode( const DrawMode::Type& drawMode )
648   {
649     mDrawMode = drawMode;
650   }
651
652   /**
653    * Returns whether node is an overlay or not.
654    * @return True if node is an overlay, false otherwise.
655    */
656   DrawMode::Type GetDrawMode() const
657   {
658     return mDrawMode;
659   }
660
661   /*
662    * Returns the transform id of the node
663    * @return The transform component id of the node
664    */
665   TransformId GetTransformId() const
666   {
667     return mTransformId;
668   }
669
670   /**
671    * Equality operator, checks for identity, not values.
672    *
673    */
674   bool operator==( const Node* rhs ) const
675   {
676     if ( this == rhs )
677     {
678       return true;
679     }
680     return false;
681   }
682
683   unsigned short GetDepth() const
684   {
685     return mDepth;
686   }
687
688 public:
689   /**
690    * @copydoc UniformMap::Add
691    */
692   void AddUniformMapping( UniformPropertyMapping* map );
693
694   /**
695    * @copydoc UniformMap::Remove
696    */
697   void RemoveUniformMapping( const std::string& uniformName );
698
699   /**
700    * Prepare the node for rendering.
701    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
702    * @param[in] updateBufferIndex The current update buffer index.
703    */
704   void PrepareRender( BufferIndex bufferIndex );
705
706   /**
707    * Called by UpdateManager when the node is added.
708    * Creates a new transform component in the transform manager and initialize all the properties
709    * related to the transformation
710    * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
711    */
712   void CreateTransform( SceneGraph::TransformManager* transformManager );
713
714 protected:
715
716   /**
717    * Set the parent of a Node.
718    * @param[in] parentNode the new parent.
719    */
720   void SetParent(Node& parentNode);
721
722   /**
723    * Protected constructor; See also Node::New()
724    */
725   Node();
726
727 private: // from NodeDataProvider
728
729   /**
730    * @copydoc NodeDataProvider::GetModelMatrix
731    */
732   virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const
733   {
734     return GetWorldMatrix( bufferId );
735   }
736
737   /**
738    * @copydoc NodeDataProvider::GetRenderColor
739    */
740   virtual const Vector4& GetRenderColor( unsigned int bufferId ) const
741   {
742     return GetWorldColor( bufferId );
743   }
744
745 public: // From UniformMapDataProvider
746   /**
747    * @copydoc UniformMapDataProvider::GetUniformMapChanged
748    */
749   virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const
750   {
751     return mUniformMapChanged[bufferIndex];
752   }
753
754   /**
755    * @copydoc UniformMapDataProvider::GetUniformMap
756    */
757   virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const
758   {
759     return mCollectedUniformMap[bufferIndex];
760   }
761
762 private:
763
764   // Undefined
765   Node(const Node&);
766
767   // Undefined
768   Node& operator=(const Node& rhs);
769
770   /**
771    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
772    */
773   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
774
775   /**
776    * Recursive helper to disconnect a Node and its children.
777    * Disconnected Nodes have no parent or children.
778    * @param[in] updateBufferIndex The current update buffer index.
779    */
780   void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
781
782 public: // Default properties
783
784   TransformManager* mTransformManager;
785   TransformId mTransformId;
786   TransformManagerPropertyVector3    mParentOrigin;  ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
787   TransformManagerPropertyVector3    mAnchorPoint;   ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
788   TransformManagerPropertyVector3    mSize;          ///< Size is provided for layouting
789   TransformManagerPropertyVector3    mPosition;      ///< Local transform; distance between parent-origin & anchor-point
790   TransformManagerPropertyQuaternion mOrientation;   ///< Local transform; rotation relative to parent node
791   TransformManagerPropertyVector3    mScale;         ///< Local transform; scale relative to parent node
792
793   AnimatableProperty<bool>           mVisible;       ///< Visibility can be inherited from the Node hierachy
794   AnimatableProperty<Vector4>        mColor;         ///< Color can be inherited from the Node hierarchy
795
796   // Inherited properties; read-only from public API
797
798   TransformManagerVector3Input    mWorldPosition;     ///< Full inherited position
799   TransformManagerVector3Input    mWorldScale;
800   TransformManagerQuaternionInput mWorldOrientation;  ///< Full inherited orientation
801   TransformManagerMatrixInput     mWorldMatrix;       ///< Full inherited world matrix
802   InheritedColor      mWorldColor;        ///< Full inherited color
803
804 protected:
805
806   Node*               mParent;                       ///< Pointer to parent node (a child is owned by its parent)
807   RenderTask*         mExclusiveRenderTask;          ///< Nodes can be marked as exclusive to a single RenderTask
808
809   RendererContainer   mRenderer;                     ///< Container of renderers; not owned
810
811   NodeContainer       mChildren;                     ///< Container of children; not owned
812
813   CollectedUniformMap mCollectedUniformMap[2];      ///< Uniform maps of the node
814   unsigned int        mUniformMapChanged[2];        ///< Records if the uniform map has been altered this frame
815   unsigned int        mRegenerateUniformMap : 2;    ///< Indicate if the uniform map has to be regenerated this frame
816
817   // flags, compressed to bitfield
818   unsigned short mDepth: 12;                        ///< Depth in the hierarchy
819   int  mDirtyFlags:8;                               ///< A composite set of flags for each of the Node properties
820
821   bool mIsRoot:1;                                    ///< True if the node cannot have a parent
822
823   DrawMode::Type          mDrawMode:2;               ///< How the Node and its children should be drawn
824   ColorMode               mColorMode:2;              ///< Determines whether mWorldColor is inherited, 2 bits is enough
825
826   // Changes scope, should be at end of class
827   DALI_LOG_OBJECT_STRING_DECLARATION;
828 };
829
830 // Messages for Node
831
832 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
833 {
834   typedef MessageValue1< Node, bool > LocalType;
835
836   // Reserve some memory inside the message queue
837   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
838
839   // Construct message in the message queue memory; note that delete should not be called on the return value
840   new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
841 }
842
843 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
844 {
845   typedef MessageValue1< Node, Vector3 > LocalType;
846
847   // Reserve some memory inside the message queue
848   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
849
850   // Construct message in the message queue memory; note that delete should not be called on the return value
851   new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
852 }
853
854 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
855 {
856   typedef MessageValue1< Node, Vector3 > LocalType;
857
858   // Reserve some memory inside the message queue
859   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
860
861   // Construct message in the message queue memory; note that delete should not be called on the return value
862   new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
863 }
864
865 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
866 {
867   typedef MessageValue1< Node, bool > LocalType;
868
869   // Reserve some memory inside the message queue
870   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
871
872   // Construct message in the message queue memory; note that delete should not be called on the return value
873   new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
874 }
875
876 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
877 {
878   typedef MessageValue1< Node, bool > LocalType;
879
880   // Reserve some memory inside the message queue
881   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
882
883   // Construct message in the message queue memory; note that delete should not be called on the return value
884   new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
885 }
886
887 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
888 {
889   typedef MessageValue1< Node, ColorMode > LocalType;
890
891   // Reserve some memory inside the message queue
892   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
893
894   // Construct message in the message queue memory; note that delete should not be called on the return value
895   new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
896 }
897
898 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
899 {
900   typedef MessageValue1< Node, DrawMode::Type > LocalType;
901
902   // Reserve some memory inside the message queue
903   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
904
905   // Construct message in the message queue memory; note that delete should not be called on the return value
906   new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
907 }
908
909 inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
910 {
911   typedef MessageValue1< Node, Renderer* > LocalType;
912
913   // Reserve some memory inside the message queue
914   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
915
916   // Construct message in the message queue memory; note that delete should not be called on the return value
917   new (slot) LocalType( &node, &Node::AddRenderer, renderer );
918 }
919
920 inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
921 {
922   typedef MessageValue1< Node, Renderer* > LocalType;
923
924   // Reserve some memory inside the message queue
925   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
926
927   // Construct message in the message queue memory; note that delete should not be called on the return value
928   new (slot) LocalType( &node, &Node::RemoveRenderer, renderer );
929 }
930 } // namespace SceneGraph
931
932 } // namespace Internal
933
934 } // namespace Dali
935
936 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_