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