b80123377a6ca804d668d40d24908ebfdea92b25
[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 GlWindow GlWindow::New()
32 {
33   PositionSize positionSize( 0, 0, 0, 0 );
34   return Dali::GlWindow::New( positionSize, "", "", false );
35 }
36 GlWindow GlWindow::New(PositionSize positionSize, const std::string& name, const std::string& className, bool isTransparent )
37 {
38   GlWindow newWindow;
39   Internal::Adaptor::GlWindow* window = Internal::Adaptor::GlWindow::New( positionSize, name, className, isTransparent );
40   if( window == nullptr )
41   {
42     DALI_LOG_ERROR("Fail to create gl-window-impl\n");
43   }
44   else
45   {
46     newWindow = GlWindow(window);
47   }
48   const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
49   if( isAdaptorAvailable )
50   {
51     Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
52     Dali::WindowContainer windows = adaptor.GetWindows();
53     if( !windows.empty() )
54     {
55       window->SetChild( windows[0] );
56     }
57   }
58   return newWindow;
59 }
60 GlWindow::GlWindow()
61 {
62 }
63 GlWindow::~GlWindow()
64 {
65 }
66 GlWindow::GlWindow(const GlWindow& handle)
67 : BaseHandle(handle)
68 {
69 }
70 GlWindow& GlWindow::operator=(const GlWindow& rhs)
71 {
72   BaseHandle::operator=(rhs);
73   return *this;
74 }
75 void GlWindow::SetEglConfig( bool depth, bool stencil, int msaa, GlesVersion version )
76 {
77   GetImplementation(*this).SetEglConfig( depth, stencil, msaa, version );
78 }
79 void GlWindow::Raise()
80 {
81   GetImplementation(*this).Raise();
82 }
83 void GlWindow::Lower()
84 {
85   GetImplementation(*this).Lower();
86 }
87 void GlWindow::Activate()
88 {
89   GetImplementation(*this).Activate();
90 }
91 void GlWindow::Show()
92 {
93   GetImplementation(*this).Show();
94 }
95 void GlWindow::Hide()
96 {
97   GetImplementation(*this).Hide();
98 }
99 unsigned int GlWindow::GetSupportedAuxiliaryHintCount() const
100 {
101   return GetImplementation(*this).GetSupportedAuxiliaryHintCount();
102 }
103 std::string GlWindow::GetSupportedAuxiliaryHint( unsigned int index ) const
104 {
105   return GetImplementation(*this).GetSupportedAuxiliaryHint( index );
106 }
107 unsigned int GlWindow::AddAuxiliaryHint( const std::string& hint, const std::string& value )
108 {
109   return GetImplementation(*this).AddAuxiliaryHint( hint, value );
110 }
111 bool GlWindow::RemoveAuxiliaryHint( unsigned int id )
112 {
113   return GetImplementation(*this).RemoveAuxiliaryHint( id );
114 }
115 bool GlWindow::SetAuxiliaryHintValue( unsigned int id, const std::string& value )
116 {
117   return GetImplementation(*this).SetAuxiliaryHintValue( id, value );
118 }
119 std::string GlWindow::GetAuxiliaryHintValue( unsigned int id ) const
120 {
121   return GetImplementation(*this).GetAuxiliaryHintValue( id );
122 }
123 unsigned int GlWindow::GetAuxiliaryHintId( const std::string& hint ) const
124 {
125   return GetImplementation(*this).GetAuxiliaryHintId( hint );
126 }
127 void GlWindow::SetInputRegion( const Rect< int >& inputRegion )
128 {
129   GetImplementation(*this).SetInputRegion( inputRegion );
130 }
131 void GlWindow::SetOpaqueState( bool opaque )
132 {
133   GetImplementation(*this).SetOpaqueState( opaque );
134 }
135 bool GlWindow::IsOpaqueState() const
136 {
137   return GetImplementation(*this).IsOpaqueState();
138 }
139 void GlWindow::SetPositionSize( PositionSize positionSize )
140 {
141   GetImplementation(*this).SetPositionSize( positionSize );
142 }
143 PositionSize GlWindow::GetPositionSize() const
144 {
145   return GetImplementation(*this).GetPositionSize();
146 }
147 Dali::GlWindow::GlWindowOrientation GlWindow::GetCurrentOrientation() const
148 {
149   return GetImplementation( *this ).GetCurrentOrientation();
150 }
151 void GlWindow::SetAvailableOrientations( const Dali::Vector< Dali::GlWindow::GlWindowOrientation >& orientations )
152 {
153   GetImplementation( *this ).SetAvailableOrientations( orientations );
154 }
155 void GlWindow::SetPreferredOrientation( Dali::GlWindow::GlWindowOrientation orientation )
156 {
157   GetImplementation(*this).SetPreferredOrientation( orientation );
158 }
159 void GlWindow::RegisterGlCallback( GlInitialize glInit, GlRenderFrame glRenderFrame, GlTerminate glTerminate )
160 {
161   GetImplementation(*this).RegisterGlCallback( glInit, glRenderFrame, glTerminate );
162 }
163 void GlWindow::RenderOnce()
164 {
165   GetImplementation(*this).RenderOnce();
166 }
167 GlWindow::FocusChangeSignalType& GlWindow::FocusChangeSignal()
168 {
169   return GetImplementation(*this).FocusChangeSignal();
170 }
171 GlWindow::ResizedSignalType& GlWindow::ResizedSignal()
172 {
173   return GetImplementation(*this).ResizedSignal();
174 }
175 GlWindow::KeyEventSignalType& GlWindow::KeyEventSignal()
176 {
177   return GetImplementation(*this).KeyEventSignal();
178 }
179 GlWindow::TouchSignalType& GlWindow::TouchSignal()
180 {
181   return GetImplementation(*this).TouchSignal();
182 }
183 GlWindow::VisibilityChangedSignalType& GlWindow::VisibilityChangedSignal()
184 {
185   return GetImplementation(*this).VisibilityChangedSignal();
186 }
187 GlWindow::GlWindow( Internal::Adaptor::GlWindow* window )
188 : BaseHandle( window )
189 {
190 }
191
192 }// Dali