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 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 unsigned int* 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 unsigned int* 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;
225 } // namespace SceneGraph
227 } // namespace Internal
231 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_MESSAGES_H__