1 #ifndef DALI_INTERNAL_UPDATE_PROXY_IMPL_H
2 #define DALI_INTERNAL_UPDATE_PROXY_IMPL_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.
26 #include <dali/internal/common/buffer-index.h>
27 #include <dali/internal/update/manager/transform-manager.h>
28 #include <dali/internal/update/nodes/node.h>
29 #include <dali/public-api/common/vector-wrapper.h>
30 #include <dali/public-api/math/matrix.h>
31 #include <dali/public-api/math/vector3.h>
43 * @brief The implementation of Dali::UpdateProxy.
45 * Ref-counting is not required for this object.
47 * @see Dali::UpdateProxy
54 * @param[in] updateManager Ref to the UpdateManager in order to add property resetters
55 * @param[in] transformManager Ref to the TransformManager in order to set/get transform properties of nodes
56 * @param[in] rootNode The root node for this proxy
58 UpdateProxy(SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode);
65 // Movable but not copyable
67 UpdateProxy(const UpdateProxy&) = delete; ///< Deleted copy constructor.
68 UpdateProxy(UpdateProxy&&) = default; ///< Default move constructor.
69 UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator.
70 UpdateProxy& operator=(UpdateProxy&&) = delete; ///< Deleted move assignment operator.
73 * @copydoc Dali::UpdateProxy::GetPosition()
75 bool GetPosition(uint32_t id, Vector3& position) const;
78 * @copydoc Dali::UpdateProxy::SetPosition()
80 bool SetPosition(uint32_t id, const Vector3& position);
83 * @copydoc Dali::UpdateProxy::BakePosition()
85 bool BakePosition(uint32_t id, const Vector3& position);
88 * @copydoc Dali::UpdateProxy::GetOrientation()
90 bool GetOrientation(uint32_t id, Quaternion& orientation) const;
93 * @copydoc Dali::UpdateProxy::SetOrientation()
95 bool SetOrientation(uint32_t id, const Quaternion& orientation);
98 * @copydoc Dali::UpdateProxy::BakeOrientation()
100 bool BakeOrientation(uint32_t id, const Quaternion& orientation);
103 * @copydoc Dali::UpdateProxy::GetSize()
105 bool GetSize(uint32_t id, Vector3& size) const;
108 * @copydoc Dali::UpdateProxy::SetSize()
110 bool SetSize(uint32_t id, const Vector3& size);
113 * @copydoc Dali::UpdateProxy::BakeSize()
115 bool BakeSize(uint32_t id, const Vector3& size);
118 * @copydoc Dali::UpdateProxy::GetPositionAndSize()
120 bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
123 * @copydoc Dali::UpdateProxy::GetWorldPositionScaleAndSize()
125 bool GetWorldPositionScaleAndSize(uint32_t id, Vector3& position, Vector3& scale, Vector3& size) const;
128 * @copydoc Dali::UpdateProxy::GetWorldTransformAndSize()
130 bool GetWorldTransformAndSize(uint32_t id, Vector3& position, Vector3& scale, Quaternion& orientation, Vector3& size) const;
133 * @copydoc Dali::UpdateProxy::GetScale()
135 bool GetScale(uint32_t id, Vector3& scale) const;
138 * @copydoc Dali::UpdateProxy::SetScale()
140 bool SetScale(uint32_t id, const Vector3& scale);
143 * @copydoc Dali::UpdateProxy::BakeScale()
145 bool BakeScale(uint32_t id, const Vector3& scale);
148 * @copydoc Dali::UpdateProxy::GetColor()
150 bool GetColor(uint32_t id, Vector4& color) const;
153 * @copydoc Dali::UpdateProxy::SetColor()
155 bool SetColor(uint32_t id, const Vector4& color);
158 * @copydoc Dali::UpdateProxy::BakeColor()
160 bool BakeColor(uint32_t id, const Vector4& color);
163 * @brief Retrieves the root-node used by this class
164 * @return The root node used by this class.
166 SceneGraph::Node& GetRootNode() const
172 * @brief Sets the buffer index to use when processing the next callback.
173 * @param[in] bufferIndex The current buffer index
175 void SetCurrentBufferIndex(BufferIndex bufferIndex)
177 mCurrentBufferIndex = bufferIndex;
181 * @brief Informs the update-proxy that the node hierarchy has changed.
183 void NodeHierarchyChanged();
186 * @brief Adds node resetter for each dirty node whose animatable properties have been changed.
188 void AddNodeResetters();
192 * @brief Retrieves the node with the specified ID.
193 * @param[in] id The ID of the node required
194 * @return A pointer to the required node if found.
195 * @note This caches the last accessed node.
197 SceneGraph::Node* GetNodeWithId(uint32_t id) const;
200 * @brief Adds a property-resetter for non-transform properties so that they can be reset to their base value every frame.
201 * @param[in] node The node the property belongs to
202 * @param[in] propertyBase The property itself
204 void AddResetter(SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase);
208 * Structure to store the ID & Node pair
212 uint32_t id; ///< The ID of the node
213 SceneGraph::Node* node; ///< The node itself
216 class PropertyModifier;
217 using PropertyModifierPtr = std::unique_ptr<PropertyModifier>;
219 mutable std::vector<IdNodePair> mNodeContainer; ///< Used to store cached pointers to already searched for Nodes.
220 mutable IdNodePair mLastCachedIdNodePair; ///< Used to cache the last retrieved id-node pair.
221 mutable std::vector<uint32_t> mDirtyNodes; ///< Used to store the ID of the dirty nodes with non-transform property modifications.
222 BufferIndex mCurrentBufferIndex;
224 SceneGraph::UpdateManager& mUpdateManager; ///< Reference to the Update Manager.
225 SceneGraph::TransformManager& mTransformManager; ///< Reference to the Transform Manager.
226 SceneGraph::Node& mRootNode; ///< The root node of this update proxy.
228 PropertyModifierPtr mPropertyModifier; ///< To ensure non-transform property modifications reset to base values.
231 } // namespace Internal
235 #endif // DALI_INTERNAL_UPDATE_PROXY_IMPL_H