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