1 #ifndef DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H
2 #define DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H
5 * Copyright (c) 2023 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.
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>
26 namespace Dali::Internal
28 // value types used by messages
30 struct ParameterType<Dali::Camera::Type>
31 : public BasicType<Dali::Camera::Type>
36 struct ParameterType<Dali::Camera::ProjectionMode>
37 : public BasicType<Dali::Camera::ProjectionMode>
43 inline void SetTypeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::Type parameter)
45 using LocalType = MessageValue1<Camera, Dali::Camera::Type>;
47 // Reserve some memory inside the message queue
48 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
54 inline void SetProjectionModeMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::Camera::ProjectionMode parameter)
56 using LocalProjectionMode = MessageValue1<Camera, Dali::Camera::ProjectionMode>;
58 // Reserve some memory inside the message queue
59 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionMode));
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);
65 inline void SetProjectionDirectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, Dali::DevelCameraActor::ProjectionDirection parameter)
67 using LocalProjectionDirection = MessageValue1<Camera, Dali::DevelCameraActor::ProjectionDirection>;
69 // Reserve some memory inside the message queue
70 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalProjectionDirection));
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);
76 inline void BakeFieldOfViewMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
78 using LocalType = MessageDoubleBuffered1<Camera, float>;
80 // Reserve some memory inside the message queue
81 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
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);
93 inline void BakeOrthographicSizeMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
95 using LocalType = MessageDoubleBuffered1<Camera, float>;
97 // Reserve some memory inside the message queue
98 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
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);
110 inline void BakeAspectRatioMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
112 using LocalType = MessageDoubleBuffered1<Camera, float>;
114 // Reserve some memory inside the message queue
115 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
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);
127 inline void SetNearClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
129 using LocalType = MessageValue1<Camera, float>;
131 // Reserve some memory inside the message queue
132 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
138 inline void SetFarClippingPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, float parameter)
140 using LocalType = MessageValue1<Camera, float>;
142 // Reserve some memory inside the message queue
143 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
149 inline void SetReflectByPlaneMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector4& plane)
151 using LocalType = MessageValue1<Camera, Vector4>;
153 // Reserve some memory inside the message queue
154 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
160 inline void SetTargetPositionMessage(EventThreadServices& eventThreadServices, const Camera& camera, const Vector3& parameter)
162 using LocalType = MessageValue1<Camera, Vector3>;
164 // Reserve some memory inside the message queue
165 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
171 inline void SetInvertYAxisMessage(EventThreadServices& eventThreadServices, const Camera& camera, bool parameter)
173 using LocalType = MessageValue1<Camera, bool>;
175 // Reserve some memory inside the message queue
176 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
182 inline void RotateProjectionMessage(EventThreadServices& eventThreadServices, const Camera& camera, int parameter)
184 typedef MessageValue1<Camera, int> LocalType;
186 // Reserve some memory inside the message queue
187 unsigned int* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
193 } // namespace SceneGraph
194 } // namespace Dali::Internal
196 #endif //DALI_INTERNAL_SCENE_GRAPH_CAMERA_MESSAGES_H