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
103 * @copydoc MessageBase::Process
105 void Process( BufferIndex updateBufferIndex ) override
107 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
114 * @note The node is expected to be const in the thread which sends this message.
115 * However it can be modified when Process() is called in a different thread.
116 * @param[in] updateManager The update-manager.
117 * @param[in] node The node.
118 * @param[in] property The property to bake.
119 * @param[in] member The member function of the object.
120 * @param[in] value The new value of the property.
122 NodePropertyMessage( UpdateManager& updateManager,
124 const AnimatableProperty<P>* property,
125 MemberFunction member,
126 typename ParameterType< P >::PassingType value )
127 : NodePropertyMessageBase( updateManager ),
128 mNode( const_cast< Node* >( node ) ),
129 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
130 mMemberFunction( member ),
138 AnimatableProperty<P>* mProperty;
139 MemberFunction mMemberFunction;
140 typename ParameterType< P >::HolderType mParam;
144 * Templated message which bakes a Node property.
146 template< typename P >
147 class NodePropertyComponentMessage : public NodePropertyMessageBase
150 using MemberFunction = void ( AnimatableProperty<P>::* )( BufferIndex, float );
154 * @note The node is expected to be const in the thread which sends this message.
155 * However it can be modified when Process() is called in a different thread.
156 * @param[in] eventThreadServices The object used to send messages to the scene graph
157 * @param[in] node The node.
158 * @param[in] property The property to bake.
159 * @param[in] member The member function of the object.
160 * @param[in] value The new value of the X,Y,Z or W component.
162 static void Send( EventThreadServices& eventThreadServices,
164 const AnimatableProperty<P>* property,
165 MemberFunction member,
168 // Reserve some memory inside the message queue
169 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodePropertyComponentMessage ) );
171 // Construct message in the message queue memory; note that delete should not be called on the return value
172 new (slot) NodePropertyComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
178 ~NodePropertyComponentMessage() override
183 * @copydoc MessageBase::Process
185 void Process( BufferIndex updateBufferIndex ) override
187 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
194 * @note The node is expected to be const in the thread which sends this message.
195 * However it can be modified when Process() is called in a different thread.
196 * @param[in] updateManager The update-manager.
197 * @param[in] node The node.
198 * @param[in] property The property to bake.
199 * @param[in] member The member function of the object.
200 * @param[in] value The new value of the X,Y,Z or W component.
202 NodePropertyComponentMessage( UpdateManager& updateManager,
204 const AnimatableProperty<P>* property,
205 MemberFunction member,
207 : NodePropertyMessageBase( updateManager ),
208 mNode( const_cast< Node* >( node ) ),
209 mProperty( const_cast< AnimatableProperty<P>* >( property ) ),
210 mMemberFunction( member ),
218 AnimatableProperty<P>* mProperty;
219 MemberFunction mMemberFunction;
224 template <typename P>
225 class NodeTransformPropertyMessage : public NodePropertyMessageBase
228 using MemberFunction = void ( TransformManagerPropertyHandler<P>::* )( BufferIndex, const P& );
232 * @note The node is expected to be const in the thread which sends this message.
233 * However it can be modified when Process() is called in a different thread.
234 * @param[in] eventThreadServices The object used to send messages to the scene graph
235 * @param[in] node The node.
236 * @param[in] property The property to bake.
237 * @param[in] member The member function of the object.
238 * @param[in] value The new value of the property.
240 static void Send( EventThreadServices& eventThreadServices,
242 const TransformManagerPropertyHandler<P>* property,
243 MemberFunction member,
246 // Reserve some memory inside the message queue
247 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformPropertyMessage ) );
249 // Construct message in the message queue memory; note that delete should not be called on the return value
250 new (slot) NodeTransformPropertyMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
256 ~NodeTransformPropertyMessage() override
261 * @copydoc MessageBase::Process
263 void Process( BufferIndex updateBufferIndex ) override
265 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
272 * @note The node is expected to be const in the thread which sends this message.
273 * However it can be modified when Process() is called in a different thread.
274 * @param[in] updateManager The update-manager.
275 * @param[in] node The node.
276 * @param[in] property The property to bake.
277 * @param[in] member The member function of the object.
278 * @param[in] value The new value of the property.
280 NodeTransformPropertyMessage( UpdateManager& updateManager,
282 const TransformManagerPropertyHandler<P>* property,
283 MemberFunction member,
285 : NodePropertyMessageBase( updateManager ),
286 mNode( const_cast< Node* >( node ) ),
287 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
288 mMemberFunction( member ),
296 TransformManagerPropertyHandler<P>* mProperty;
297 MemberFunction mMemberFunction;
302 template <typename P>
303 class NodeTransformComponentMessage : public NodePropertyMessageBase
306 using MemberFunction = void ( TransformManagerPropertyHandler<P>::* )( BufferIndex, float );
310 * @note The node is expected to be const in the thread which sends this message.
311 * However it can be modified when Process() is called in a different thread.
312 * @param[in] eventThreadServices The object used to send messages to the scene graph
313 * @param[in] node The node.
314 * @param[in] property The property to bake.
315 * @param[in] member The member function of the object.
316 * @param[in] value The new value of the X,Y,Z or W component.
318 static void Send( EventThreadServices& eventThreadServices,
320 const TransformManagerPropertyHandler<P>* property,
321 MemberFunction member,
324 // Reserve some memory inside the message queue
325 uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( NodeTransformComponentMessage ) );
327 // Construct message in the message queue memory; note that delete should not be called on the return value
328 new (slot) NodeTransformComponentMessage( eventThreadServices.GetUpdateManager(), node, property, member, value );
334 ~NodeTransformComponentMessage() override
339 * @copydoc MessageBase::Process
341 void Process( BufferIndex updateBufferIndex ) override
343 (mProperty->*mMemberFunction)( updateBufferIndex, mParam );
350 * @note The node is expected to be const in the thread which sends this message.
351 * However it can be modified when Process() is called in a different thread.
352 * @param[in] updateManager The update-manager.
353 * @param[in] node The node.
354 * @param[in] property The property to bake.
355 * @param[in] member The member function of the object.
356 * @param[in] value The new value of the X,Y,Z or W component.
358 NodeTransformComponentMessage( UpdateManager& updateManager,
360 const TransformManagerPropertyHandler<P>* property,
361 MemberFunction member,
363 : NodePropertyMessageBase( updateManager ),
364 mNode( const_cast< Node* >( node ) ),
365 mProperty( const_cast< TransformManagerPropertyHandler<P>* >( property ) ),
366 mMemberFunction( member ),
374 TransformManagerPropertyHandler<P>* mProperty;
375 MemberFunction mMemberFunction;
379 } // namespace SceneGraph
381 } // namespace Internal
385 #endif // DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H