(FrameCallback) All values now local & baking of the value supported
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-proxy-impl.h
1 #ifndef DALI_INTERNAL_UPDATE_PROXY_IMPL_H
2 #define DALI_INTERNAL_UPDATE_PROXY_IMPL_H
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/math/matrix.h>
26 #include <dali/public-api/math/vector3.h>
27 #include <dali/internal/common/buffer-index.h>
28 #include <dali/internal/update/manager/transform-manager.h>
29 #include <dali/internal/update/nodes/node.h>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 /**
38  * @brief The implementation of Dali::UpdateProxy.
39  *
40  * Ref-counting is not required for this object.
41  *
42  * @see Dali::UpdateProxy
43  */
44 class UpdateProxy
45 {
46 public:
47
48   /**
49    * @brief Constructor.
50    * @param[in]  transformManager   Ref to the TransformManager in order to set/get transform properties of nodes
51    * @param[in]  rootNode           The root node for this proxy
52    */
53   UpdateProxy( SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode );
54
55   /**
56    * @brief Destructor.
57    */
58   ~UpdateProxy();
59
60   // Movable but not copyable
61
62   UpdateProxy( const UpdateProxy& )            = delete;  ///< Deleted copy constructor.
63   UpdateProxy( UpdateProxy&& )                 = default; ///< Default move constructor.
64   UpdateProxy& operator=( const UpdateProxy& ) = delete;  ///< Deleted copy assignment operator.
65   UpdateProxy& operator=( UpdateProxy&& )      = default; ///< Default move assignment operator.
66
67   /**
68    * @copydoc Dali::UpdateProxy::GetPosition()
69    */
70   bool GetPosition( unsigned int id, Vector3& position) const;
71
72   /**
73    * @copydoc Dali::UpdateProxy::SetPosition()
74    */
75   bool SetPosition( unsigned int id, const Vector3& position );
76
77   /**
78    * @copydoc Dali::UpdateProxy::BakePosition()
79    */
80   bool BakePosition( unsigned int id, const Vector3& position );
81
82   /**
83    * @copydoc Dali::UpdateProxy::GetSize()
84    */
85   bool GetSize( unsigned int id, Vector3& size ) const;
86
87   /**
88    * @copydoc Dali::UpdateProxy::SetSize()
89    */
90   bool SetSize( unsigned int id, const Vector3& size );
91
92   /**
93    * @copydoc Dali::UpdateProxy::BakeSize()
94    */
95   bool BakeSize( unsigned int id, const Vector3& size );
96
97   /**
98    * @copydoc Dali::UpdateProxy::GetPositionAndSize()
99    */
100   bool GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const;
101
102   /**
103    * @copydoc Dali::UpdateProxy::GetScale()
104    */
105   bool GetScale( unsigned int id, Vector3& scale ) const;
106
107   /**
108    * @copydoc Dali::UpdateProxy::SetScale()
109    */
110   bool SetScale( unsigned int id, const Vector3& scale );
111
112   /**
113    * @copydoc Dali::UpdateProxy::BakeScale()
114    */
115   bool BakeScale( unsigned int id, const Vector3& scale );
116
117   /**
118    * @copydoc Dali::UpdateProxy::GetColor()
119    */
120   bool GetColor( unsigned int id, Vector4& color ) const;
121
122   /**
123    * @copydoc Dali::UpdateProxy::SetColor()
124    */
125   bool SetColor( unsigned int id, const Vector4& color ) const;
126
127   /**
128    * @copydoc Dali::UpdateProxy::BakeColor()
129    */
130   bool BakeColor( unsigned int id, const Vector4& color ) const;
131
132   /**
133    * @brief Retrieves the root-node used by this class
134    * @return The root node used by this class.
135    */
136   SceneGraph::Node& GetRootNode() const
137   {
138     return mRootNode;
139   }
140
141   /**
142    * @brief Sets the buffer index to use when processing the next callback.
143    * @param[in]  bufferIndex  The current buffer index
144    */
145   void SetCurrentBufferIndex( BufferIndex bufferIndex )
146   {
147     mCurrentBufferIndex = bufferIndex;
148   }
149
150   /**
151    * @brief Informs the update-proxy that the node hierarchy has changed.
152    */
153   void NodeHierarchyChanged();
154
155 private:
156
157   /**
158    * @brief Retrieves the node with the specified ID.
159    * @param[in]  id  The ID of the node required
160    * @return A pointer to the required node if found.
161    * @note This caches the last accessed node.
162    */
163   SceneGraph::Node* GetNodeWithId( unsigned int id ) const;
164
165 private:
166
167   /**
168    * Structure to store the ID & Node pair
169    */
170   struct IdNodePair
171   {
172     unsigned int id; ///< The ID of the node
173     SceneGraph::Node* node; ///< The node itself
174   };
175
176   mutable std::vector< IdNodePair > mNodeContainer; ///< Used to store cached pointers to already searched for Nodes.
177   mutable IdNodePair mLastCachedIdNodePair; ///< Used to cache the last retrieved id-node pair.
178   BufferIndex mCurrentBufferIndex;
179
180   SceneGraph::TransformManager& mTransformManager; ///< Reference to the Transform Manager.
181   SceneGraph::Node& mRootNode; ///< The root node of this update proxy.
182 };
183
184 } // namespace Internal
185
186 } // namespace Dali
187
188 #endif // DALI_INTERNAL_UPDATE_PROXY_IMPL_H