1 #ifndef DALI_UPDATE_PROXY_H
2 #define DALI_UPDATE_PROXY_H
5 * Copyright (c) 2020 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 size.
76 * @param[in] id The Actor ID
77 * @param[out] size Set to the Actor's current size, if Actor ID is valid
78 * @return Whether the method call was successful or not.
80 bool GetSize(uint32_t id, Vector3& size) const;
83 * @brief Allows setting an Actor's size from the Frame callback function for the current frame only.
84 * @param[in] id The Actor ID
85 * @param[in] size The size 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 SetSize(uint32_t id, const Vector3& size);
92 * @brief Allows baking an Actor's size from the Frame callback function.
93 * @param[in] id The Actor ID
94 * @param[in] size The size 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 BakeSize(uint32_t id, const Vector3& size);
101 * @brief Given the Actor ID, this retrieves that Actor's local position and size.
102 * @param[in] id The Actor ID
103 * @param[out] position Set to the Actor's current position, if Actor ID is valid
104 * @param[out] size Set to the Actor's current size, if Actor ID is valid
105 * @return Whether the method call was successful or not.
107 bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
110 * @brief Given the Actor ID, this retrieves that Actor's local scale.
111 * @param[in] id The Actor ID
112 * @param[out] scale Set to the Actor's current scale, if Actor ID is valid
113 * @return Whether the method call was successful or not.
115 bool GetScale(uint32_t id, Vector3& scale) const;
118 * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only.
119 * @param[in] id The Actor ID
120 * @param[in] scale The scale to set
121 * @return Whether the method call was successful or not.
122 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
124 bool SetScale(uint32_t id, const Vector3& scale);
127 * @brief Allows baking an Actor's local scale from the Frame callback function.
128 * @param[in] id The Actor ID
129 * @param[in] scale The scale to bake
130 * @return Whether the method call was successful or not.
131 * @note The value is saved so will cause undesired effects if this property is being animated.
133 bool BakeScale(uint32_t id, const Vector3& scale);
136 * @brief Given the Actor ID, this retrieves that Actor's local color.
137 * @param[in] id The Actor ID
138 * @param[out] color Set to the Actor's current color, if Actor ID is valid
139 * @return Whether the method call was successful or not.
141 bool GetColor(uint32_t id, Vector4& color) const;
144 * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only.
145 * @param[in] id The Actor ID
146 * @param[in] color The color to set
147 * @return Whether the method call was successful or not.
148 * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again.
150 bool SetColor(uint32_t id, const Vector4& color);
153 * @brief Allows baking an Actor's local color from the Frame callback function.
154 * @param[in] id The Actor ID
155 * @param[in] color The color to bake
156 * @return Whether the method call was successful or not.
157 * @note The value is saved so will cause undesired effects if this property is being animated.
159 bool BakeColor(uint32_t id, const Vector4& color);
161 public: // Not intended for application developers
165 * @brief Constructor.
166 * @param[in] impl A reference to the internal object.
168 DALI_INTERNAL UpdateProxy(Internal::UpdateProxy& impl);
173 DALI_INTERNAL ~UpdateProxy();
175 // Not copyable or movable
177 UpdateProxy(const UpdateProxy&) = delete; ///< Deleted copy constructor
178 UpdateProxy(UpdateProxy&&) = delete; ///< Deleted move constructor
179 UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator
180 UpdateProxy& operator=(UpdateProxy&&) = delete; ///< Deleted move assignment operator
186 Internal::UpdateProxy& mImpl;
192 #endif // DALI_UPDATE_PROXY_H