195eda28412ea2fcbc099a80029af731fd970e07
[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 #include <dali/internal/graphics/gles/egl-graphics.h>
21
22 // EXTERNAL_HEADERS
23 #include <dali/integration-api/debug.h>
24
25 #ifdef ECORE_WAYLAND2
26 #include <Ecore_Wl2.h>
27 #else
28 #include <Ecore_Wayland.h>
29 #endif
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace Adaptor
38 {
39
40 DisplayConnection* DisplayConnectionEcoreWl::New()
41 {
42   DisplayConnection* pDisplayConnection(new DisplayConnectionEcoreWl());
43
44   return pDisplayConnection;
45 }
46
47 DisplayConnectionEcoreWl::DisplayConnectionEcoreWl()
48 : mDisplay( NULL ),
49   mSurfaceType( RenderSurface::WINDOW_RENDER_SURFACE ),
50   mGraphics( nullptr )
51 {
52 }
53
54 DisplayConnectionEcoreWl::~DisplayConnectionEcoreWl()
55 {
56   if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
57   {
58     ReleaseNativeDisplay();
59   }
60 }
61
62 Any DisplayConnectionEcoreWl::GetDisplay()
63 {
64   return Any( mDisplay );
65 }
66
67 void DisplayConnectionEcoreWl::ConsumeEvents()
68 {
69 }
70
71 bool DisplayConnectionEcoreWl::InitializeGraphics()
72 {
73   auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
74   EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
75
76   if( !eglImpl.InitializeGles( mDisplay ) )
77   {
78     DALI_LOG_ERROR("Failed to initialize GLES.\n");
79     return false;
80   }
81
82   return true;
83 }
84
85 void DisplayConnectionEcoreWl::SetSurfaceType( RenderSurface::Type type )
86 {
87   mSurfaceType = type;
88
89   if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
90   {
91     mDisplay = GetNativeDisplay();
92   }
93   else
94   {
95 #ifdef ECORE_WAYLAND2
96     Ecore_Wl2_Display* display = ecore_wl2_connected_display_get( NULL );
97     mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl2_display_get( display ) );
98 #else
99     mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl_display_get() );
100 #endif
101   }
102 }
103
104 void DisplayConnectionEcoreWl::SetGraphicsInterface( GraphicsInterface& graphics )
105 {
106   mGraphics = &graphics;
107 }
108
109 EGLNativeDisplayType DisplayConnectionEcoreWl::GetNativeDisplay()
110 {
111   return EGLNativeDisplayType();
112 }
113
114 void DisplayConnectionEcoreWl::ReleaseNativeDisplay()
115 {
116
117 }
118
119 } // namespace Adaptor
120
121 } // namespace Internal
122
123 } // namespace Dali