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