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