[Tizen] Support Ecore-Wayland2
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / display-connection-impl-ecore-wl.cpp
1 /*
2  * Copyright (c) 2018 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/window-system/tizen-wayland/display-connection-impl-ecore-wl.h>
20
21 // EXTERNAL_HEADERS
22 #include <dali/integration-api/debug.h>
23
24 #ifdef ECORE_WAYLAND2
25 #include <Ecore_Wl2.h>
26 #else
27 #include <Ecore_Wayland.h>
28 #endif
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38
39 DisplayConnection* DisplayConnectionEcoreWl::New()
40 {
41   DisplayConnection* pDisplayConnection(new DisplayConnectionEcoreWl());
42
43   return pDisplayConnection;
44 }
45
46 DisplayConnectionEcoreWl::DisplayConnectionEcoreWl()
47 : mDisplay( NULL ),
48   mSurfaceType( RenderSurface::WINDOW_RENDER_SURFACE )
49 {
50 }
51
52 DisplayConnectionEcoreWl::~DisplayConnectionEcoreWl()
53 {
54   if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
55   {
56     ReleaseNativeDisplay();
57   }
58 }
59
60 Any DisplayConnectionEcoreWl::GetDisplay()
61 {
62   return Any( mDisplay );
63 }
64
65 void DisplayConnectionEcoreWl::ConsumeEvents()
66 {
67 }
68
69 bool DisplayConnectionEcoreWl::InitializeEgl(EglInterface& egl)
70 {
71   EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
72
73   if( !eglImpl.InitializeGles( mDisplay ) )
74   {
75     DALI_LOG_ERROR("Failed to initialize GLES.\n");
76     return false;
77   }
78
79   return true;
80 }
81
82 void DisplayConnectionEcoreWl::SetSurfaceType( RenderSurface::Type type )
83 {
84   mSurfaceType = type;
85
86   if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
87   {
88     mDisplay = GetNativeDisplay();
89   }
90   else
91   {
92 #ifdef ECORE_WAYLAND2
93     Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
94     mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl2_display_get( display ) );
95 #else
96     mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl_display_get() );
97 #endif
98   }
99 }
100
101 EGLNativeDisplayType DisplayConnectionEcoreWl::GetNativeDisplay()
102 {
103   return EGLNativeDisplayType();
104 }
105
106 void DisplayConnectionEcoreWl::ReleaseNativeDisplay()
107 {
108
109 }
110
111 } // namespace Adaptor
112
113 } // namespace Internal
114
115 } // namespace Dali