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 ~NodePropertyMessageBase() override;
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
70 using MemberFunction = void ( AnimatableProperty<P>::* )( BufferIndex, typename ParameterType<P>::PassingType );
74 * @note The node is expected to be const in the thread which sends this message.
75 * However it can be modified when Process() is called in a different thread.
76 * @param[in] eventThreadServices The object used to send messages to the scene graph
77 * @param[in] node The node.
78 * @param[in] property The property to bake.
79 * @param[in] member The member function of the object.
80 * @param[in] value The new value of the property.
82 static void Send( EventThreadServices& eventThreadServices,
84 const AnimatableProperty<P>* property,
85 MemberFunction member,
86 typename ParameterType< P >::PassingType value )
88 // Reserve some memory inside the message queue
89 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyMessage ) );
91 // Construct message in the message queue memory; note that delete should not be called on the return value
92 new (slot) NodePropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
98 ~NodePropertyMessage() override = default;
101 * @copydoc MessageBase::Process
103 void Process( BufferIndex updateBufferIndex ) override
105 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
112 * @note The node is expected to be const in the thread which sends this message.
113 * However it can be modified when Process() is called in a different thread.
114 * @param[in] updateManager The update-manager.
115 * @param[in] node The node.
116 * @param[in] property The property to bake.
117 * @param[in] member The member function of the object.
118 * @param[in] value The new value of the property.
120 NodePropertyMessage( UpdateManager& updateManager,
122 const AnimatableProperty<P>* property,
123 MemberFunction member,
124 typename ParameterType< P >::PassingType value )
125 : NodePropertyMessageBase( updateManager ),
126 mNode( const_cast< Node* >( node ) ),
127 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
128 mMemberFunction( member ),
136 AnimatableProperty<P>* mProperty;
137 MemberFunction mMemberFunction;
138 typename ParameterType< P >::HolderType mParam;
142 * Templated message which bakes a Node property.
144 template< typename P >
145 class NodePropertyComponentMessage : public NodePropertyMessageBase
148 using MemberFunction = void ( AnimatableProperty<P>::* )( BufferIndex, float );
152 * @note The node is expected to be const in the thread which sends this message.
153 * However it can be modified when Process() is called in a different thread.
154 * @param[in] eventThreadServices The object used to send messages to the scene graph
155 * @param[in] node The node.
156 * @param[in] property The property to bake.
157 * @param[in] member The member function of the object.
158 * @param[in] value The new value of the X,Y,Z or W component.
160 static void Send( EventThreadServices& eventThreadServices,
162 const AnimatableProperty<P>* property,
163 MemberFunction member,
166 // Reserve some memory inside the message queue
167 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyComponentMessage ) );
169 // Construct message in the message queue memory; note that delete should not be called on the return value
170 new (slot) NodePropertyComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
176 ~NodePropertyComponentMessage() override = default;
179 * @copydoc MessageBase::Process
181 void Process( BufferIndex updateBufferIndex ) override
183 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
190 * @note The node is expected to be const in the thread which sends this message.
191 * However it can be modified when Process() is called in a different thread.
192 * @param[in] updateManager The update-manager.
193 * @param[in] node The node.
194 * @param[in] property The property to bake.
195 * @param[in] member The member function of the object.
196 * @param[in] value The new value of the X,Y,Z or W component.
198 NodePropertyComponentMessage( UpdateManager& updateManager,
200 const AnimatableProperty<P>* property,
201 MemberFunction member,
203 : NodePropertyMessageBase( updateManager ),
204 mNode( const_cast< Node* >( node ) ),
205 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
206 mMemberFunction( member ),
214 AnimatableProperty<P>* mProperty;
215 MemberFunction mMemberFunction;
220 template <typename P>
221 class NodeTransformPropertyMessage : public NodePropertyMessageBase
224 using MemberFunction = void ( TransformManagerPropertyHandler<P>::* )( BufferIndex, const P& );
228 * @note The node is expected to be const in the thread which sends this message.
229 * However it can be modified when Process() is called in a different thread.
230 * @param[in] eventThreadServices The object used to send messages to the scene graph
231 * @param[in] node The node.
232 * @param[in] property The property to bake.
233 * @param[in] member The member function of the object.
234 * @param[in] value The new value of the property.
236 static void Send( EventThreadServices& eventThreadServices,
238 const TransformManagerPropertyHandler<P>* property,
239 MemberFunction member,
242 // Reserve some memory inside the message queue
243 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformPropertyMessage ) );
245 // Construct message in the message queue memory; note that delete should not be called on the return value
246 new (slot) NodeTransformPropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
252 ~NodeTransformPropertyMessage() override = default;
255 * @copydoc MessageBase::Process
257 void Process( BufferIndex updateBufferIndex ) override
259 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
266 * @note The node is expected to be const in the thread which sends this message.
267 * However it can be modified when Process() is called in a different thread.
268 * @param[in] updateManager The update-manager.
269 * @param[in] node The node.
270 * @param[in] property The property to bake.
271 * @param[in] member The member function of the object.
272 * @param[in] value The new value of the property.
274 NodeTransformPropertyMessage( UpdateManager& updateManager,
276 const TransformManagerPropertyHandler<P>* property,
277 MemberFunction member,
279 : NodePropertyMessageBase( updateManager ),
280 mNode( const_cast< Node* >( node ) ),
281 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
282 mMemberFunction( member ),
290 TransformManagerPropertyHandler<P>* mProperty;
291 MemberFunction mMemberFunction;
296 template <typename P>
297 class NodeTransformComponentMessage : public NodePropertyMessageBase
300 using MemberFunction = void ( TransformManagerPropertyHandler<P>::* )( BufferIndex, float );
304 * @note The node is expected to be const in the thread which sends this message.
305 * However it can be modified when Process() is called in a different thread.
306 * @param[in] eventThreadServices The object used to send messages to the scene graph
307 * @param[in] node The node.
308 * @param[in] property The property to bake.
309 * @param[in] member The member function of the object.
310 * @param[in] value The new value of the X,Y,Z or W component.
312 static void Send( EventThreadServices& eventThreadServices,
314 const TransformManagerPropertyHandler<P>* property,
315 MemberFunction member,
318 // Reserve some memory inside the message queue
319 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformComponentMessage ) );
321 // Construct message in the message queue memory; note that delete should not be called on the return value
322 new (slot) NodeTransformComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
328 ~NodeTransformComponentMessage() override = default;
331 * @copydoc MessageBase::Process
333 void Process( BufferIndex updateBufferIndex ) override
335 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
342 * @note The node is expected to be const in the thread which sends this message.
343 * However it can be modified when Process() is called in a different thread.
344 * @param[in] updateManager The update-manager.
345 * @param[in] node The node.
346 * @param[in] property The property to bake.
347 * @param[in] member The member function of the object.
348 * @param[in] value The new value of the X,Y,Z or W component.
350 NodeTransformComponentMessage( UpdateManager& updateManager,
352 const TransformManagerPropertyHandler<P>* property,
353 MemberFunction member,
355 : NodePropertyMessageBase( updateManager ),
356 mNode( const_cast< Node* >( node ) ),
357 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
358 mMemberFunction( member ),
366 TransformManagerPropertyHandler<P>* mProperty;
367 MemberFunction mMemberFunction;
371 } // namespace SceneGraph
373 } // namespace Internal
377 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H