Revert "[Tizen] Add codes for Dali Windows Backend"
[platform/core/uifw/dali-core.git] / dali / internal / update / nodes / scene-graph-layer.cpp
1 /*
2  * Copyright (c) 2016 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 : mSortFunction( Internal::Layer::ZValue ),
43   mClippingBox( 0,0,0,0 ),
44   mLastCamera( NULL ),
45   mBehavior( Dali::Layer::LAYER_2D ),
46   mIsClipping( false ),
47   mDepthTestDisabled( true ),
48   mIsDefaultSortFunction( true )
49 {
50   // set a flag the node to say this is a layer
51   mIsLayer = true;
52
53   // layer starts off dirty
54   mAllChildTransformsClean[ 0 ] = false;
55   mAllChildTransformsClean[ 1 ] = false;
56 }
57
58 Layer::~Layer()
59 {
60 }
61
62 void Layer::SetSortFunction( Dali::Layer::SortFunctionType function )
63 {
64   if( mSortFunction != function )
65   {
66     // is a custom sort function used
67     if( function != Internal::Layer::ZValue )
68     {
69       mIsDefaultSortFunction = false;
70     }
71     else
72     {
73       mIsDefaultSortFunction = true;
74     }
75
76     // changing the sort function makes the layer dirty
77     mAllChildTransformsClean[ 0 ] = false;
78     mAllChildTransformsClean[ 1 ] = false;
79     mSortFunction = function;
80   }
81 }
82
83 void Layer::SetClipping(bool enabled)
84 {
85   mIsClipping = enabled;
86 }
87
88 void Layer::SetClippingBox(const Dali::ClippingBox& box)
89 {
90   mClippingBox.Set(box.x, box.y, box.width, box.height);
91 }
92
93 void Layer::SetBehavior( Dali::Layer::Behavior behavior )
94 {
95   mBehavior = behavior;
96 }
97
98 void Layer::SetDepthTestDisabled( bool disable )
99 {
100   mDepthTestDisabled = disable;
101 }
102
103 bool Layer::IsDepthTestDisabled() const
104 {
105   return mDepthTestDisabled;
106 }
107
108 void Layer::ClearRenderables()
109 {
110   colorRenderables.Clear();
111   overlayRenderables.Clear();
112 }
113
114 } // namespace SceneGraph
115
116 template <>
117 void OwnerPointer<Dali::Internal::SceneGraph::Layer>::Reset()
118 {
119   if( mObject != NULL )
120   {
121     Dali::Internal::SceneGraph::Node::Delete( mObject );
122     mObject = NULL;
123   }
124 }
125 } // namespace Internal
126
127 } // namespace Dali