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 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
115 * @note The node is expected to be const in the thread which sends this message.
116 * However it can be modified when Process() is called in a different thread.
117 * @param[in] updateManager The update-manager.
118 * @param[in] node The node.
119 * @param[in] property The property to bake.
120 * @param[in] member The member function of the object.
121 * @param[in] value The new value of the property.
123 NodePropertyMessage( UpdateManager& updateManager,
125 const AnimatableProperty<P>* property,
126 MemberFunction member,
127 typename ParameterType< P >::PassingType value )
128 : NodePropertyMessageBase( updateManager ),
129 mNode( const_cast< Node* >( node ) ),
130 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
131 mMemberFunction( member ),
139 AnimatableProperty<P>* mProperty;
140 MemberFunction mMemberFunction;
141 typename ParameterType< P >::HolderType mParam;
145 * Templated message which bakes a Node property.
147 template< typename P >
148 class NodePropertyComponentMessage : public NodePropertyMessageBase
152 typedef void(AnimatableProperty<P>::*MemberFunction)( BufferIndex, float );
156 * @note The node is expected to be const in the thread which sends this message.
157 * However it can be modified when Process() is called in a different thread.
158 * @param[in] eventThreadServices The object used to send messages to the scene graph
159 * @param[in] node The node.
160 * @param[in] property The property to bake.
161 * @param[in] member The member function of the object.
162 * @param[in] value The new value of the X,Y,Z or W component.
164 static void Send( EventThreadServices& eventThreadServices,
166 const AnimatableProperty<P>* property,
167 MemberFunction member,
170 // Reserve some memory inside the message queue
171 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyComponentMessage ) );
173 // Construct message in the message queue memory; note that delete should not be called on the return value
174 new (slot) NodePropertyComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
180 virtual ~NodePropertyComponentMessage()
185 * @copydoc MessageBase::Process
187 virtual void Process( BufferIndex updateBufferIndex )
189 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
196 * @note The node is expected to be const in the thread which sends this message.
197 * However it can be modified when Process() is called in a different thread.
198 * @param[in] updateManager The update-manager.
199 * @param[in] node The node.
200 * @param[in] property The property to bake.
201 * @param[in] member The member function of the object.
202 * @param[in] value The new value of the X,Y,Z or W component.
204 NodePropertyComponentMessage( UpdateManager& updateManager,
206 const AnimatableProperty<P>* property,
207 MemberFunction member,
209 : NodePropertyMessageBase( updateManager ),
210 mNode( const_cast< Node* >( node ) ),
211 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
212 mMemberFunction( member ),
220 AnimatableProperty<P>* mProperty;
221 MemberFunction mMemberFunction;
226 template <typename P>
227 class NodeTransformPropertyMessage : public NodePropertyMessageBase
231 typedef void(TransformManagerPropertyHandler<P>::*MemberFunction)( BufferIndex, const P& );
235 * @note The node is expected to be const in the thread which sends this message.
236 * However it can be modified when Process() is called in a different thread.
237 * @param[in] eventThreadServices The object used to send messages to the scene graph
238 * @param[in] node The node.
239 * @param[in] property The property to bake.
240 * @param[in] member The member function of the object.
241 * @param[in] value The new value of the property.
243 static void Send( EventThreadServices& eventThreadServices,
245 const TransformManagerPropertyHandler<P>* property,
246 MemberFunction member,
249 // Reserve some memory inside the message queue
250 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformPropertyMessage ) );
252 // Construct message in the message queue memory; note that delete should not be called on the return value
253 new (slot) NodeTransformPropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
259 virtual ~NodeTransformPropertyMessage()
264 * @copydoc MessageBase::Process
266 virtual void Process( BufferIndex updateBufferIndex )
268 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
275 * @note The node is expected to be const in the thread which sends this message.
276 * However it can be modified when Process() is called in a different thread.
277 * @param[in] updateManager The update-manager.
278 * @param[in] node The node.
279 * @param[in] property The property to bake.
280 * @param[in] member The member function of the object.
281 * @param[in] value The new value of the property.
283 NodeTransformPropertyMessage( UpdateManager& updateManager,
285 const TransformManagerPropertyHandler<P>* property,
286 MemberFunction member,
288 : NodePropertyMessageBase( updateManager ),
289 mNode( const_cast< Node* >( node ) ),
290 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
291 mMemberFunction( member ),
299 TransformManagerPropertyHandler<P>* mProperty;
300 MemberFunction mMemberFunction;
305 template <typename P>
306 class NodeTransformComponentMessage : public NodePropertyMessageBase
310 typedef void(TransformManagerPropertyHandler<P>::*MemberFunction)( BufferIndex, float );
314 * @note The node is expected to be const in the thread which sends this message.
315 * However it can be modified when Process() is called in a different thread.
316 * @param[in] eventThreadServices The object used to send messages to the scene graph
317 * @param[in] node The node.
318 * @param[in] property The property to bake.
319 * @param[in] member The member function of the object.
320 * @param[in] value The new value of the X,Y,Z or W component.
322 static void Send( EventThreadServices& eventThreadServices,
324 const TransformManagerPropertyHandler<P>* property,
325 MemberFunction member,
328 // Reserve some memory inside the message queue
329 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformComponentMessage ) );
331 // Construct message in the message queue memory; note that delete should not be called on the return value
332 new (slot) NodeTransformComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
338 virtual ~NodeTransformComponentMessage()
343 * @copydoc MessageBase::Process
345 virtual void Process( BufferIndex updateBufferIndex )
347 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
354 * @note The node is expected to be const in the thread which sends this message.
355 * However it can be modified when Process() is called in a different thread.
356 * @param[in] updateManager The update-manager.
357 * @param[in] node The node.
358 * @param[in] property The property to bake.
359 * @param[in] member The member function of the object.
360 * @param[in] value The new value of the X,Y,Z or W component.
362 NodeTransformComponentMessage( UpdateManager& updateManager,
364 const TransformManagerPropertyHandler<P>* property,
365 MemberFunction member,
367 : NodePropertyMessageBase( updateManager ),
368 mNode( const_cast< Node* >( node ) ),
369 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
370 mMemberFunction( member ),
378 TransformManagerPropertyHandler<P>* mProperty;
379 MemberFunction mMemberFunction;
383 } // namespace SceneGraph
385 } // namespace Internal
389 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H