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 "display-connection-impl.h"
22 #include <Ecore_Wayland.h>
23 #include <dali/integration-api/debug.h>
26 #include <native-render-surface.h>
37 DisplayConnection* DisplayConnection::New()
39 DisplayConnection* pDisplayConnection(new DisplayConnection());
41 return pDisplayConnection;
44 DisplayConnection::DisplayConnection()
46 mSurfaceType( RenderSurface::ECORE_RENDER_SURFACE )
50 DisplayConnection::~DisplayConnection()
52 if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
54 ReleaseNativeDisplay();
58 Any DisplayConnection::GetDisplay()
60 return Any( mDisplay );
63 void DisplayConnection::ConsumeEvents()
67 bool DisplayConnection::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 DisplayConnection::SetSurfaceType( RenderSurface::Type type )
84 if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
86 mDisplay = GetNativeDisplay();
90 mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl_display_get() );
94 void DisplayConnection::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
99 // 1 inch = 25.4 millimeters
100 xres = ecore_wl_dpi_get();
101 yres = ecore_wl_dpi_get();
103 dpiHorizontal = int(xres + 0.5f); // rounding
104 dpiVertical = int(yres + 0.5f);
107 } // namespace Adaptor
109 } // namespace Internal