1 #ifndef DALI_UPDATE_PROXY_H
2 #define DALI_UPDATE_PROXY_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.
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/math/matrix.h>
27 #include <dali/public-api/math/vector3.h>
31 namespace Internal DALI_INTERNAL
37 * @brief This class is used to access data of the actors from the update-thread.
39 * The Actor API _CANNOT_ be called directly from the update-thread.
40 * This class can be used as a proxy to that required Actor data.
41 * An actor's data can be accessed using the Actor's Unique ID.
42 * The unique ID should be passed to the callback using this class in a thread-safe manner
43 * (as you cannot call Actor::GetId from the update-thread).
45 class DALI_CORE_API UpdateProxy
49 * @brief Given the Actor ID, this retrieves that Actor's local position.
50 * @param[in] id The Actor ID
51 * @param[out] position Set to the Actor's current position, if Actor ID is valid
52 * @return Whether the method call was successful or not.
54 bool GetPosition(uint32_t id, Vector3& position) const;
57 * @brief Allows setting an Actor's local position from the Frame callback function for the current frame only.
58 * @param[in] id The Actor ID
59 * @param[in] position The position to set
60 * @return Whether the method call was successful or not.
61 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
63 bool SetPosition(uint32_t id, const Vector3& position);
66 * @brief Allows baking an Actor's local position from the Frame callback function.
67 * @param[in] id The Actor ID
68 * @param[in] position The position to bake
69 * @return Whether the method call was successful or not.
70 * @note The value is saved so will cause undesired effects if this property is being animated.
72 bool BakePosition(uint32_t id, const Vector3& position);
75 * @brief Given the Actor ID, this retrieves that Actor's local orientation.
76 * @param[in] id The Actor ID
77 * @param[out] orientation Set to the Actor's current orientation, if Actor ID is valid
78 * @return Whether the method call was successful or not.
80 bool GetOrientation(uint32_t id, Quaternion& orientation) const;
83 * @brief Allows setting an Actor's local orientation from the Frame callback function for the current frame only.
84 * @param[in] id The Actor ID
85 * @param[in] orientation The orientation to set
86 * @return Whether the method call was successful or not.
87 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
89 bool SetOrientation(uint32_t id, const Quaternion& orientation);
92 * @brief Allows baking an Actor's local orientation from the Frame callback function.
93 * @param[in] id The Actor ID
94 * @param[in] orientation The orientation to bake
95 * @return Whether the method call was successful or not.
96 * @note The value is saved so will cause undesired effects if this property is being animated.
98 bool BakeOrientation(uint32_t id, const Quaternion& orientation);
101 * @brief Given the Actor ID, this retrieves that Actor's size.
102 * @param[in] id The Actor ID
103 * @param[out] size Set to the Actor's current size, if Actor ID is valid
104 * @return Whether the method call was successful or not.
106 bool GetSize(uint32_t id, Vector3& size) const;
109 * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
110 * @param[in] id The Actor ID
111 * @param[in] size The size to set
112 * @return Whether the method call was successful or not.
113 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
115 bool SetSize(uint32_t id, const Vector3& size);
118 * @brief Allows baking an Actor's size from the Frame callback function.
119 * @param[in] id The Actor ID
120 * @param[in] size The size to bake
121 * @return Whether the method call was successful or not.
122 * @note The value is saved so will cause undesired effects if this property is being animated.
124 bool BakeSize(uint32_t id, const Vector3& size);
127 * @brief Given the Actor ID, this retrieves that Actor's local position and size.
128 * @param[in] id The Actor ID
129 * @param[out] position Set to the Actor's current position, if Actor ID is valid
130 * @param[out] size Set to the Actor's current size, if Actor ID is valid
131 * @return Whether the method call was successful or not.
133 bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
136 * @brief Given the Actor ID, this retrieves that Actor's world position and size.
137 * @param[in] id The Actor ID
138 * @param[out] position Set to the Actor's current world position, if Actor ID is valid
139 * @param[out] scale Set to the Actor's current world scale, if Actor ID is valid
140 * @param[out] size Set to the Actor's current size, if Actor ID is valid
141 * @return Whether the method call was successful or not.
143 bool GetWorldPositionScaleAndSize(uint32_t id, Vector3& position, Vector3& scale, Vector3& size) const;
146 * @brief Given the Actor ID, this retrieves that Actor's world transform properties and size.
147 * @param[in] id The Actor ID
148 * @param[out] position Set to the Actor's current world position, if Actor ID is valid
149 * @param[out] scale Set to the Actor's current world scale, if Actor ID is valid
150 * @param[out] orientation Set to the Actor's current world orientation, if Actor ID is valid
151 * @param[out] size Set to the Actor's current size, if Actor ID is valid
152 * @return Whether the method call was successful or not.
154 bool GetWorldTransformAndSize(uint32_t id, Vector3& position, Vector3& scale, Quaternion& orientation, Vector3& size) const;
157 * @brief Given the Actor ID, this retrieves that Actor's local scale.
158 * @param[in] id The Actor ID
159 * @param[out] scale Set to the Actor's current scale, if Actor ID is valid
160 * @return Whether the method call was successful or not.
162 bool GetScale(uint32_t id, Vector3& scale) const;
165 * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
166 * @param[in] id The Actor ID
167 * @param[in] scale The scale to set
168 * @return Whether the method call was successful or not.
169 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
171 bool SetScale(uint32_t id, const Vector3& scale);
174 * @brief Allows baking an Actor's local scale from the Frame callback function.
175 * @param[in] id The Actor ID
176 * @param[in] scale The scale to bake
177 * @return Whether the method call was successful or not.
178 * @note The value is saved so will cause undesired effects if this property is being animated.
180 bool BakeScale(uint32_t id, const Vector3& scale);
183 * @brief Given the Actor ID, this retrieves that Actor's local color.
184 * @param[in] id The Actor ID
185 * @param[out] color Set to the Actor's current color, if Actor ID is valid
186 * @return Whether the method call was successful or not.
188 bool GetColor(uint32_t id, Vector4& color) const;
191 * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
192 * @param[in] id The Actor ID
193 * @param[in] color The color to set
194 * @return Whether the method call was successful or not.
195 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
197 bool SetColor(uint32_t id, const Vector4& color);
200 * @brief Allows baking an Actor's local color from the Frame callback function.
201 * @param[in] id The Actor ID
202 * @param[in] color The color to bake
203 * @return Whether the method call was successful or not.
204 * @note The value is saved so will cause undesired effects if this property is being animated.
206 bool BakeColor(uint32_t id, const Vector4& color);
208 public: // Not intended for application developers
212 * @brief Constructor.
213 * @param[in] impl A reference to the internal object.
215 DALI_INTERNAL UpdateProxy(Internal::UpdateProxy& impl);
220 DALI_INTERNAL ~UpdateProxy();
222 // Not copyable or movable
224 UpdateProxy(const UpdateProxy&) = delete; ///< Deleted copy constructor
225 UpdateProxy(UpdateProxy&&) = delete; ///< Deleted move constructor
226 UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator
227 UpdateProxy& operator=(UpdateProxy&&) = delete; ///< Deleted move assignment operator
233 Internal::UpdateProxy& mImpl;
239 #endif // DALI_UPDATE_PROXY_H