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()
48 DisplayConnection::~DisplayConnection()
50 if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
52 ReleaseNativeDisplay();
56 Any DisplayConnection::GetDisplay()
58 return Any( mDisplay );
61 void DisplayConnection::ConsumeEvents()
65 bool DisplayConnection::InitializeEgl(EglInterface& egl)
67 EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
69 if( !eglImpl.InitializeGles( mDisplay ) )
71 DALI_LOG_ERROR("Failed to initialize GLES.\n");
78 void DisplayConnection::SetSurfaceType( RenderSurface::Type type )
82 if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
84 mDisplay = GetNativeDisplay();
88 mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl_display_get() );
92 void DisplayConnection::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
97 // 1 inch = 25.4 millimeters
98 xres = ecore_wl_dpi_get();
99 yres = ecore_wl_dpi_get();
101 dpiHorizontal = int(xres + 0.5f); // rounding
102 dpiVertical = int(yres + 0.5f);
105 } // namespace Adaptor
107 } // namespace Internal