2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/display-connection-impl-ecore-wl2.h>
22 #include <Ecore_Wl2.h>
23 #include <dali/integration-api/debug.h>
26 #include <dali/integration-api/wayland/native-render-surface.h>
37 DisplayConnection* DisplayConnectionEcoreWl2::New()
39 DisplayConnection* pDisplayConnection(new DisplayConnectionEcoreWl2());
41 return pDisplayConnection;
44 DisplayConnectionEcoreWl2::DisplayConnectionEcoreWl2()
46 mSurfaceType( RenderSurface::ECORE_RENDER_SURFACE )
50 DisplayConnectionEcoreWl2::~DisplayConnectionEcoreWl2()
52 if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
54 ReleaseNativeDisplay();
58 Any DisplayConnectionEcoreWl2::GetDisplay()
60 return Any( mDisplay );
63 void DisplayConnectionEcoreWl2::ConsumeEvents()
67 bool DisplayConnectionEcoreWl2::InitializeEgl(EglInterface& egl)
69 EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
71 if( !eglImpl.InitializeGles( mDisplay ) )
73 DALI_LOG_ERROR("Failed to initialize GLES.\n");
80 void DisplayConnectionEcoreWl2::SetSurfaceType( RenderSurface::Type type )
84 if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
86 mDisplay = GetNativeDisplay();
90 Ecore_Wl2_Display* ecore_wl2_display = ecore_wl2_connected_display_get(NULL);
91 mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl2_display_get(ecore_wl2_display) );
95 void DisplayConnectionEcoreWl2::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
100 // 1 inch = 25.4 millimeters
102 Ecore_Wl2_Window *ecore_wl2_window_find(unsigned int id);
103 Ecore_Wl2_Window *ecore_wl2_window_surface_find(struct wl_surface *surface);
105 Ecore_Wl2_Output *ecore_wl2_window_output_find(Ecore_Wl2_Window *window);
106 ecore_wl2_window_output_find(wdata->win);
107 xres = ecore_wl2_output_dpi_get();
108 yres = ecore_wl2_output_dpi_get();
112 dpiHorizontal = int(xres + 0.5f); // rounding
113 dpiVertical = int(yres + 0.5f);
116 void DisplayConnectionEcoreWl2::GetDpi(Any nativeWindow, unsigned int& dpiHorizontal, unsigned int& dpiVertical)
121 Ecore_Wl2_Output *wl2_output = ecore_wl2_window_output_find(AnyCast<Ecore_Wl2_Window*>( nativeWindow ));
125 DALI_LOG_ERROR("Failed to get Ecore_Wl2_Output.\n");
128 xres = ecore_wl2_output_dpi_get(wl2_output);
129 yres = ecore_wl2_output_dpi_get(wl2_output);
131 dpiHorizontal = int(xres + 0.5f); // rounding
132 dpiVertical = int(yres + 0.5f);
135 EGLNativeDisplayType DisplayConnectionEcoreWl2::GetNativeDisplay()
137 return EGLNativeDisplayType();
140 void DisplayConnectionEcoreWl2::ReleaseNativeDisplay()
145 } // namespace Adaptor
147 } // namespace Internal