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