Added object sizes to platform abstraction in profiling section
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / layer-impl.h
1 #ifndef __DALI_INTERNAL_LAYER_H__
2 #define __DALI_INTERNAL_LAYER_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/actors/layer.h>
22 #include <dali/internal/event/actors/actor-impl.h>
23 #include <dali/internal/event/actors/actor-declarations.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 class LayerList;
32
33 namespace SceneGraph
34 {
35 class UpdateManager;
36 class Layer;
37 }
38
39 typedef Dali::ClippingBox ClippingBox;
40
41 class Layer : public Actor
42 {
43 public:
44
45   /**
46    * @copydoc Dali::Layer::ZValue(const Vector3&, float)
47    */
48   static float ZValue(const Vector3& position, float sortModifier)
49   {
50     // inlined so we avoid a function call when sorting renderers
51     return position.z + sortModifier;
52   }
53
54   /**
55    * Create a new Layer.
56    * @return A smart-pointer to the newly allocated Layer.
57    */
58   static LayerPtr New();
59
60   /**
61    * Create a new root layer; this is typically owned by the stage.
62    * @param[in] stage The owning stage.
63    * @param[in] layerList The layer will be added to this ordered list.
64    * @param[in] manager The update manager to install a root node with.
65    * @param[in] systemLevel True if using the SystemOverlay API; see Integration::GetSystemOverlay() for more details.
66    * @return A smart-pointer to the newly allocated Actor.
67    */
68   static LayerPtr NewRoot( Stage& stage, LayerList& layerList, SceneGraph::UpdateManager& manager, bool systemLevel );
69
70   /**
71    * @copydoc Dali::Internal::Actor::OnInitialize
72    */
73   void OnInitialize();
74
75   /**
76    * Query the current depth of the layer
77    */
78   unsigned int GetDepth() const;
79
80   /**
81    * @copydoc Dali::Layer::Raise
82    */
83   void Raise();
84
85   /**
86    * @copydoc Dali::Layer::Lower
87    */
88   void Lower();
89
90   /**
91    * @copydoc Dali::Layer::RaiseAbove
92    */
93   void RaiseAbove( const Internal::Layer& target );
94
95   /**
96    * @copydoc Dali::Layer::LowerBelow
97    */
98   void LowerBelow( const Internal::Layer& target );
99
100   /**
101    * @copydoc Dali::Layer::RaiseToTop
102    */
103   void RaiseToTop();
104
105   /**
106    * @copydoc Dali::Layer::LowerToBottom
107    */
108   void LowerToBottom();
109
110   /**
111    * @copydoc Dali::Layer::MoveAbove
112    */
113   void MoveAbove( const Internal::Layer& target );
114
115   /**
116    * @copydoc Dali::Layer::MoveAbove
117    */
118   void MoveBelow( const Internal::Layer& target );
119
120   /**
121    * @copydoc Dali::Layer::SetClipping()
122    */
123   void SetClipping(bool enabled);
124
125   /**
126    * @copydoc Dali::Layer::IsClipping()
127    */
128   bool IsClipping() const
129   {
130     return mIsClipping; // Actor-side has most up-to-date value
131   }
132
133   /**
134    * @copydoc Dali::Layer::SetClippingBox()
135    */
136   void SetClippingBox(int x, int y, int width, int height);
137
138   /**
139    * @copydoc Dali::Layer::GetClippingBox()
140    */
141   const Dali::ClippingBox& GetClippingBox() const
142   {
143     return mClippingBox; // Actor-side has most up-to-date value
144   }
145
146   /**
147    * @copydoc Dali::Layer::SetDepthTestDisabled()
148    */
149   void SetDepthTestDisabled( bool disable );
150
151   /**
152    * @copydoc Dali::Layer::IsDepthTestDisabled()
153    */
154   bool IsDepthTestDisabled() const;
155
156   /**
157    * @copydoc Dali::Layer::SetSortFunction()
158    */
159   void SetSortFunction(Dali::Layer::SortFunctionType function);
160
161   /**
162    * Helper function to get the scene object.
163    * This should only be called by Stage
164    * @return the scene object for the layer.
165    */
166   const SceneGraph::Layer& GetSceneLayerOnStage() const;
167
168   /**
169    * @copydoc Dali::Internal::Actor::DoAction()
170    */
171   static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
172
173 public: // Default property extensions from ProxyObject
174   /**
175    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
176    */
177   virtual unsigned int GetDefaultPropertyCount() const;
178
179   /**
180    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
181    */
182   virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
183
184   /**
185    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
186    */
187   virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
188
189   /**
190    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
191    */
192   virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
193
194   /**
195    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
196    */
197   virtual bool IsDefaultPropertyWritable(Property::Index index) const;
198
199   /**
200    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
201    */
202   virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
203
204   /**
205    * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
206    */
207   virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
208
209   /**
210    * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
211    */
212   virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
213
214   /**
215    * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
216    */
217   virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
218
219   /**
220    * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
221    */
222   virtual Property::Value GetDefaultProperty( Property::Index index ) const;
223
224 protected:
225
226   /**
227    * Construct a new layer.
228    * @param[in] type Either Actor::LAYER or Actor::ROOT_LAYER if this is the root actor.
229    */
230   Layer( Actor::DerivedType type );
231
232   /**
233    * A reference counted object may only be deleted by calling Unreference()
234    */
235   virtual ~Layer();
236
237 private: // From Actor
238
239   /**
240    * From Actor; create a node to represent the layer in the scene-graph.
241    * @return A newly allocated layer node.
242    */
243   virtual SceneGraph::Node* CreateNode() const;
244
245   /**
246    * From Actor.
247    */
248   virtual void OnStageConnectionInternal();
249
250   /**
251    * From Actor.
252    */
253   virtual void OnStageDisconnectionInternal();
254
255 private:
256
257   LayerList* mLayerList; ///< Only valid when layer is on-stage
258
259   // These properties not animatable; the actor side has the most up-to-date values
260   ClippingBox mClippingBox;                     ///< The clipping box, in window coordinates
261   Dali::Layer::SortFunctionType mSortFunction;  ///< Used to sort semi-transparent geometry
262
263   bool mIsClipping:1;                           ///< True when clipping is enabled
264   bool mDepthTestDisabled:1;                    ///< Whether depth test is disabled.
265
266   static bool mFirstInstance;
267   static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties
268 };
269
270 } // namespace Internal
271
272 // Helpers for public-api forwarding methods
273
274 inline Internal::Layer& GetImplementation(Dali::Layer& layer)
275 {
276   DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
277
278   BaseObject& handle = layer.GetBaseObject();
279
280   return static_cast<Internal::Layer&>(handle);
281 }
282
283 inline const Internal::Layer& GetImplementation(const Dali::Layer& layer)
284 {
285   DALI_ASSERT_ALWAYS(layer && "Layer handle is empty");
286
287   const BaseObject& handle = layer.GetBaseObject();
288
289   return static_cast<const Internal::Layer&>(handle);
290 }
291
292 } // namespace Dali
293
294
295 #endif //__DALI_INTERNAL_LAYER_H__