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