e354b32f47c2db8ea3e729170ebb465237e594a7
[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    *
594    * @param[out] size The current size of the node
595    * @return The local to world matrix of the node
596    */
597   const Matrix& GetWorldMatrixAndSize( Vector3& size ) const
598   {
599     if( mTransformId != INVALID_TRANSFORM_ID )
600     {
601       return mTransformManager->GetWorldMatrixAndSize( mTransformId, size );
602     }
603     return Matrix::IDENTITY;
604   }
605
606   /**
607    * Checks if local matrix has changed since last update
608    * @return true if local matrix has changed, false otherwise
609    */
610   bool IsLocalMatrixDirty() const
611   {
612     return (mTransformId != INVALID_TRANSFORM_ID) &&
613            (mTransformManager->IsLocalMatrixDirty( mTransformId ));
614   }
615
616
617   /**
618    * Retrieve the cached world-matrix of a node.
619    * @param[in] bufferIndex The buffer to read from.
620    * @return The world-matrix.
621    */
622   const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
623   {
624     return mWorldMatrix.Get(bufferIndex);
625   }
626
627   /**
628    * Mark the node as exclusive to a single RenderTask.
629    * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
630    */
631   void SetExclusiveRenderTask( RenderTask* renderTask )
632   {
633     mExclusiveRenderTask = renderTask;
634   }
635
636   /**
637    * Query whether the node is exclusive to a single RenderTask.
638    * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
639    */
640   RenderTask* GetExclusiveRenderTask() const
641   {
642     return mExclusiveRenderTask;
643   }
644
645   /**
646    * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
647    * @param[in] drawMode The new draw-mode to use.
648    */
649   void SetDrawMode( const DrawMode::Type& drawMode )
650   {
651     mDrawMode = drawMode;
652   }
653
654   /**
655    * Returns whether node is an overlay or not.
656    * @return True if node is an overlay, false otherwise.
657    */
658   DrawMode::Type GetDrawMode() const
659   {
660     return mDrawMode;
661   }
662
663   /*
664    * Returns the transform id of the node
665    * @return The transform component id of the node
666    */
667   TransformId GetTransformId() const
668   {
669     return mTransformId;
670   }
671
672   /**
673    * Equality operator, checks for identity, not values.
674    *
675    */
676   bool operator==( const Node* rhs ) const
677   {
678     if ( this == rhs )
679     {
680       return true;
681     }
682     return false;
683   }
684
685   unsigned short GetDepth() const
686   {
687     return mDepth;
688   }
689
690 public:
691   /**
692    * @copydoc UniformMap::Add
693    */
694   void AddUniformMapping( UniformPropertyMapping* map );
695
696   /**
697    * @copydoc UniformMap::Remove
698    */
699   void RemoveUniformMapping( const std::string& uniformName );
700
701   /**
702    * Prepare the node for rendering.
703    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
704    * @param[in] updateBufferIndex The current update buffer index.
705    */
706   void PrepareRender( BufferIndex bufferIndex );
707
708   /**
709    * Called by UpdateManager when the node is added.
710    * Creates a new transform component in the transform manager and initialize all the properties
711    * related to the transformation
712    * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
713    */
714   void CreateTransform( SceneGraph::TransformManager* transformManager );
715
716 protected:
717
718   /**
719    * Set the parent of a Node.
720    * @param[in] parentNode the new parent.
721    */
722   void SetParent(Node& parentNode);
723
724   /**
725    * Protected constructor; See also Node::New()
726    */
727   Node();
728
729 private: // from NodeDataProvider
730
731   /**
732    * @copydoc NodeDataProvider::GetModelMatrix
733    */
734   virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const
735   {
736     return GetWorldMatrix( bufferId );
737   }
738
739   /**
740    * @copydoc NodeDataProvider::GetRenderColor
741    */
742   virtual const Vector4& GetRenderColor( unsigned int bufferId ) const
743   {
744     return GetWorldColor( bufferId );
745   }
746
747 public: // From UniformMapDataProvider
748   /**
749    * @copydoc UniformMapDataProvider::GetUniformMapChanged
750    */
751   virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const
752   {
753     return mUniformMapChanged[bufferIndex];
754   }
755
756   /**
757    * @copydoc UniformMapDataProvider::GetUniformMap
758    */
759   virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const
760   {
761     return mCollectedUniformMap[bufferIndex];
762   }
763
764 private:
765
766   // Undefined
767   Node(const Node&);
768
769   // Undefined
770   Node& operator=(const Node& rhs);
771
772   /**
773    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
774    */
775   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
776
777   /**
778    * Recursive helper to disconnect a Node and its children.
779    * Disconnected Nodes have no parent or children.
780    * @param[in] updateBufferIndex The current update buffer index.
781    */
782   void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
783
784 public: // Default properties
785
786   TransformManager* mTransformManager;
787   TransformId mTransformId;
788   TransformManagerPropertyVector3    mParentOrigin;  ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
789   TransformManagerPropertyVector3    mAnchorPoint;   ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
790   TransformManagerPropertyVector3    mSize;          ///< Size is provided for layouting
791   TransformManagerPropertyVector3    mPosition;      ///< Local transform; distance between parent-origin & anchor-point
792   TransformManagerPropertyQuaternion mOrientation;   ///< Local transform; rotation relative to parent node
793   TransformManagerPropertyVector3    mScale;         ///< Local transform; scale relative to parent node
794
795   AnimatableProperty<bool>           mVisible;       ///< Visibility can be inherited from the Node hierachy
796   AnimatableProperty<Vector4>        mColor;         ///< Color can be inherited from the Node hierarchy
797
798   // Inherited properties; read-only from public API
799
800   TransformManagerVector3Input    mWorldPosition;     ///< Full inherited position
801   TransformManagerVector3Input    mWorldScale;
802   TransformManagerQuaternionInput mWorldOrientation;  ///< Full inherited orientation
803   TransformManagerMatrixInput     mWorldMatrix;       ///< Full inherited world matrix
804   InheritedColor      mWorldColor;        ///< Full inherited color
805
806 protected:
807
808   Node*               mParent;                       ///< Pointer to parent node (a child is owned by its parent)
809   RenderTask*         mExclusiveRenderTask;          ///< Nodes can be marked as exclusive to a single RenderTask
810
811   RendererContainer   mRenderer;                     ///< Container of renderers; not owned
812
813   NodeContainer       mChildren;                     ///< Container of children; not owned
814
815   CollectedUniformMap mCollectedUniformMap[2];      ///< Uniform maps of the node
816   unsigned int        mUniformMapChanged[2];        ///< Records if the uniform map has been altered this frame
817   unsigned int        mRegenerateUniformMap : 2;    ///< Indicate if the uniform map has to be regenerated this frame
818
819   // flags, compressed to bitfield
820   unsigned short mDepth: 12;                        ///< Depth in the hierarchy
821   int  mDirtyFlags:8;                               ///< A composite set of flags for each of the Node properties
822
823   bool mIsRoot:1;                                    ///< True if the node cannot have a parent
824
825   DrawMode::Type          mDrawMode:2;               ///< How the Node and its children should be drawn
826   ColorMode               mColorMode:2;              ///< Determines whether mWorldColor is inherited, 2 bits is enough
827
828   // Changes scope, should be at end of class
829   DALI_LOG_OBJECT_STRING_DECLARATION;
830 };
831
832 // Messages for Node
833
834 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
835 {
836   typedef MessageValue1< Node, bool > LocalType;
837
838   // Reserve some memory inside the message queue
839   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
840
841   // Construct message in the message queue memory; note that delete should not be called on the return value
842   new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
843 }
844
845 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
846 {
847   typedef MessageValue1< Node, Vector3 > LocalType;
848
849   // Reserve some memory inside the message queue
850   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
851
852   // Construct message in the message queue memory; note that delete should not be called on the return value
853   new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
854 }
855
856 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
857 {
858   typedef MessageValue1< Node, Vector3 > LocalType;
859
860   // Reserve some memory inside the message queue
861   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
862
863   // Construct message in the message queue memory; note that delete should not be called on the return value
864   new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
865 }
866
867 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
868 {
869   typedef MessageValue1< Node, bool > LocalType;
870
871   // Reserve some memory inside the message queue
872   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
873
874   // Construct message in the message queue memory; note that delete should not be called on the return value
875   new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
876 }
877
878 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
879 {
880   typedef MessageValue1< Node, bool > LocalType;
881
882   // Reserve some memory inside the message queue
883   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
884
885   // Construct message in the message queue memory; note that delete should not be called on the return value
886   new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
887 }
888
889 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
890 {
891   typedef MessageValue1< Node, ColorMode > LocalType;
892
893   // Reserve some memory inside the message queue
894   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
895
896   // Construct message in the message queue memory; note that delete should not be called on the return value
897   new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
898 }
899
900 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
901 {
902   typedef MessageValue1< Node, DrawMode::Type > LocalType;
903
904   // Reserve some memory inside the message queue
905   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
906
907   // Construct message in the message queue memory; note that delete should not be called on the return value
908   new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
909 }
910
911 inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
912 {
913   typedef MessageValue1< Node, Renderer* > LocalType;
914
915   // Reserve some memory inside the message queue
916   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
917
918   // Construct message in the message queue memory; note that delete should not be called on the return value
919   new (slot) LocalType( &node, &Node::AddRenderer, renderer );
920 }
921
922 inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
923 {
924   typedef MessageValue1< Node, Renderer* > LocalType;
925
926   // Reserve some memory inside the message queue
927   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
928
929   // Construct message in the message queue memory; note that delete should not be called on the return value
930   new (slot) LocalType( &node, &Node::RemoveRenderer, renderer );
931 }
932 } // namespace SceneGraph
933
934 } // namespace Internal
935
936 } // namespace Dali
937
938 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_