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