[dali_1.1.12] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / scene-graph-layer.cpp
1 /*
2  * Copyright (c) 2014 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   return new Layer();
37 }
38
39 Layer::Layer()
40 : mSortFunction( Internal::Layer::ZValue ),
41   mClippingBox( 0,0,0,0 ),
42   mLastCamera( NULL ),
43   mBehavior( Dali::Layer::LAYER_2D ),
44   mIsClipping( false ),
45   mDepthTestDisabled( false ),
46   mIsDefaultSortFunction( true )
47 {
48   // layer starts off dirty
49   mAllChildTransformsClean[ 0 ] = false;
50   mAllChildTransformsClean[ 1 ] = false;
51 }
52
53 Layer::~Layer()
54 {
55 }
56
57 void Layer::SetSortFunction( Dali::Layer::SortFunctionType function )
58 {
59   if( mSortFunction != function )
60   {
61     // is a custom sort function used
62     if( function != Internal::Layer::ZValue )
63     {
64       mIsDefaultSortFunction = false;
65     }
66     else
67     {
68       mIsDefaultSortFunction = true;
69     }
70
71     // changing the sort function makes the layer dirty
72     mAllChildTransformsClean[ 0 ] = false;
73     mAllChildTransformsClean[ 1 ] = false;
74     mSortFunction = function;
75   }
76 }
77
78 void Layer::SetClipping(bool enabled)
79 {
80   mIsClipping = enabled;
81 }
82
83 void Layer::SetClippingBox(const Dali::ClippingBox& box)
84 {
85   mClippingBox.Set(box.x, box.y, box.width, box.height);
86 }
87
88 void Layer::SetBehavior( Dali::Layer::Behavior behavior )
89 {
90   mBehavior = behavior;
91 }
92
93 void Layer::SetDepthTestDisabled( bool disable )
94 {
95   mDepthTestDisabled = disable;
96 }
97
98 bool Layer::IsDepthTestDisabled() const
99 {
100   return ( mBehavior == Dali::Layer::LAYER_2D ) || mDepthTestDisabled;
101 }
102
103 void Layer::ClearRenderables()
104 {
105   stencilRenderables.Clear();
106   colorRenderables.Clear();
107   overlayRenderables.Clear();
108 }
109
110 } // namespace SceneGraph
111
112 } // namespace Internal
113
114 } // namespace Dali