Merge "Use existing callback ID for recurring callbacks" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / gl-window.cpp
1 /*
2  * Copyright (c) 2020 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/devel-api/adaptor-framework/gl-window.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/adaptor-framework/window.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/window-system/common/gl-window-impl.h>
27 #include <dali/internal/window-system/common/orientation-impl.h>
28
29 namespace Dali
30 {
31
32 GlWindow GlWindow::New()
33 {
34   PositionSize positionSize( 0, 0, 0, 0 );
35   return Dali::GlWindow::New( positionSize, "", "", false );
36 }
37
38 GlWindow GlWindow::New(PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent )
39 {
40   GlWindow newWindow;
41   Internal::Adaptor::GlWindow* window = Internal::Adaptor::GlWindow::New( positionSize, name, className, isTransparent );
42   newWindow = GlWindow(window);
43
44   const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
45   if( isAdaptorAvailable )
46   {
47     Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
48     Dali::WindowContainer windows = adaptor.GetWindows();
49     if( !windows.empty() )
50     {
51       window->SetChild( windows[0] );
52     }
53   }
54   return newWindow;
55 }
56
57 GlWindow::GlWindow()
58 {
59 }
60
61 GlWindow::~GlWindow()
62 {
63 }
64
65 GlWindow::GlWindow(const GlWindow& handle) = default;
66
67 GlWindow& GlWindow::operator=(const GlWindow& rhs) = default;
68
69 GlWindow::GlWindow(GlWindow&& rhs) = default;
70
71 GlWindow& GlWindow::operator=(GlWindow&& rhs) = default;
72
73 void GlWindow::SetEglConfig( bool depth, bool stencil, int msaa, GlesVersion version )
74 {
75   GetImplementation(*this).SetEglConfig( depth, stencil, msaa, version );
76 }
77
78 void GlWindow::Raise()
79 {
80   GetImplementation(*this).Raise();
81 }
82
83 void GlWindow::Lower()
84 {
85   GetImplementation(*this).Lower();
86 }
87
88 void GlWindow::Activate()
89 {
90   GetImplementation(*this).Activate();
91 }
92
93 void GlWindow::Show()
94 {
95   GetImplementation(*this).Show();
96 }
97
98 void GlWindow::Hide()
99 {
100   GetImplementation(*this).Hide();
101 }
102
103 unsigned int GlWindow::GetSupportedAuxiliaryHintCount() const
104 {
105   return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
106 }
107
108 std::string GlWindow::GetSupportedAuxiliaryHint( unsigned int index ) const
109 {
110   return GetImplementation(*this).GetSupportedAuxiliaryHint( index );
111 }
112
113 unsigned int GlWindow::AddAuxiliaryHint( const std::string& hint, const std::string& value )
114 {
115   return GetImplementation(*this).AddAuxiliaryHint( hint, value );
116 }
117
118 bool GlWindow::RemoveAuxiliaryHint( unsigned int id )
119 {
120   return GetImplementation(*this).RemoveAuxiliaryHint( id );
121 }
122
123 bool GlWindow::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
124 {
125   return GetImplementation(*this).SetAuxiliaryHintValue( id, value );
126 }
127
128 std::string GlWindow::GetAuxiliaryHintValue( unsigned int id ) const
129 {
130   return GetImplementation(*this).GetAuxiliaryHintValue( id );
131 }
132
133 unsigned int GlWindow::GetAuxiliaryHintId( const std::string& hint ) const
134 {
135   return GetImplementation(*this).GetAuxiliaryHintId( hint );
136 }
137
138 void GlWindow::SetInputRegion( const Rect< int >& inputRegion )
139 {
140   GetImplementation(*this).SetInputRegion( inputRegion );
141 }
142
143 void GlWindow::SetOpaqueState( bool opaque )
144 {
145   GetImplementation(*this).SetOpaqueState( opaque );
146 }
147
148 bool GlWindow::IsOpaqueState() const
149 {
150   return GetImplementation(*this).IsOpaqueState();
151 }
152
153 void GlWindow::SetPositionSize( PositionSize positionSize )
154 {
155   GetImplementation(*this).SetPositionSize( positionSize );
156 }
157
158 PositionSize GlWindow::GetPositionSize() const
159 {
160   return GetImplementation(*this).GetPositionSize();
161 }
162
163 WindowOrientation GlWindow::GetCurrentOrientation() const
164 {
165   return GetImplementation( *this ).GetCurrentOrientation();
166 }
167
168 void GlWindow::SetAvailableOrientations( const Dali::Vector< WindowOrientation >& orientations )
169 {
170   GetImplementation( *this ).SetAvailableOrientations( orientations );
171 }
172
173 void GlWindow::SetPreferredOrientation( WindowOrientation orientation )
174 {
175   GetImplementation(*this).SetPreferredOrientation( orientation );
176 }
177
178 void GlWindow::RegisterGlCallback( CallbackBase* initCallback, CallbackBase* renderFrameCallback, CallbackBase* terminateCallback )
179 {
180   GetImplementation(*this).RegisterGlCallback( initCallback, renderFrameCallback, terminateCallback );
181 }
182
183 void GlWindow::RenderOnce()
184 {
185   GetImplementation(*this).RenderOnce();
186 }
187
188 GlWindow::FocusChangeSignalType& GlWindow::FocusChangeSignal()
189 {
190   return GetImplementation(*this).FocusChangeSignal();
191 }
192
193 GlWindow::ResizeSignalType& GlWindow::ResizeSignal()
194 {
195   return GetImplementation(*this).ResizeSignal();
196 }
197
198 GlWindow::KeyEventSignalType& GlWindow::KeyEventSignal()
199 {
200   return GetImplementation(*this).KeyEventSignal();
201 }
202
203 GlWindow::TouchEventSignalType& GlWindow::TouchedSignal()
204 {
205   return GetImplementation(*this).TouchedSignal();
206 }
207
208 GlWindow::VisibilityChangedSignalType& GlWindow::VisibilityChangedSignal()
209 {
210   return GetImplementation(*this).VisibilityChangedSignal();
211 }
212
213 GlWindow::GlWindow( Internal::Adaptor::GlWindow* window )
214 : BaseHandle( window )
215 {
216 }
217
218 }// Dali