1 #ifndef DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H
2 #define DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/internal/common/buffer-index.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/update/nodes/node.h>
25 #include <dali/internal/update/manager/update-manager.h>
38 class NodePropertyMessageBase : public MessageBase
45 NodePropertyMessageBase(UpdateManager& updateManager);
50 virtual ~NodePropertyMessageBase();
55 NodePropertyMessageBase(const NodePropertyMessageBase&);
56 NodePropertyMessageBase& operator=(const NodePropertyMessageBase& rhs);
60 UpdateManager& mUpdateManager;
64 * Templated message which bakes a Node property.
66 template< typename P >
67 class NodePropertyMessage : public NodePropertyMessageBase
71 typedef void(AnimatableProperty<P>::*MemberFunction)( BufferIndex, typename ParameterType< P >::PassingType );
75 * @note The node is expected to be const in the thread which sends this message.
76 * However it can be modified when Process() is called in a different thread.
77 * @param[in] eventThreadServices The object used to send messages to the scene graph
78 * @param[in] node The node.
79 * @param[in] property The property to bake.
80 * @param[in] member The member function of the object.
81 * @param[in] value The new value of the property.
83 static void Send( EventThreadServices& eventThreadServices,
85 const AnimatableProperty<P>* property,
86 MemberFunction member,
87 typename ParameterType< P >::PassingType value )
89 // Reserve some memory inside the message queue
90 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyMessage ) );
92 // Construct message in the message queue memory; note that delete should not be called on the return value
93 new (slot) NodePropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
99 virtual ~NodePropertyMessage()
104 * @copydoc MessageBase::Process
106 virtual void Process( BufferIndex updateBufferIndex )
108 mNode->SetPropertyDirty( true );
109 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
116 * @note The node is expected to be const in the thread which sends this message.
117 * However it can be modified when Process() is called in a different thread.
118 * @param[in] updateManager The update-manager.
119 * @param[in] node The node.
120 * @param[in] property The property to bake.
121 * @param[in] member The member function of the object.
122 * @param[in] value The new value of the property.
124 NodePropertyMessage( UpdateManager& updateManager,
126 const AnimatableProperty<P>* property,
127 MemberFunction member,
128 typename ParameterType< P >::PassingType value )
129 : NodePropertyMessageBase( updateManager ),
130 mNode( const_cast< Node* >( node ) ),
131 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
132 mMemberFunction( member ),
140 AnimatableProperty<P>* mProperty;
141 MemberFunction mMemberFunction;
142 typename ParameterType< P >::HolderType mParam;
146 * Templated message which bakes a Node property.
148 template< typename P >
149 class NodePropertyComponentMessage : public NodePropertyMessageBase
153 typedef void(AnimatableProperty<P>::*MemberFunction)( BufferIndex, float );
157 * @note The node is expected to be const in the thread which sends this message.
158 * However it can be modified when Process() is called in a different thread.
159 * @param[in] eventThreadServices The object used to send messages to the scene graph
160 * @param[in] node The node.
161 * @param[in] property The property to bake.
162 * @param[in] member The member function of the object.
163 * @param[in] value The new value of the X,Y,Z or W component.
165 static void Send( EventThreadServices& eventThreadServices,
167 const AnimatableProperty<P>* property,
168 MemberFunction member,
171 // Reserve some memory inside the message queue
172 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyComponentMessage ) );
174 // Construct message in the message queue memory; note that delete should not be called on the return value
175 new (slot) NodePropertyComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
181 virtual ~NodePropertyComponentMessage()
186 * @copydoc MessageBase::Process
188 virtual void Process( BufferIndex updateBufferIndex )
190 mNode->SetPropertyDirty( true );
191 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
198 * @note The node is expected to be const in the thread which sends this message.
199 * However it can be modified when Process() is called in a different thread.
200 * @param[in] updateManager The update-manager.
201 * @param[in] node The node.
202 * @param[in] property The property to bake.
203 * @param[in] member The member function of the object.
204 * @param[in] value The new value of the X,Y,Z or W component.
206 NodePropertyComponentMessage( UpdateManager& updateManager,
208 const AnimatableProperty<P>* property,
209 MemberFunction member,
211 : NodePropertyMessageBase( updateManager ),
212 mNode( const_cast< Node* >( node ) ),
213 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
214 mMemberFunction( member ),
222 AnimatableProperty<P>* mProperty;
223 MemberFunction mMemberFunction;
228 template <typename P>
229 class NodeTransformPropertyMessage : public NodePropertyMessageBase
233 typedef void(TransformManagerPropertyHandler<P>::*MemberFunction)( BufferIndex, const P& );
237 * @note The node is expected to be const in the thread which sends this message.
238 * However it can be modified when Process() is called in a different thread.
239 * @param[in] eventThreadServices The object used to send messages to the scene graph
240 * @param[in] node The node.
241 * @param[in] property The property to bake.
242 * @param[in] member The member function of the object.
243 * @param[in] value The new value of the property.
245 static void Send( EventThreadServices& eventThreadServices,
247 const TransformManagerPropertyHandler<P>* property,
248 MemberFunction member,
251 // Reserve some memory inside the message queue
252 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformPropertyMessage ) );
254 // Construct message in the message queue memory; note that delete should not be called on the return value
255 new (slot) NodeTransformPropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
261 virtual ~NodeTransformPropertyMessage()
266 * @copydoc MessageBase::Process
268 virtual void Process( BufferIndex updateBufferIndex )
270 mNode->SetPropertyDirty( true );
271 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
278 * @note The node is expected to be const in the thread which sends this message.
279 * However it can be modified when Process() is called in a different thread.
280 * @param[in] updateManager The update-manager.
281 * @param[in] node The node.
282 * @param[in] property The property to bake.
283 * @param[in] member The member function of the object.
284 * @param[in] value The new value of the property.
286 NodeTransformPropertyMessage( UpdateManager& updateManager,
288 const TransformManagerPropertyHandler<P>* property,
289 MemberFunction member,
291 : NodePropertyMessageBase( updateManager ),
292 mNode( const_cast< Node* >( node ) ),
293 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
294 mMemberFunction( member ),
302 TransformManagerPropertyHandler<P>* mProperty;
303 MemberFunction mMemberFunction;
308 template <typename P>
309 class NodeTransformComponentMessage : public NodePropertyMessageBase
313 typedef void(TransformManagerPropertyHandler<P>::*MemberFunction)( BufferIndex, float );
317 * @note The node is expected to be const in the thread which sends this message.
318 * However it can be modified when Process() is called in a different thread.
319 * @param[in] eventThreadServices The object used to send messages to the scene graph
320 * @param[in] node The node.
321 * @param[in] property The property to bake.
322 * @param[in] member The member function of the object.
323 * @param[in] value The new value of the X,Y,Z or W component.
325 static void Send( EventThreadServices& eventThreadServices,
327 const TransformManagerPropertyHandler<P>* property,
328 MemberFunction member,
331 // Reserve some memory inside the message queue
332 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformComponentMessage ) );
334 // Construct message in the message queue memory; note that delete should not be called on the return value
335 new (slot) NodeTransformComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
341 virtual ~NodeTransformComponentMessage()
346 * @copydoc MessageBase::Process
348 virtual void Process( BufferIndex updateBufferIndex )
350 mNode->SetPropertyDirty( true );
351 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
358 * @note The node is expected to be const in the thread which sends this message.
359 * However it can be modified when Process() is called in a different thread.
360 * @param[in] updateManager The update-manager.
361 * @param[in] node The node.
362 * @param[in] property The property to bake.
363 * @param[in] member The member function of the object.
364 * @param[in] value The new value of the X,Y,Z or W component.
366 NodeTransformComponentMessage( UpdateManager& updateManager,
368 const TransformManagerPropertyHandler<P>* property,
369 MemberFunction member,
371 : NodePropertyMessageBase( updateManager ),
372 mNode( const_cast< Node* >( node ) ),
373 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
374 mMemberFunction( member ),
382 TransformManagerPropertyHandler<P>* mProperty;
383 MemberFunction mMemberFunction;
387 } // namespace SceneGraph
389 } // namespace Internal
393 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H