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