Merge changes I8783ad29,I2c860a84 into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / render-tasks / scene-graph-camera-messages.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H
2 #define DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H
3
4 /*
5  * Copyright (c) 2023 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 #include <dali/internal/common/message.h>
21 #include <dali/internal/common/type-abstraction-enums.h>
22 #include <dali/internal/event/common/event-thread-services.h>
23 #include <dali/internal/update/manager/update-manager.h>
24 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
25
26 namespace Dali::Internal
27 {
28 // value types used by messages
29 template<>
30 struct ParameterType<Dali::Camera::Type>
31 : public BasicType<Dali::Camera::Type>
32 {
33 };
34
35 template<>
36 struct ParameterType<Dali::Camera::ProjectionMode>
37 : public BasicType<Dali::Camera::ProjectionMode>
38 {
39 };
40
41 namespace SceneGraph
42 {
43 inline void SetTypeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::Type parameter)
44 {
45   using LocalType = MessageValue1<Camera, Dali::Camera::Type>;
46
47   // Reserve some memory inside the message queue
48   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
49
50   // Construct message in the message queue memory; note that delete should not be called on the return value
51   new(slot) LocalType(&camera, &Camera::SetType, parameter);
52 }
53
54 inline void SetProjectionModeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::ProjectionMode parameter)
55 {
56   using LocalProjectionMode = MessageValue1<Camera, Dali::Camera::ProjectionMode>;
57
58   // Reserve some memory inside the message queue
59   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionMode));
60
61   // Construct message in the message queue memory; note that delete should not be called on the return value
62   new(slot) LocalProjectionMode(&camera, &Camera::SetProjectionMode, parameter);
63 }
64
65 inline void SetProjectionDirectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::DevelCameraActor::ProjectionDirection parameter)
66 {
67   using LocalProjectionDirection = MessageValue1<Camera, Dali::DevelCameraActor::ProjectionDirection>;
68
69   // Reserve some memory inside the message queue
70   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionDirection));
71
72   // Construct message in the message queue memory; note that delete should not be called on the return value
73   new(slot) LocalProjectionDirection(&camera, &Camera::SetProjectionDirection, parameter);
74 }
75
76 inline void BakeFieldOfViewMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
77 {
78   using LocalType = MessageDoubleBuffered1<Camera, float>;
79
80   // Reserve some memory inside the message queue
81   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
82
83   // Construct message in the message queue memory; note that delete should not be called on the return value
84   new(slot) LocalType(&camera, &Camera::BakeFieldOfView, parameter);
85
86   OwnerPointer<SceneGraph::PropertyResetterBase> resetter(
87     new SceneGraph::BakerResetter(const_cast<SceneGraph::Camera*>(&camera),
88                                   const_cast<SceneGraph::AnimatableProperty<float>*>(&camera.mFieldOfView),
89                                   BakerResetter::Lifetime::BAKE));
90   AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
91 }
92
93 inline void BakeOrthographicSizeMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
94 {
95   using LocalType = MessageDoubleBuffered1<Camera, float>;
96
97   // Reserve some memory inside the message queue
98   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
99
100   // Construct message in the message queue memory; note that delete should not be called on the return value
101   new(slot) LocalType(&camera, &Camera::BakeOrthographicSize, parameter);
102
103   OwnerPointer<SceneGraph::PropertyResetterBase> resetter(
104     new SceneGraph::BakerResetter(const_cast<SceneGraph::Camera*>(&camera),
105                                   const_cast<SceneGraph::AnimatableProperty<float>*>(&camera.mOrthographicSize),
106                                   BakerResetter::Lifetime::BAKE));
107   AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
108 }
109
110 inline void BakeAspectRatioMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
111 {
112   using LocalType = MessageDoubleBuffered1<Camera, float>;
113
114   // Reserve some memory inside the message queue
115   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
116
117   // Construct message in the message queue memory; note that delete should not be called on the return value
118   new(slot) LocalType(&camera, &Camera::BakeAspectRatio, parameter);
119
120   OwnerPointer<SceneGraph::PropertyResetterBase> resetter(
121     new SceneGraph::BakerResetter(const_cast<SceneGraph::Camera*>(&camera),
122                                   const_cast<SceneGraph::AnimatableProperty<float>*>(&camera.mAspectRatio),
123                                   BakerResetter::Lifetime::BAKE));
124   AddResetterMessage(eventThreadServices.GetUpdateManager(), resetter);
125 }
126
127 inline void SetNearClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
128 {
129   using LocalType = MessageValue1<Camera, float>;
130
131   // Reserve some memory inside the message queue
132   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
133
134   // Construct message in the message queue memory; note that delete should not be called on the return value
135   new(slot) LocalType(&camera, &Camera::SetNearClippingPlane, parameter);
136 }
137
138 inline void SetFarClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
139 {
140   using LocalType = MessageValue1<Camera, float>;
141
142   // Reserve some memory inside the message queue
143   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
144
145   // Construct message in the message queue memory; note that delete should not be called on the return value
146   new(slot) LocalType(&camera, &Camera::SetFarClippingPlane, parameter);
147 }
148
149 inline void SetReflectByPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector4& plane)
150 {
151   using LocalType = MessageValue1<Camera, Vector4>;
152
153   // Reserve some memory inside the message queue
154   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
155
156   // Construct message in the message queue memory; note that delete should not be called on the return value
157   new(slot) LocalType(&camera, &Camera::SetReflectByPlane, plane);
158 }
159
160 inline void SetTargetPositionMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector3& parameter)
161 {
162   using LocalType = MessageValue1<Camera, Vector3>;
163
164   // Reserve some memory inside the message queue
165   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
166
167   // Construct message in the message queue memory; note that delete should not be called on the return value
168   new(slot) LocalType(&camera, &Camera::SetTargetPosition, parameter);
169 }
170
171 inline void SetInvertYAxisMessage(EventThreadServices& eventThreadServices, const Camera& camera, bool parameter)
172 {
173   using LocalType = MessageValue1<Camera, bool>;
174
175   // Reserve some memory inside the message queue
176   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
177
178   // Construct message in the message queue memory; note that delete should not be called on the return value
179   new(slot) LocalType(&camera, &Camera::SetInvertYAxis, parameter);
180 }
181
182 inline void RotateProjectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, int parameter)
183 {
184   typedef MessageValue1<Camera, int> LocalType;
185
186   // Reserve some memory inside the message queue
187   unsigned int* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
188
189   // Construct message in the message queue memory; note that delete should not be called on the return value
190   new(slot) LocalType(&camera, &Camera::RotateProjection, parameter);
191 }
192
193 } // namespace SceneGraph
194 } // namespace Dali::Internal
195
196 #endif //DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H