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