1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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
11 // http://floralicense.org/license/
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.
21 #include <dali/internal/common/buffer-index.h>
22 #include <dali/internal/common/message.h>
23 #include <dali/internal/update/nodes/node.h>
24 #include <dali/internal/update/manager/update-manager.h>
37 class NodePropertyMessageBase : public MessageBase
44 NodePropertyMessageBase(UpdateManager& updateManager);
49 virtual ~NodePropertyMessageBase();
54 * Inform UpdateManager that the Node is now active
56 void NotifyUpdateManager( Node* node );
61 NodePropertyMessageBase(const NodePropertyMessageBase&);
62 NodePropertyMessageBase& operator=(const NodePropertyMessageBase& rhs);
66 UpdateManager& mUpdateManager;
70 * Templated message which bakes a Node property.
72 template< typename P >
73 class NodePropertyMessage : public NodePropertyMessageBase
77 typedef void(AnimatableProperty<P>::*MemberFunction)( BufferIndex, typename ParameterType< P >::PassingType );
81 * @note The node is expected to be const in the thread which sends this message.
82 * However it can be modified when Process() is called in a different thread.
83 * @param[in] updateManager The update-manager.
84 * @param[in] node The node.
85 * @param[in] property The property to bake.
86 * @param[in] member The member function of the object.
87 * @param[in] value The new value of the property.
89 static void Send( UpdateManager& updateManager,
91 const AnimatableProperty<P>* property,
92 MemberFunction member,
93 typename ParameterType< P >::PassingType value )
95 // Reserve some memory inside the message queue
96 unsigned int* slot = updateManager.GetEventToUpdate().ReserveMessageSlot( sizeof( NodePropertyMessage ) );
98 // Construct message in the message queue memory; note that delete should not be called on the return value
99 new (slot) NodePropertyMessage( updateManager, node, property, member, value );
105 virtual ~NodePropertyMessage()
110 * @copydoc MessageBase::Process
112 virtual void Process( BufferIndex updateBufferIndex )
114 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
116 if( ! mNode->IsActive() )
118 // Inform UpdateManager that the Node is now active
119 NotifyUpdateManager( mNode );
127 * @note The node is expected to be const in the thread which sends this message.
128 * However it can be modified when Process() is called in a different thread.
129 * @param[in] updateManager The update-manager.
130 * @param[in] node The node.
131 * @param[in] property The property to bake.
132 * @param[in] member The member function of the object.
133 * @param[in] value The new value of the property.
135 NodePropertyMessage( UpdateManager& updateManager,
137 const AnimatableProperty<P>* property,
138 MemberFunction member,
139 typename ParameterType< P >::PassingType value )
140 : NodePropertyMessageBase( updateManager ),
141 mNode( const_cast< Node* >( node ) ),
142 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
143 mMemberFunction( member ),
151 AnimatableProperty<P>* mProperty;
152 MemberFunction mMemberFunction;
153 typename ParameterType< P >::HolderType mParam;
157 * Templated message which bakes a Node property.
159 template< typename P >
160 class NodePropertyComponentMessage : public NodePropertyMessageBase
164 typedef void(AnimatableProperty<P>::*MemberFunction)( BufferIndex, float );
168 * @note The node is expected to be const in the thread which sends this message.
169 * However it can be modified when Process() is called in a different thread.
170 * @param[in] updateManager The update-manager.
171 * @param[in] node The node.
172 * @param[in] property The property to bake.
173 * @param[in] member The member function of the object.
174 * @param[in] value The new value of the X,Y,Z or W component.
176 static void Send( UpdateManager& updateManager,
178 const AnimatableProperty<P>* property,
179 MemberFunction member,
182 // Reserve some memory inside the message queue
183 unsigned int* slot = updateManager.GetEventToUpdate().ReserveMessageSlot( sizeof( NodePropertyComponentMessage ) );
185 // Construct message in the message queue memory; note that delete should not be called on the return value
186 new (slot) NodePropertyComponentMessage( updateManager, node, property, member, value );
192 virtual ~NodePropertyComponentMessage()
197 * @copydoc MessageBase::Process
199 virtual void Process( BufferIndex updateBufferIndex )
201 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
203 if( ! mNode->IsActive() )
205 // Inform UpdateManager that the Node is now active
206 NotifyUpdateManager( mNode );
214 * @note The node is expected to be const in the thread which sends this message.
215 * However it can be modified when Process() is called in a different thread.
216 * @param[in] updateManager The update-manager.
217 * @param[in] node The node.
218 * @param[in] property The property to bake.
219 * @param[in] member The member function of the object.
220 * @param[in] value The new value of the X,Y,Z or W component.
222 NodePropertyComponentMessage( UpdateManager& updateManager,
224 const AnimatableProperty<P>* property,
225 MemberFunction member,
227 : NodePropertyMessageBase( updateManager ),
228 mNode( const_cast< Node* >( node ) ),
229 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
230 mMemberFunction( member ),
238 AnimatableProperty<P>* mProperty;
239 MemberFunction mMemberFunction;
243 } // namespace SceneGraph
245 } // namespace Internal
249 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H__