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 * Type to define a unique sync point.
51 using NotifySyncPoint = int;
52 static constexpr NotifySyncPoint INVALID_SYNC{-1};
55 * @brief Given the Actor ID, this retrieves that Actor's local position.
56 * @param[in] id The Actor ID
57 * @param[out] position Set to the Actor's current position, if Actor ID is valid
58 * @return Whether the method call was successful or not.
60 bool GetPosition(uint32_t id, Vector3& position) const;
63 * @brief Allows setting an Actor's local position from the Frame callback function for the current frame only.
64 * @param[in] id The Actor ID
65 * @param[in] position The position to set
66 * @return Whether the method call was successful or not.
67 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
69 bool SetPosition(uint32_t id, const Vector3& position);
72 * @brief Allows baking an Actor's local position from the Frame callback function.
73 * @param[in] id The Actor ID
74 * @param[in] position The position to bake
75 * @return Whether the method call was successful or not.
76 * @note The value is saved so will cause undesired effects if this property is being animated.
78 bool BakePosition(uint32_t id, const Vector3& position);
81 * @brief Given the Actor ID, this retrieves that Actor's local orientation.
82 * @param[in] id The Actor ID
83 * @param[out] orientation Set to the Actor's current orientation, if Actor ID is valid
84 * @return Whether the method call was successful or not.
86 bool GetOrientation(uint32_t id, Quaternion& orientation) const;
89 * @brief Allows setting an Actor's local orientation from the Frame callback function for the current frame only.
90 * @param[in] id The Actor ID
91 * @param[in] orientation The orientation to set
92 * @return Whether the method call was successful or not.
93 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
95 bool SetOrientation(uint32_t id, const Quaternion& orientation);
98 * @brief Allows baking an Actor's local orientation from the Frame callback function.
99 * @param[in] id The Actor ID
100 * @param[in] orientation The orientation to bake
101 * @return Whether the method call was successful or not.
102 * @note The value is saved so will cause undesired effects if this property is being animated.
104 bool BakeOrientation(uint32_t id, const Quaternion& orientation);
107 * @brief Given the Actor ID, this retrieves that Actor's size.
108 * @param[in] id The Actor ID
109 * @param[out] size Set to the Actor's current size, if Actor ID is valid
110 * @return Whether the method call was successful or not.
112 bool GetSize(uint32_t id, Vector3& size) const;
115 * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
116 * @param[in] id The Actor ID
117 * @param[in] size The size to set
118 * @return Whether the method call was successful or not.
119 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
121 bool SetSize(uint32_t id, const Vector3& size);
124 * @brief Allows baking an Actor's size from the Frame callback function.
125 * @param[in] id The Actor ID
126 * @param[in] size The size to bake
127 * @return Whether the method call was successful or not.
128 * @note The value is saved so will cause undesired effects if this property is being animated.
130 bool BakeSize(uint32_t id, const Vector3& size);
133 * @brief Given the Actor ID, this retrieves that Actor's local position and size.
134 * @param[in] id The Actor ID
135 * @param[out] position Set to the Actor's current position, if Actor ID is valid
136 * @param[out] size Set to the Actor's current size, if Actor ID is valid
137 * @return Whether the method call was successful or not.
139 bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
142 * @brief Given the Actor ID, this retrieves that Actor's world position and size.
143 * @param[in] id The Actor ID
144 * @param[out] position Set to the Actor's current world position, if Actor ID is valid
145 * @param[out] scale Set to the Actor's current world scale, if Actor ID is valid
146 * @param[out] size Set to the Actor's current size, if Actor ID is valid
147 * @return Whether the method call was successful or not.
149 bool GetWorldPositionScaleAndSize(uint32_t id, Vector3& position, Vector3& scale, Vector3& size) const;
152 * @brief Given the Actor ID, this retrieves that Actor's world transform properties and size.
153 * @param[in] id The Actor ID
154 * @param[out] position Set to the Actor's current world position, if Actor ID is valid
155 * @param[out] scale Set to the Actor's current world scale, if Actor ID is valid
156 * @param[out] orientation Set to the Actor's current world orientation, if Actor ID is valid
157 * @param[out] size Set to the Actor's current size, if Actor ID is valid
158 * @return Whether the method call was successful or not.
160 bool GetWorldTransformAndSize(uint32_t id, Vector3& position, Vector3& scale, Quaternion& orientation, Vector3& size) const;
163 * @brief Given the Actor ID, this retrieves that Actor's local scale.
164 * @param[in] id The Actor ID
165 * @param[out] scale Set to the Actor's current scale, if Actor ID is valid
166 * @return Whether the method call was successful or not.
168 bool GetScale(uint32_t id, Vector3& scale) const;
171 * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
172 * @param[in] id The Actor ID
173 * @param[in] scale The scale to set
174 * @return Whether the method call was successful or not.
175 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
177 bool SetScale(uint32_t id, const Vector3& scale);
180 * @brief Allows baking an Actor's local scale from the Frame callback function.
181 * @param[in] id The Actor ID
182 * @param[in] scale The scale to bake
183 * @return Whether the method call was successful or not.
184 * @note The value is saved so will cause undesired effects if this property is being animated.
186 bool BakeScale(uint32_t id, const Vector3& scale);
189 * @brief Given the Actor ID, this retrieves that Actor's local color.
190 * @param[in] id The Actor ID
191 * @param[out] color Set to the Actor's current color, if Actor ID is valid
192 * @return Whether the method call was successful or not.
194 bool GetColor(uint32_t id, Vector4& color) const;
197 * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
198 * @param[in] id The Actor ID
199 * @param[in] color The color to set
200 * @return Whether the method call was successful or not.
201 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
203 bool SetColor(uint32_t id, const Vector4& color);
206 * @brief Allows baking an Actor's local color from the Frame callback function.
207 * @param[in] id The Actor ID
208 * @param[in] color The color to bake
209 * @return Whether the method call was successful or not.
210 * @note The value is saved so will cause undesired effects if this property is being animated.
212 bool BakeColor(uint32_t id, const Vector4& color);
215 * @brief Pop a sync point off the stack.
217 * Sync points can be added from the event side using Dali::DevelStage::NotifyFrameCallback().
218 * @return INVALID_SYNC if there was no SyncPoint, or a unique value if there was a sync point.
220 NotifySyncPoint PopSyncPoint();
223 * @brief Given the Actor ID, Gets the updated area of the actor.
225 * @param[in] id The Actor ID
226 * @param[out] updateArea Get to the Actor's current updated area, if Actor ID is valid
227 * @return Whether the method call was successful or not.
229 bool GetUpdateArea(uint32_t id, Vector4& updateArea) const;
232 * @brief Given the Actor ID, Sets the updated area of the actor.
234 * @param[in] id The Actor ID
235 * @param[in] updateArea Set to the Actor's current updated area, if Actor ID is valid
236 * @return Whether the method call was successful or not.
238 bool SetUpdateArea(uint32_t id, const Vector4& updateArea);
240 public: // Not intended for application developers
244 * @brief Constructor.
245 * @param[in] impl A reference to the internal object.
247 DALI_INTERNAL UpdateProxy(Internal::UpdateProxy& impl);
252 DALI_INTERNAL ~UpdateProxy();
254 // Not copyable or movable
256 UpdateProxy(const UpdateProxy&) = delete; ///< Deleted copy constructor
257 UpdateProxy(UpdateProxy&&) = delete; ///< Deleted move constructor
258 UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator
259 UpdateProxy& operator=(UpdateProxy&&) = delete; ///< Deleted move assignment operator
265 Internal::UpdateProxy& mImpl;
271 #endif // DALI_UPDATE_PROXY_H