Inline default layer sort function to avoid unnecessary function call
[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 Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/internal/update/nodes/scene-graph-layer.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/common/dali-common.h>
22
23
24 using namespace std;
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace SceneGraph
33 {
34
35 SceneGraph::Layer* Layer::New()
36 {
37   return new Layer();
38 }
39
40 Layer::Layer()
41 : mSortFunction( Dali::Layer::ZValue ),
42   mClippingBox( 0,0,0,0 ),
43   mIsClipping( false ),
44   mDepthTestDisabled( false ),
45   mIsDefaultSortFunction( true )
46 {
47   // layer starts off dirty
48   mAllChildTransformsClean[ 0 ] = false;
49   mAllChildTransformsClean[ 1 ] = false;
50 }
51
52 Layer::~Layer()
53 {
54 }
55
56 void Layer::SetSortFunction( Dali::Layer::SortFunctionType function )
57 {
58   if( mSortFunction != function )
59   {
60     // is a custom sort function used
61     if( function != Dali::Layer::ZValue )
62     {
63       mIsDefaultSortFunction = false;
64     }
65     else
66     {
67       mIsDefaultSortFunction = true;
68     }
69
70     // changing the sort function makes the layer dirty
71     mAllChildTransformsClean[ 0 ] = false;
72     mAllChildTransformsClean[ 1 ] = false;
73     mSortFunction = function;
74   }
75 }
76
77 void Layer::SetClipping(bool enabled)
78 {
79   mIsClipping = enabled;
80 }
81
82 void Layer::SetClippingBox(const Dali::ClippingBox& box)
83 {
84   mClippingBox.Set(box.x, box.y, box.width, box.height);
85 }
86
87 void Layer::SetDepthTestDisabled( bool disable )
88 {
89   mDepthTestDisabled = disable;
90 }
91
92 bool Layer::IsDepthTestDisabled() const
93 {
94   return mDepthTestDisabled;
95 }
96
97 } // namespace SceneGraph
98
99 } // namespace Internal
100
101 } // namespace Dali