Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-core.git] / dali / internal / update / common / property-owner-messages.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/common/event-thread-services.h>
23 #include <dali/internal/update/common/property-owner.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace SceneGraph
32 {
33
34 // Messages for PropertyOwner
35
36 inline void InstallCustomPropertyMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, PropertyBase* property )
37 {
38   typedef MessageValue1< PropertyOwner, OwnerPointer<PropertyBase> > LocalType;
39
40   // Reserve some memory inside the message queue
41   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
42
43   // Construct message in the message queue memory; note that delete should not be called on the return value
44   new (slot) LocalType( &owner, &PropertyOwner::InstallCustomProperty, property );
45 }
46
47 inline void ApplyConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, ConstraintBase& constraint )
48 {
49   typedef MessageValue1< PropertyOwner, OwnerPointer<ConstraintBase> > LocalType;
50
51   // Reserve some memory inside the message queue
52   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
53
54   // Construct message in the message queue memory; note that delete should not be called on the return value
55   new (slot) LocalType( &owner, &PropertyOwner::ApplyConstraint, &constraint );
56 }
57
58 inline void RemoveConstraintMessage( EventThreadServices& eventThreadServices, const PropertyOwner& owner, const ConstraintBase& constConstraint )
59 {
60   // The update-thread can modify this object.
61   ConstraintBase& constraint = const_cast< ConstraintBase& >( constConstraint );
62
63   typedef MessageValue1< PropertyOwner, ConstraintBase* > LocalType;
64
65   // Reserve some memory inside the message queue
66   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
67
68   // Construct message in the message queue memory; note that delete should not be called on the return value
69   new (slot) LocalType( &owner, &PropertyOwner::RemoveConstraint, &constraint );
70 }
71
72 } // namespace SceneGraph
73
74 } // namespace Internal
75
76 } // namespace Dali
77
78 #endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_OWNER_MESSAGES_H__