Remove batching.
[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) 2017 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 template <> struct ParameterType< ClippingMode::Type > : public BasicType< ClippingMode::Type > {};
52
53 namespace SceneGraph
54 {
55
56 class DiscardQueue;
57 class Layer;
58 class RenderTask;
59 class UpdateManager;
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    * This method sets clipping information on the node based on its hierarchy in the scene-graph.
147    * A value is calculated that can be used during sorting to increase sort speed.
148    * @param[in] clippingId The Clipping ID of the node to set
149    * @param[in] clippingDepth The Clipping Depth of the node to set
150    */
151   void SetClippingInformation( const uint32_t clippingId, const uint32_t clippingDepth )
152   {
153     // We only set up the sort value if we have a clipping depth, IE. At least 1 clipping node has been hit.
154     // If not, if we traverse down a clipping tree and back up, and there is another
155     // node on the parent, this will have a non-zero clipping ID that must be ignored
156     if( DALI_LIKELY( clippingDepth > 0u ) )
157     {
158       mClippingDepth = clippingDepth;
159
160       // Calculate the sort value here on write, as when read (during sort) it may be accessed several times.
161       // The items must be sorted by Clipping ID first (so the ID is kept in the most-significant bits).
162       // For the same ID, the clipping nodes must be first, so we negate the
163       // clipping enabled flag and set it as the least significant bit.
164       mClippingSortModifier = ( clippingId << 1u ) | ( mClippingMode == ClippingMode::DISABLED ? 1u : 0u );
165     }
166     else
167     {
168       // If we do not have a clipping depth, then set this to 0 so we do not have a Clipping ID either.
169       mClippingSortModifier = 0u;
170     }
171   }
172
173   /**
174    * Gets the Clipping ID for this node.
175    * @return The Clipping ID for this node.
176    */
177   uint32_t GetClippingId() const
178   {
179     return mClippingSortModifier >> 1u;
180   }
181
182   /**
183    * Gets the Clipping Depth for this node.
184    * @return The Clipping Depth for this node.
185    */
186   uint32_t GetClippingDepth() const
187   {
188     return mClippingDepth;
189   }
190
191   /**
192    * Sets the clipping mode for this node.
193    * @param[in] clippingMode The ClippingMode to set
194    */
195   void SetClippingMode( const ClippingMode::Type clippingMode )
196   {
197     mClippingMode = clippingMode;
198   }
199
200   /**
201    * Gets the Clipping Mode for this node.
202    * @return The ClippingMode of this node
203    */
204   ClippingMode::Type GetClippingMode() const
205   {
206     return mClippingMode;
207   }
208
209   /**
210    * Add a renderer to the node
211    * @param[in] renderer The renderer added to the node
212    */
213   void AddRenderer( Renderer* renderer );
214
215   /**
216    * Remove a renderer from the node
217    * @param[in] renderer The renderer to be removed
218    */
219   void RemoveRenderer( Renderer* renderer );
220
221   /*
222    * Get the renderer at the given index
223    * @param[in] index
224    */
225   Renderer* GetRendererAt( unsigned int index ) const
226   {
227     return mRenderer[index];
228   }
229
230   /**
231    * Retrieve the number of renderers for the node
232    */
233   unsigned int GetRendererCount()
234   {
235     return mRenderer.Size();
236   }
237
238   // Containment methods
239
240   /**
241    * Query whether a node is the root node. Root nodes cannot have a parent node.
242    * A node becomes a root node, when it is installed by UpdateManager.
243    * @return True if the node is a root node.
244    */
245   bool IsRoot() const
246   {
247     return mIsRoot;
248   }
249
250   /**
251    * Set whether a node is the root node. Root nodes cannot have a parent node.
252    * This method should only be called by UpdateManager.
253    * @pre When isRoot is true, the node must not have a parent.
254    * @param[in] isRoot Whether the node is now a root node.
255    */
256   void SetRoot(bool isRoot);
257
258   /**
259    * Retrieve the parent of a Node.
260    * @return The parent node, or NULL if the Node has not been added to the scene-graph.
261    */
262   Node* GetParent()
263   {
264     return mParent;
265   }
266
267   /**
268    * Retrieve the parent of a Node.
269    * @return The parent node, or NULL if the Node has not been added to the scene-graph.
270    */
271   const Node* GetParent() const
272   {
273     return mParent;
274   }
275
276   /**
277    * Connect a node to the scene-graph.
278    * @pre A node cannot be added to itself.
279    * @pre The parent node is connected to the scene-graph.
280    * @pre The childNode does not already have a parent.
281    * @pre The childNode is not a root node.
282    * @param[in] childNode The child to add.
283    */
284   void ConnectChild( Node* childNode );
285
286   /**
287    * Disconnect a child (& its children) from the scene-graph.
288    * @pre childNode is a child of this Node.
289    * @param[in] updateBufferIndex The current update buffer index.
290    * @param[in] childNode The node to disconnect.
291    */
292   void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode );
293
294   /**
295    * Retrieve the children a Node.
296    * @return The container of children.
297    */
298   const NodeContainer& GetChildren() const
299   {
300     return mChildren;
301   }
302
303   /**
304    * Retrieve the children a Node.
305    * @return The container of children.
306    */
307   NodeContainer& GetChildren()
308   {
309     return mChildren;
310   }
311
312   // Update methods
313
314   /**
315    * Flag that one of the node values has changed in the current frame.
316    * @param[in] flag The flag to set.
317    */
318   void SetDirtyFlag(NodePropertyFlags flag)
319   {
320     mDirtyFlags |= flag;
321   }
322
323   /**
324    * Flag that all of the node values are dirty.
325    */
326   void SetAllDirtyFlags()
327   {
328     mDirtyFlags = AllFlags;
329   }
330
331   /**
332    * Query whether a node is dirty.
333    * @return The dirty flags
334    */
335   int GetDirtyFlags() const;
336
337   /**
338    * Query whether a node is clean.
339    * @return True if the node is clean.
340    */
341   bool IsClean() const
342   {
343     return ( NothingFlag == GetDirtyFlags() );
344   }
345
346   /**
347    * Retrieve the parent-origin of the node.
348    * @return The parent-origin.
349    */
350   const Vector3& GetParentOrigin() const
351   {
352     return mParentOrigin.Get(0);
353   }
354
355   /**
356    * Sets both the local & base parent-origins of the node.
357    * @param[in] origin The new local & base parent-origins.
358    */
359   void SetParentOrigin(const Vector3& origin)
360   {
361     mParentOrigin.Set(0,origin );
362   }
363
364   /**
365    * Retrieve the anchor-point of the node.
366    * @return The anchor-point.
367    */
368   const Vector3& GetAnchorPoint() const
369   {
370     return mAnchorPoint.Get(0);
371   }
372
373   /**
374    * Sets both the local & base anchor-points of the node.
375    * @param[in] anchor The new local & base anchor-points.
376    */
377   void SetAnchorPoint(const Vector3& anchor)
378   {
379     mAnchorPoint.Set(0, anchor );
380   }
381
382   /**
383    * Retrieve the local position of the node, relative to its parent.
384    * @param[in] bufferIndex The buffer to read from.
385    * @return The local position.
386    */
387   const Vector3& GetPosition(BufferIndex bufferIndex) const
388   {
389     if( mTransformId != INVALID_TRANSFORM_ID )
390     {
391       return mPosition.Get(bufferIndex);
392     }
393
394     return Vector3::ZERO;
395   }
396
397   /**
398    * Retrieve the position of the node derived from the position of all its parents.
399    * @return The world position.
400    */
401   const Vector3& GetWorldPosition( BufferIndex bufferIndex ) const
402   {
403     return mWorldPosition.Get(bufferIndex);
404   }
405
406   /**
407    * Set whether the Node inherits position.
408    * @param[in] inherit True if the parent position is inherited.
409    */
410   void SetInheritPosition(bool inherit)
411   {
412     if( mTransformId != INVALID_TRANSFORM_ID )
413     {
414       mTransformManager->SetInheritPosition( mTransformId, inherit );
415     }
416   }
417
418   /**
419    * Retrieve the local orientation of the node, relative to its parent.
420    * @param[in] bufferIndex The buffer to read from.
421    * @return The local orientation.
422    */
423   const Quaternion& GetOrientation(BufferIndex bufferIndex) const
424   {
425     if( mTransformId != INVALID_TRANSFORM_ID )
426     {
427       return mOrientation.Get(0);
428     }
429
430     return Quaternion::IDENTITY;
431   }
432
433   /**
434    * Retrieve the orientation of the node derived from the rotation of all its parents.
435    * @param[in] bufferIndex The buffer to read from.
436    * @return The world rotation.
437    */
438   const Quaternion& GetWorldOrientation( BufferIndex bufferIndex ) const
439   {
440     return mWorldOrientation.Get(0);
441   }
442
443   /**
444    * Set whether the Node inherits orientation.
445    * @param[in] inherit True if the parent orientation is inherited.
446    */
447   void SetInheritOrientation(bool inherit)
448   {
449     if( mTransformId != INVALID_TRANSFORM_ID )
450     {
451       mTransformManager->SetInheritOrientation(mTransformId, inherit );
452     }
453   }
454
455   /**
456    * Retrieve the local scale of the node, relative to its parent.
457    * @param[in] bufferIndex The buffer to read from.
458    * @return The local scale.
459    */
460   const Vector3& GetScale(BufferIndex bufferIndex) const
461   {
462     if( mTransformId != INVALID_TRANSFORM_ID )
463     {
464       return mScale.Get(0);
465     }
466
467     return Vector3::ONE;
468   }
469
470
471   /**
472    * Retrieve the scale of the node derived from the scale of all its parents.
473    * @param[in] bufferIndex The buffer to read from.
474    * @return The world scale.
475    */
476   const Vector3& GetWorldScale( BufferIndex bufferIndex ) const
477   {
478     return mWorldScale.Get(0);
479   }
480
481   /**
482    * Set whether the Node inherits scale.
483    * @param inherit True if the Node inherits scale.
484    */
485   void SetInheritScale( bool inherit )
486   {
487     if( mTransformId != INVALID_TRANSFORM_ID )
488     {
489       mTransformManager->SetInheritScale(mTransformId, inherit );
490     }
491   }
492
493   /**
494    * Retrieve the visibility of the node.
495    * @param[in] bufferIndex The buffer to read from.
496    * @return True if the node is visible.
497    */
498   bool IsVisible(BufferIndex bufferIndex) const
499   {
500     return mVisible[bufferIndex];
501   }
502
503   /**
504    * Retrieve the opacity of the node.
505    * @param[in] bufferIndex The buffer to read from.
506    * @return The opacity.
507    */
508   float GetOpacity(BufferIndex bufferIndex) const
509   {
510     return mColor[bufferIndex].a;
511   }
512
513   /**
514    * Retrieve the color of the node.
515    * @param[in] bufferIndex The buffer to read from.
516    * @return The color.
517    */
518   const Vector4& GetColor(BufferIndex bufferIndex) const
519   {
520     return mColor[bufferIndex];
521   }
522
523   /**
524    * Sets the color of the node derived from the color of all its parents.
525    * @param[in] color The world color.
526    * @param[in] updateBufferIndex The current update buffer index.
527    */
528   void SetWorldColor(const Vector4& color, BufferIndex updateBufferIndex)
529   {
530     mWorldColor.Set( updateBufferIndex, color );
531   }
532
533   /**
534    * Sets the color of the node derived from the color of all its parents.
535    * This method should only be called when the parents world color is up-to-date.
536    * @pre The node has a parent.
537    * @param[in] updateBufferIndex The current update buffer index.
538    */
539   void InheritWorldColor( BufferIndex updateBufferIndex )
540   {
541     DALI_ASSERT_DEBUG(mParent != NULL);
542
543     // default first
544     if( mColorMode == USE_OWN_MULTIPLY_PARENT_ALPHA )
545     {
546       const Vector4& ownColor = mColor[updateBufferIndex];
547       mWorldColor.Set( updateBufferIndex, ownColor.r, ownColor.g, ownColor.b, ownColor.a * mParent->GetWorldColor(updateBufferIndex).a );
548     }
549     else if( mColorMode == USE_OWN_MULTIPLY_PARENT_COLOR )
550     {
551       mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) * mColor[updateBufferIndex] );
552     }
553     else if( mColorMode == USE_PARENT_COLOR )
554     {
555       mWorldColor.Set( updateBufferIndex, mParent->GetWorldColor(updateBufferIndex) );
556     }
557     else // USE_OWN_COLOR
558     {
559       mWorldColor.Set( updateBufferIndex, mColor[updateBufferIndex] );
560     }
561   }
562
563   /**
564    * Copies the previous inherited scale, if this changed in the previous frame.
565    * This method should be called instead of InheritWorldScale i.e. if the inherited scale
566    * does not need to be recalculated in the current frame.
567    * @param[in] updateBufferIndex The current update buffer index.
568    */
569   void CopyPreviousWorldColor( BufferIndex updateBufferIndex )
570   {
571     mWorldColor.CopyPrevious( updateBufferIndex );
572   }
573
574   /**
575    * Retrieve the color of the node, possibly derived from the color
576    * of all its parents, depending on the value of mColorMode.
577    * @param[in] bufferIndex The buffer to read from.
578    * @return The world color.
579    */
580   const Vector4& GetWorldColor(BufferIndex bufferIndex) const
581   {
582     return mWorldColor[bufferIndex];
583   }
584
585   /**
586    * Set the color mode. This specifies whether the Node uses its own color,
587    * or inherits its parent color.
588    * @param[in] colorMode The new color mode.
589    */
590   void SetColorMode(ColorMode colorMode)
591   {
592     mColorMode = colorMode;
593
594     SetDirtyFlag(ColorFlag);
595   }
596
597   /**
598    * Retrieve the color mode.
599    * @return The color mode.
600    */
601   ColorMode GetColorMode() const
602   {
603     return mColorMode;
604   }
605
606   /**
607    * Retrieve the size of the node.
608    * @param[in] bufferIndex The buffer to read from.
609    * @return The size.
610    */
611   const Vector3& GetSize(BufferIndex bufferIndex) const
612   {
613     if( mTransformId != INVALID_TRANSFORM_ID )
614     {
615       return mSize.Get(0);
616     }
617
618     return Vector3::ZERO;
619   }
620
621   /**
622    * Retrieve the bounding sphere of the node
623    * @return A vector4 describing the bounding sphere. XYZ is the center and W is the radius
624    */
625   const Vector4& GetBoundingSphere() const
626   {
627     if( mTransformId != INVALID_TRANSFORM_ID )
628     {
629       return mTransformManager->GetBoundingSphere( mTransformId );
630     }
631
632     return Vector4::ZERO;
633   }
634
635   /**
636    * Retrieve world matrix and size of the node
637    * @param[out] The local to world matrix of the node
638    * @param[out] size The current size of the node
639    */
640   void GetWorldMatrixAndSize( Matrix& worldMatrix, Vector3& size ) const
641   {
642     if( mTransformId != INVALID_TRANSFORM_ID )
643     {
644       mTransformManager->GetWorldMatrixAndSize( mTransformId, worldMatrix, size );
645     }
646   }
647
648   /**
649    * Checks if local matrix has changed since last update
650    * @return true if local matrix has changed, false otherwise
651    */
652   bool IsLocalMatrixDirty() const
653   {
654     return (mTransformId != INVALID_TRANSFORM_ID) &&
655            (mTransformManager->IsLocalMatrixDirty( mTransformId ));
656   }
657
658   /**
659    * Retrieve the cached world-matrix of a node.
660    * @param[in] bufferIndex The buffer to read from.
661    * @return The world-matrix.
662    */
663   const Matrix& GetWorldMatrix( BufferIndex bufferIndex ) const
664   {
665     return mWorldMatrix.Get(bufferIndex);
666   }
667
668   /**
669    * Mark the node as exclusive to a single RenderTask.
670    * @param[in] renderTask The render-task, or NULL if the Node is not exclusive to a single RenderTask.
671    */
672   void SetExclusiveRenderTask( RenderTask* renderTask )
673   {
674     mExclusiveRenderTask = renderTask;
675   }
676
677   /**
678    * Query whether the node is exclusive to a single RenderTask.
679    * @return The render-task, or NULL if the Node is not exclusive to a single RenderTask.
680    */
681   RenderTask* GetExclusiveRenderTask() const
682   {
683     return mExclusiveRenderTask;
684   }
685
686   /**
687    * Set how the Node and its children should be drawn; see Dali::Actor::SetDrawMode() for more details.
688    * @param[in] drawMode The new draw-mode to use.
689    */
690   void SetDrawMode( const DrawMode::Type& drawMode )
691   {
692     mDrawMode = drawMode;
693   }
694
695   /**
696    * Returns whether node is an overlay or not.
697    * @return True if node is an overlay, false otherwise.
698    */
699   DrawMode::Type GetDrawMode() const
700   {
701     return mDrawMode;
702   }
703
704   /*
705    * Returns the transform id of the node
706    * @return The transform component id of the node
707    */
708   TransformId GetTransformId() const
709   {
710     return mTransformId;
711   }
712
713   /**
714    * Equality operator, checks for identity, not values.
715    * @param[in]
716    */
717   bool operator==( const Node* rhs ) const
718   {
719     return ( this == rhs );
720   }
721
722   /**
723    * @brief Sets the sibling order of the node
724    * @param[in] order The new order
725    */
726   void SetDepthIndex( unsigned int depthIndex ){ mDepthIndex = depthIndex; }
727
728   /**
729    * @brief Get the depth index of the node
730    * @return Current depth index
731    */
732   unsigned int GetDepthIndex(){ return mDepthIndex; }
733
734 public:
735   /**
736    * @copydoc UniformMap::Add
737    */
738   void AddUniformMapping( UniformPropertyMapping* map );
739
740   /**
741    * @copydoc UniformMap::Remove
742    */
743   void RemoveUniformMapping( const std::string& uniformName );
744
745   /**
746    * Prepare the node for rendering.
747    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
748    * @param[in] updateBufferIndex The current update buffer index.
749    */
750   void PrepareRender( BufferIndex bufferIndex );
751
752   /**
753    * Called by UpdateManager when the node is added.
754    * Creates a new transform component in the transform manager and initialize all the properties
755    * related to the transformation
756    * @param[in] transformManager A pointer to the trnasform manager (Owned by UpdateManager)
757    */
758   void CreateTransform( SceneGraph::TransformManager* transformManager );
759
760 protected:
761
762   /**
763    * Set the parent of a Node.
764    * @param[in] parentNode the new parent.
765    */
766   void SetParent( Node& parentNode );
767
768 protected:
769
770   /**
771    * Protected constructor; See also Node::New()
772    */
773   Node();
774
775 private: // from NodeDataProvider
776
777   /**
778    * @copydoc NodeDataProvider::GetModelMatrix
779    */
780   virtual const Matrix& GetModelMatrix( unsigned int bufferId ) const
781   {
782     return GetWorldMatrix( bufferId );
783   }
784
785   /**
786    * @copydoc NodeDataProvider::GetRenderColor
787    */
788   virtual const Vector4& GetRenderColor( unsigned int bufferId ) const
789   {
790     return GetWorldColor( bufferId );
791   }
792
793 public: // From UniformMapDataProvider
794   /**
795    * @copydoc UniformMapDataProvider::GetUniformMapChanged
796    */
797   virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const
798   {
799     return mUniformMapChanged[bufferIndex];
800   }
801
802   /**
803    * @copydoc UniformMapDataProvider::GetUniformMap
804    */
805   virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const
806   {
807     return mCollectedUniformMap[bufferIndex];
808   }
809
810 private:
811
812   // Undefined
813   Node(const Node&);
814
815   // Undefined
816   Node& operator=(const Node& rhs);
817
818   /**
819    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
820    */
821   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
822
823   /**
824    * Recursive helper to disconnect a Node and its children.
825    * Disconnected Nodes have no parent or children.
826    * @param[in] updateBufferIndex The current update buffer index.
827    */
828   void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
829
830 public: // Default properties
831
832   TransformManager*                  mTransformManager;
833   TransformId                        mTransformId;
834   TransformManagerPropertyVector3    mParentOrigin;           ///< Local transform; the position is relative to this. Sets the TransformFlag dirty when changed
835   TransformManagerPropertyVector3    mAnchorPoint;            ///< Local transform; local center of rotation. Sets the TransformFlag dirty when changed
836   TransformManagerPropertyVector3    mSize;                   ///< Size is provided for layouting
837   TransformManagerPropertyVector3    mPosition;               ///< Local transform; distance between parent-origin & anchor-point
838   TransformManagerPropertyQuaternion mOrientation;            ///< Local transform; rotation relative to parent node
839   TransformManagerPropertyVector3    mScale;                  ///< Local transform; scale relative to parent node
840
841   AnimatableProperty<bool>           mVisible;                ///< Visibility can be inherited from the Node hierachy
842   AnimatableProperty<Vector4>        mColor;                  ///< Color can be inherited from the Node hierarchy
843
844   // Inherited properties; read-only from public API
845
846   TransformManagerVector3Input       mWorldPosition;          ///< Full inherited position
847   TransformManagerVector3Input       mWorldScale;
848   TransformManagerQuaternionInput    mWorldOrientation;       ///< Full inherited orientation
849   TransformManagerMatrixInput        mWorldMatrix;            ///< Full inherited world matrix
850   InheritedColor                     mWorldColor;             ///< Full inherited color
851
852   uint32_t                           mClippingSortModifier;   ///< Contains bit-packed clipping information for quick access when sorting
853
854 protected:
855
856   Node*                              mParent;                 ///< Pointer to parent node (a child is owned by its parent)
857   RenderTask*                        mExclusiveRenderTask;    ///< Nodes can be marked as exclusive to a single RenderTask
858
859   RendererContainer                  mRenderer;               ///< Container of renderers; not owned
860
861   NodeContainer                      mChildren;               ///< Container of children; not owned
862
863   CollectedUniformMap                mCollectedUniformMap[2]; ///< Uniform maps of the node
864   unsigned int                       mUniformMapChanged[2];   ///< Records if the uniform map has been altered this frame
865   uint32_t                           mClippingDepth;          ///< The number of clipping nodes deep this node is
866
867   uint32_t                           mDepthIndex;             ///< Depth index of the node
868
869   // flags, compressed to bitfield
870   unsigned int                       mRegenerateUniformMap:2; ///< Indicate if the uniform map has to be regenerated this frame
871   int                                mDirtyFlags:8;           ///< A composite set of flags for each of the Node properties
872   DrawMode::Type                     mDrawMode:2;             ///< How the Node and its children should be drawn
873   ColorMode                          mColorMode:2;            ///< Determines whether mWorldColor is inherited, 2 bits is enough
874   ClippingMode::Type                 mClippingMode:2;         ///< The clipping mode of this node
875   bool                               mIsRoot:1;               ///< True if the node cannot have a parent
876
877   // Changes scope, should be at end of class
878   DALI_LOG_OBJECT_STRING_DECLARATION;
879 };
880
881 // Messages for Node
882
883 inline void SetInheritOrientationMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
884 {
885   typedef MessageValue1< Node, bool > LocalType;
886
887   // Reserve some memory inside the message queue
888   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
889
890   // Construct message in the message queue memory; note that delete should not be called on the return value
891   new (slot) LocalType( &node, &Node::SetInheritOrientation, inherit );
892 }
893
894 inline void SetParentOriginMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& origin )
895 {
896   typedef MessageValue1< Node, Vector3 > LocalType;
897
898   // Reserve some memory inside the message queue
899   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
900
901   // Construct message in the message queue memory; note that delete should not be called on the return value
902   new (slot) LocalType( &node, &Node::SetParentOrigin, origin );
903 }
904
905 inline void SetAnchorPointMessage( EventThreadServices& eventThreadServices, const Node& node, const Vector3& anchor )
906 {
907   typedef MessageValue1< Node, Vector3 > LocalType;
908
909   // Reserve some memory inside the message queue
910   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
911
912   // Construct message in the message queue memory; note that delete should not be called on the return value
913   new (slot) LocalType( &node, &Node::SetAnchorPoint, anchor );
914 }
915
916 inline void SetInheritPositionMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
917 {
918   typedef MessageValue1< Node, bool > LocalType;
919
920   // Reserve some memory inside the message queue
921   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
922
923   // Construct message in the message queue memory; note that delete should not be called on the return value
924   new (slot) LocalType( &node, &Node::SetInheritPosition, inherit );
925 }
926
927 inline void SetInheritScaleMessage( EventThreadServices& eventThreadServices, const Node& node, bool inherit )
928 {
929   typedef MessageValue1< Node, bool > LocalType;
930
931   // Reserve some memory inside the message queue
932   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
933
934   // Construct message in the message queue memory; note that delete should not be called on the return value
935   new (slot) LocalType( &node, &Node::SetInheritScale, inherit );
936 }
937
938 inline void SetColorModeMessage( EventThreadServices& eventThreadServices, const Node& node, ColorMode colorMode )
939 {
940   typedef MessageValue1< Node, ColorMode > LocalType;
941
942   // Reserve some memory inside the message queue
943   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
944
945   // Construct message in the message queue memory; note that delete should not be called on the return value
946   new (slot) LocalType( &node, &Node::SetColorMode, colorMode );
947 }
948
949 inline void SetDrawModeMessage( EventThreadServices& eventThreadServices, const Node& node, DrawMode::Type drawMode )
950 {
951   typedef MessageValue1< Node, DrawMode::Type > LocalType;
952
953   // Reserve some memory inside the message queue
954   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
955
956   // Construct message in the message queue memory; note that delete should not be called on the return value
957   new (slot) LocalType( &node, &Node::SetDrawMode, drawMode );
958 }
959
960 inline void AddRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
961 {
962   typedef MessageValue1< Node, Renderer* > LocalType;
963
964   // Reserve some memory inside the message queue
965   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
966
967   // Construct message in the message queue memory; note that delete should not be called on the return value
968   new (slot) LocalType( &node, &Node::AddRenderer, renderer );
969 }
970
971 inline void RemoveRendererMessage( EventThreadServices& eventThreadServices, const Node& node, Renderer* renderer )
972 {
973   typedef MessageValue1< Node, Renderer* > LocalType;
974
975   // Reserve some memory inside the message queue
976   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
977
978   // Construct message in the message queue memory; note that delete should not be called on the return value
979   new (slot) LocalType( &node, &Node::RemoveRenderer, renderer );
980 }
981
982 inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Node& node, unsigned int depthIndex )
983 {
984   typedef MessageValue1< Node, unsigned int > LocalType;
985
986   // Reserve some memory inside the message queue
987   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
988
989   // Construct message in the message queue memory; note that delete should not be called on the return value
990   new (slot) LocalType( &node, &Node::SetDepthIndex, depthIndex );
991 }
992
993 inline void SetClippingModeMessage( EventThreadServices& eventThreadServices, const Node& node, ClippingMode::Type clippingMode )
994 {
995   typedef MessageValue1< Node, ClippingMode::Type > LocalType;
996
997   // Reserve some memory inside the message queue
998   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
999
1000   // Construct message in the message queue memory; note that delete should not be called on the return value
1001   new (slot) LocalType( &node, &Node::SetClippingMode, clippingMode );
1002 }
1003
1004
1005 } // namespace SceneGraph
1006
1007 } // namespace Internal
1008
1009 } // namespace Dali
1010
1011 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_H