Merge branch 'devel/master' (1.1.28) into tizen
[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    * Retrieve the local orientation of the node, relative to its parent.
406    * @param[in] bufferIndex The buffer to read from.
407    * @return The local orientation.
408    */
409   const Quaternion& GetOrientation(BufferIndex bufferIndex) const
410   {
411     if( mTransformId != INVALID_TRANSFORM_ID )
412     {
413       return mOrientation.Get(0);
414     }
415
416     return Quaternion::IDENTITY;
417   }
418
419   /**
420    * Retrieve the orientation of the node derived from the rotation of all its parents.
421    * @param[in] bufferIndex The buffer to read from.
422    * @return The world rotation.
423    */
424   const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
425   {
426     return mWorldOrientation.Get(0);
427   }
428
429   /**
430    * Set whether the Node inherits orientation.
431    * @param[in] inherit True if the parent orientation is inherited.
432    */
433   void SetInheritOrientation(bool inherit)
434   {
435     if( mTransformId != INVALID_TRANSFORM_ID )
436     {
437       mTransformManager->SetInheritOrientation(mTransformId, inherit );
438     }
439   }
440
441   /**
442    * Retrieve the local scale of the node, relative to its parent.
443    * @param[in] bufferIndex The buffer to read from.
444    * @return The local scale.
445    */
446   const Vector3& GetScale(BufferIndex bufferIndex) const
447   {
448     if( mTransformId != INVALID_TRANSFORM_ID )
449     {
450       return mScale.Get(0);
451     }
452
453     return Vector3::ONE;
454   }
455
456
457   /**
458    * Retrieve the scale of the node derived from the scale of all its parents.
459    * @param[in] bufferIndex The buffer to read from.
460    * @return The world scale.
461    */
462   const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
463   {
464     return mWorldScale.Get(0);
465   }
466
467   /**
468    * Set whether the Node inherits scale.
469    * @param inherit True if the Node inherits scale.
470    */
471   void SetInheritScale( bool inherit )
472   {
473     if( mTransformId != INVALID_TRANSFORM_ID )
474     {
475       mTransformManager->SetInheritScale(mTransformId, inherit );
476     }
477   }
478
479   /**
480    * Retrieve the visibility of the node.
481    * @param[in] bufferIndex The buffer to read from.
482    * @return True if the node is visible.
483    */
484   bool IsVisible(BufferIndex bufferIndex) const
485   {
486     return mVisible[bufferIndex];
487   }
488
489   /**
490    * Retrieve the opacity of the node.
491    * @param[in] bufferIndex The buffer to read from.
492    * @return The opacity.
493    */
494   float GetOpacity(BufferIndex bufferIndex) const
495   {
496     return mColor[bufferIndex].a;
497   }
498
499   /**
500    * Retrieve the color of the node.
501    * @param[in] bufferIndex The buffer to read from.
502    * @return The color.
503    */
504   const Vector4& GetColor(BufferIndex bufferIndex) const
505   {
506     return mColor[bufferIndex];
507   }
508
509   /**
510    * Sets the color of the node derived from the color of all its parents.
511    * @param[in] color The world color.
512    * @param[in] updateBufferIndex The current update buffer index.
513    */
514   void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
515   {
516     mWorldColor.Set( updateBufferIndex, color );
517   }
518
519   /**
520    * Sets the color of the node derived from the color of all its parents.
521    * This method should only be called when the parents world color is up-to-date.
522    * @pre The node has a parent.
523    * @param[in] updateBufferIndex The current update buffer index.
524    */
525   void InheritWorldColor( BufferIndex updateBufferIndex )
526   {
527     DALI_ASSERT_DEBUG(mParent != NULL);
528
529     // default first
530     if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
531     {
532       const Vector4& ownColor = mColor[updateBufferIndex];
533       mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
534     }
535     else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
536     {
537       mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
538     }
539     else if( mColorMode == USE_PARENT_COLOR )
540     {
541       mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
542     }
543     else // USE_OWN_COLOR
544     {
545       mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
546     }
547   }
548
549   /**
550    * Copies the previous inherited scale, if this changed in the previous frame.
551    * This method should be called instead of InheritWorldScale i.e. if the inherited scale
552    * does not need to be recalculated in the current frame.
553    * @param[in] updateBufferIndex The current update buffer index.
554    */
555   void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
556   {
557     mWorldColor.CopyPrevious( updateBufferIndex );
558   }
559
560   /**
561    * Retrieve the color of the node, possibly derived from the color
562    * of all its parents, depending on the value of mColorMode.
563    * @param[in] bufferIndex The buffer to read from.
564    * @return The world color.
565    */
566   const Vector4& GetWorldColor(BufferIndex bufferIndex) const
567   {
568     return mWorldColor[bufferIndex];
569   }
570
571   /**
572    * Set the color mode. This specifies whether the Node uses its own color,
573    * or inherits its parent color.
574    * @param[in] colorMode The new color mode.
575    */
576   void SetColorMode(ColorMode colorMode)
577   {
578     mColorMode = colorMode;
579
580     SetDirtyFlag(ColorFlag);
581   }
582
583   /**
584    * Retrieve the color mode.
585    * @return The color mode.
586    */
587   ColorMode GetColorMode() const
588   {
589     return mColorMode;
590   }
591
592   /**
593    * Retrieve the size of the node.
594    * @param[in] bufferIndex The buffer to read from.
595    * @return The size.
596    */
597   const Vector3& GetSize(BufferIndex bufferIndex) const
598   {
599     if( mTransformId != INVALID_TRANSFORM_ID )
600     {
601       return mSize.Get(0);
602     }
603
604     return Vector3::ZERO;
605   }
606
607   /**
608    * Checks if local matrix has changed since last update
609    * @return true if local matrix has changed, false otherwise
610    */
611   bool IsLocalMatrixDirty() const
612   {
613     return (mTransformId != INVALID_TRANSFORM_ID) &&
614            (mTransformManager->IsLocalMatrixDirty( mTransformId ));
615   }
616
617
618   /**
619    * Retrieve the cached world-matrix of a node.
620    * @param[in] bufferIndex The buffer to read from.
621    * @return The world-matrix.
622    */
623   const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
624   {
625     return mWorldMatrix.Get(bufferIndex);
626   }
627
628   /**
629    * Mark the node as exclusive to a single RenderTask.
630    * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
631    */
632   void SetExclusiveRenderTask( RenderTask* renderTask )
633   {
634     mExclusiveRenderTask = renderTask;
635   }
636
637   /**
638    * Query whether the node is exclusive to a single RenderTask.
639    * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
640    */
641   RenderTask* GetExclusiveRenderTask() const
642   {
643     return mExclusiveRenderTask;
644   }
645
646   /**
647    * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
648    * @param[in] drawMode The new draw-mode to use.
649    */
650   void SetDrawMode( const DrawMode::Type& drawMode )
651   {
652     mDrawMode = drawMode;
653   }
654
655   /**
656    * Returns whether node is an overlay or not.
657    * @return True if node is an overlay, false otherwise.
658    */
659   DrawMode::Type GetDrawMode() const
660   {
661     return mDrawMode;
662   }
663
664   /*
665    * Returns the transform id of the node
666    * @return The transform component id of the node
667    */
668   TransformId GetTransformId() const
669   {
670     return mTransformId;
671   }
672
673   /**
674    * Equality operator, checks for identity, not values.
675    *
676    */
677   bool operator==( const Node* rhs ) const
678   {
679     if ( this == rhs )
680     {
681       return true;
682     }
683     return false;
684   }
685
686   unsigned short GetDepth() const
687   {
688     return mDepth;
689   }
690
691 public:
692   /**
693    * @copydoc UniformMap::Add
694    */
695   void AddUniformMapping( UniformPropertyMapping* map );
696
697   /**
698    * @copydoc UniformMap::Remove
699    */
700   void RemoveUniformMapping( const std::string& uniformName );
701
702   /**
703    * Prepare the node for rendering.
704    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
705    * @param[in] updateBufferIndex The current update buffer index.
706    */
707   void PrepareRender( BufferIndex bufferIndex );
708
709   /**
710    * Called by UpdateManager when the node is added.
711    * Creates a new transform component in the transform manager and initialize all the properties
712    * related to the transformation
713    * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
714    */
715   void CreateTransform( SceneGraph::TransformManager* transformManager );
716
717 protected:
718
719   /**
720    * Set the parent of a Node.
721    * @param[in] parentNode the new parent.
722    */
723   void SetParent(Node& parentNode);
724
725   /**
726    * Protected constructor; See also Node::New()
727    */
728   Node();
729
730 private: // from NodeDataProvider
731
732   /**
733    * @copydoc NodeDataProvider::GetModelMatrix
734    */
735   virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const
736   {
737     return GetWorldMatrix( bufferId );
738   }
739
740   /**
741    * @copydoc NodeDataProvider::GetRenderColor
742    */
743   virtual const Vector4& GetRenderColor( unsigned int bufferId ) const
744   {
745     return GetWorldColor( bufferId );
746   }
747
748 public: // From UniformMapDataProvider
749   /**
750    * @copydoc UniformMapDataProvider::GetUniformMapChanged
751    */
752   virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const
753   {
754     return mUniformMapChanged[bufferIndex];
755   }
756
757   /**
758    * @copydoc UniformMapDataProvider::GetUniformMap
759    */
760   virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const
761   {
762     return mCollectedUniformMap[bufferIndex];
763   }
764
765 private:
766
767   // Undefined
768   Node(const Node&);
769
770   // Undefined
771   Node& operator=(const Node& rhs);
772
773   /**
774    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
775    */
776   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
777
778   /**
779    * Recursive helper to disconnect a Node and its children.
780    * Disconnected Nodes have no parent or children.
781    * @param[in] updateBufferIndex The current update buffer index.
782    */
783   void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
784
785 public: // Default properties
786
787   TransformManager* mTransformManager;
788   TransformId mTransformId;
789   TransformManagerPropertyVector3    mParentOrigin;  ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
790   TransformManagerPropertyVector3    mAnchorPoint;   ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
791   TransformManagerPropertyVector3    mSize;          ///< Size is provided for layouting
792   TransformManagerPropertyVector3    mPosition;      ///< Local transform; distance between parent-origin & anchor-point
793   TransformManagerPropertyQuaternion mOrientation;   ///< Local transform; rotation relative to parent node
794   TransformManagerPropertyVector3    mScale;         ///< Local transform; scale relative to parent node
795
796   AnimatableProperty<bool>           mVisible;       ///< Visibility can be inherited from the Node hierachy
797   AnimatableProperty<Vector4>        mColor;         ///< Color can be inherited from the Node hierarchy
798
799   // Inherited properties; read-only from public API
800
801   TransformManagerVector3Input    mWorldPosition;     ///< Full inherited position
802   TransformManagerVector3Input    mWorldScale;
803   TransformManagerQuaternionInput mWorldOrientation;  ///< Full inherited orientation
804   TransformManagerMatrixInput     mWorldMatrix;       ///< Full inherited world matrix
805   InheritedColor      mWorldColor;        ///< Full inherited color
806
807 protected:
808
809   Node*               mParent;                       ///< Pointer to parent node (a child is owned by its parent)
810   RenderTask*         mExclusiveRenderTask;          ///< Nodes can be marked as exclusive to a single RenderTask
811
812   NodeAttachmentOwner mAttachment;                   ///< Optional owned attachment
813   RendererContainer   mRenderer;                     ///< Container of renderers; not owned
814
815   NodeContainer       mChildren;                     ///< Container of children; not owned
816
817   CollectedUniformMap mCollectedUniformMap[2];      ///< Uniform maps of the node
818   unsigned int        mUniformMapChanged[2];        ///< Records if the uniform map has been altered this frame
819   unsigned int        mRegenerateUniformMap : 2;    ///< Indicate if the uniform map has to be regenerated this frame
820
821   // flags, compressed to bitfield
822   unsigned short mDepth: 12;                        ///< Depth in the hierarchy
823   int  mDirtyFlags:8;                               ///< A composite set of flags for each of the Node properties
824
825   bool mIsRoot:1;                                    ///< True if the node cannot have a parent
826
827   DrawMode::Type          mDrawMode:2;               ///< How the Node and its children should be drawn
828   ColorMode               mColorMode:2;              ///< Determines whether mWorldColor is inherited, 2 bits is enough
829
830   // Changes scope, should be at end of class
831   DALI_LOG_OBJECT_STRING_DECLARATION;
832 };
833
834 // Messages for Node
835
836 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
837 {
838   typedef MessageValue1< Node, bool > LocalType;
839
840   // Reserve some memory inside the message queue
841   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
842
843   // Construct message in the message queue memory; note that delete should not be called on the return value
844   new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
845 }
846
847 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
848 {
849   typedef MessageValue1< Node, Vector3 > LocalType;
850
851   // Reserve some memory inside the message queue
852   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
853
854   // Construct message in the message queue memory; note that delete should not be called on the return value
855   new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
856 }
857
858 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
859 {
860   typedef MessageValue1< Node, Vector3 > LocalType;
861
862   // Reserve some memory inside the message queue
863   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
864
865   // Construct message in the message queue memory; note that delete should not be called on the return value
866   new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
867 }
868
869 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
870 {
871   typedef MessageValue1< Node, bool > LocalType;
872
873   // Reserve some memory inside the message queue
874   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
875
876   // Construct message in the message queue memory; note that delete should not be called on the return value
877   new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
878 }
879
880 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
881 {
882   typedef MessageValue1< Node, bool > LocalType;
883
884   // Reserve some memory inside the message queue
885   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
886
887   // Construct message in the message queue memory; note that delete should not be called on the return value
888   new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
889 }
890
891 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
892 {
893   typedef MessageValue1< Node, ColorMode > LocalType;
894
895   // Reserve some memory inside the message queue
896   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
897
898   // Construct message in the message queue memory; note that delete should not be called on the return value
899   new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
900 }
901
902 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
903 {
904   typedef MessageValue1< Node, DrawMode::Type > LocalType;
905
906   // Reserve some memory inside the message queue
907   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
908
909   // Construct message in the message queue memory; note that delete should not be called on the return value
910   new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
911 }
912
913 inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
914 {
915   typedef MessageValue1< Node, Renderer* > LocalType;
916
917   // Reserve some memory inside the message queue
918   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
919
920   // Construct message in the message queue memory; note that delete should not be called on the return value
921   new (slot) LocalType( &node, &Node::AddRenderer, renderer );
922 }
923
924 inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
925 {
926   typedef MessageValue1< Node, Renderer* > LocalType;
927
928   // Reserve some memory inside the message queue
929   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
930
931   // Construct message in the message queue memory; note that delete should not be called on the return value
932   new (slot) LocalType( &node, &Node::RemoveRenderer, renderer );
933 }
934 } // namespace SceneGraph
935
936 } // namespace Internal
937
938 } // namespace Dali
939
940 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_H_