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