[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / scene-graph-layer.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/update/nodes/scene-graph-layer.h>
20 #include <dali/internal/event/actors/layer-impl.h>
21
22 // INTERNAL INCLUDES
23 #include <dali/public-api/common/dali-common.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace SceneGraph
32 {
33
34 SceneGraph::Layer* Layer::New()
35 {
36   // Layers are currently heap allocated, unlike Nodes which are in a memory pool
37   // However Node::Delete( layer ) will correctly delete a layer / node depending on type
38   return new Layer();
39 }
40
41 Layer::Layer()
42 : Node(),
43   mSortFunction( Internal::Layer::ZValue ),
44   mClippingBox( 0,0,0,0 ),
45   mLastCamera( NULL ),
46   mBehavior( Dali::Layer::LAYER_UI ),
47   mIsClipping( false ),
48   mDepthTestDisabled( true ),
49   mIsDefaultSortFunction( true )
50 {
51   // set a flag the node to say this is a layer
52   mIsLayer = true;
53
54   // layer starts off dirty
55   mAllChildTransformsClean[ 0 ] = false;
56   mAllChildTransformsClean[ 1 ] = false;
57 }
58
59 Layer::~Layer()
60 {
61 }
62
63 void Layer::SetSortFunction( Dali::Layer::SortFunctionType function )
64 {
65   if( mSortFunction != function )
66   {
67     SetPropertyDirty( true );
68     // is a custom sort function used
69     if( function != Internal::Layer::ZValue )
70     {
71       mIsDefaultSortFunction = false;
72     }
73     else
74     {
75       mIsDefaultSortFunction = true;
76     }
77
78     // changing the sort function makes the layer dirty
79     mAllChildTransformsClean[ 0 ] = false;
80     mAllChildTransformsClean[ 1 ] = false;
81     mSortFunction = function;
82   }
83 }
84
85 void Layer::SetClipping(bool enabled)
86 {
87   mIsClipping = enabled;
88   SetPropertyDirty( true );
89 }
90
91 void Layer::SetClippingBox(const Dali::ClippingBox& box)
92 {
93   mClippingBox.Set(box.x, box.y, box.width, box.height);
94   SetPropertyDirty( true );
95 }
96
97 void Layer::SetBehavior( Dali::Layer::Behavior behavior )
98 {
99   mBehavior = behavior;
100   SetPropertyDirty( true );
101 }
102
103 void Layer::SetDepthTestDisabled( bool disable )
104 {
105   mDepthTestDisabled = disable;
106   SetPropertyDirty( true );
107 }
108
109 bool Layer::IsDepthTestDisabled() const
110 {
111   return mDepthTestDisabled;
112 }
113
114 void Layer::ClearRenderables()
115 {
116   colorRenderables.Clear();
117   overlayRenderables.Clear();
118 }
119
120 } // namespace SceneGraph
121
122 } // namespace Internal
123
124 } // namespace Dali