1 #ifndef DALI_INTERNAL_UPDATE_PROXY_IMPL_H
2 #define DALI_INTERNAL_UPDATE_PROXY_IMPL_H
5 * Copyright (c) 2024 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/list-wrapper.h>
30 #include <dali/public-api/common/vector-wrapper.h>
31 #include <dali/public-api/math/matrix.h>
32 #include <dali/public-api/math/vector3.h>
34 #include <dali/internal/update/manager/scene-graph-traveler-interface.h>
46 * @brief The implementation of Dali::UpdateProxy.
48 * Ref-counting is not required for this object.
50 * @see Dali::UpdateProxy
57 * @param[in] updateManager Ref to the UpdateManager in order to add property resetters
58 * @param[in] transformManager Ref to the TransformManager in order to set/get transform properties of nodes
59 * @param[in] traveler The cache of traversal.
61 UpdateProxy(SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraphTravelerInterfacePtr traveler);
68 // Movable but not copyable
70 UpdateProxy(const UpdateProxy&) = delete; ///< Deleted copy constructor.
71 UpdateProxy(UpdateProxy&&) = default; ///< Default move constructor.
72 UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator.
73 UpdateProxy& operator=(UpdateProxy&&) = delete; ///< Deleted move assignment operator.
76 * @copydoc Dali::UpdateProxy::GetPosition()
78 bool GetPosition(uint32_t id, Vector3& position) const;
81 * @copydoc Dali::UpdateProxy::SetPosition()
83 bool SetPosition(uint32_t id, const Vector3& position);
86 * @copydoc Dali::UpdateProxy::BakePosition()
88 bool BakePosition(uint32_t id, const Vector3& position);
91 * @copydoc Dali::UpdateProxy::GetOrientation()
93 bool GetOrientation(uint32_t id, Quaternion& orientation) const;
96 * @copydoc Dali::UpdateProxy::SetOrientation()
98 bool SetOrientation(uint32_t id, const Quaternion& orientation);
101 * @copydoc Dali::UpdateProxy::BakeOrientation()
103 bool BakeOrientation(uint32_t id, const Quaternion& orientation);
106 * @copydoc Dali::UpdateProxy::GetSize()
108 bool GetSize(uint32_t id, Vector3& size) const;
111 * @copydoc Dali::UpdateProxy::SetSize()
113 bool SetSize(uint32_t id, const Vector3& size);
116 * @copydoc Dali::UpdateProxy::BakeSize()
118 bool BakeSize(uint32_t id, const Vector3& size);
121 * @copydoc Dali::UpdateProxy::GetPositionAndSize()
123 bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const;
126 * @copydoc Dali::UpdateProxy::GetWorldPositionScaleAndSize()
128 bool GetWorldPositionScaleAndSize(uint32_t id, Vector3& position, Vector3& scale, Vector3& size) const;
131 * @copydoc Dali::UpdateProxy::GetWorldTransformAndSize()
133 bool GetWorldTransformAndSize(uint32_t id, Vector3& position, Vector3& scale, Quaternion& orientation, Vector3& size) const;
136 * @copydoc Dali::UpdateProxy::GetScale()
138 bool GetScale(uint32_t id, Vector3& scale) const;
141 * @copydoc Dali::UpdateProxy::SetScale()
143 bool SetScale(uint32_t id, const Vector3& scale);
146 * @copydoc Dali::UpdateProxy::BakeScale()
148 bool BakeScale(uint32_t id, const Vector3& scale);
151 * @copydoc Dali::UpdateProxy::GetColor()
153 bool GetColor(uint32_t id, Vector4& color) const;
156 * @copydoc Dali::UpdateProxy::SetColor()
158 bool SetColor(uint32_t id, const Vector4& color);
161 * @copydoc Dali::UpdateProxy::BakeColor()
163 bool BakeColor(uint32_t id, const Vector4& color);
166 * @brief Sets the buffer index to use when processing the next callback.
167 * @param[in] bufferIndex The current buffer index
169 void SetCurrentBufferIndex(BufferIndex bufferIndex)
171 mCurrentBufferIndex = bufferIndex;
175 * @brief Informs the update-proxy that the node hierarchy has changed.
177 void NodeHierarchyChanged();
180 * @brief Inform the proxy that a sync point was requested.
182 * @param[in] syncPoint The sync point to notify with.
184 void Notify(Dali::UpdateProxy::NotifySyncPoint syncPoint);
187 * @brief Get the sync point from the proxy. If there was no sync point,
188 * this returns INVALID_SYNC. It is intended that this method is only called
189 * once per Update(), so clears any stored sync point.
190 * @return Valid sync point or INVALID_SYNC
192 Dali::UpdateProxy::NotifySyncPoint PopSyncPoint();
195 * @brief Adds node resetter for each dirty node whose animatable properties have been changed.
197 void AddNodeResetters();
200 * @copydoc Dali::UpdateProxy::GetUpdateArea()
202 bool GetUpdateArea(uint32_t id, Vector4& updateArea) const;
205 * @copydoc Dali::UpdateProxy::SetUpdateArea()
207 bool SetUpdateArea(uint32_t id, const Vector4& updateArea);
211 * @brief Retrieves the node with the specified ID.
212 * @param[in] id The ID of the node required
213 * @return A pointer to the required node if found.
214 * @note This caches the last accessed node.
216 SceneGraph::Node* GetNodeWithId(uint32_t id) const;
219 * @brief Adds a property-resetter for non-transform properties so that they can be reset to their base value every frame.
220 * @param[in] node The node the property belongs to
221 * @param[in] propertyBase The property itself
223 void AddResetter(SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase);
227 * Structure to store the ID & Node pair
231 uint32_t id; ///< The ID of the node
232 SceneGraph::Node* node; ///< The node itself
235 class PropertyModifier;
236 using PropertyModifierPtr = std::unique_ptr<PropertyModifier>;
238 mutable IdNodePair mLastCachedIdNodePair; ///< Used to cache the last retrieved id-node pair.
239 std::vector<uint32_t> mDirtyNodes; ///< Used to store the ID of the dirty nodes with non-transform property modifications.
240 BufferIndex mCurrentBufferIndex;
242 SceneGraph::UpdateManager& mUpdateManager; ///< Reference to the Update Manager.
243 SceneGraph::TransformManager& mTransformManager; ///< Reference to the Transform Manager.
244 SceneGraphTravelerInterfacePtr mSceneGraphTraveler; ///< The cache system when we travel scene graph. (Not owned)
246 std::list<Dali::UpdateProxy::NotifySyncPoint> mSyncPoints;
248 PropertyModifierPtr mPropertyModifier; ///< To ensure non-transform property modifications reset to base values.
251 } // namespace Internal
255 #endif // DALI_INTERNAL_UPDATE_PROXY_IMPL_H