Merge remote-tracking branch 'origin/tizen' into devel/new_mesh
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / display-connection-impl-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 "display-connection-impl.h"
20
21 // EXTERNAL_HEADERS
22 #include <Ecore_Wayland.h>
23 #include <dali/integration-api/debug.h>
24
25 // INTERNAL HEADERS
26 #include <pixmap-render-surface.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 namespace Adaptor
35 {
36
37 DisplayConnection* DisplayConnection::New()
38 {
39   DisplayConnection* pDisplayConnection(new DisplayConnection());
40
41   return pDisplayConnection;
42 }
43
44 DisplayConnection::DisplayConnection()
45 : mDisplay(NULL)
46 {
47   //FIXME
48 }
49
50 DisplayConnection::~DisplayConnection()
51 {
52   //FIXME
53 }
54
55 Any DisplayConnection::GetDisplay()
56 {
57   return Any(mDisplay);
58 }
59
60 void DisplayConnection::ConsumeEvents()
61 {
62 }
63
64 bool DisplayConnection::InitializeEgl(EglInterface& egl)
65 {
66   EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
67
68   if (!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))
69   {
70     DALI_LOG_ERROR("Failed to initialize GLES.");
71     return false;
72   }
73
74   return true;
75 }
76
77 void DisplayConnection::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
78 {
79   // calculate DPI
80   float xres, yres;
81
82   // 1 inch = 25.4 millimeters
83   xres = ecore_wl_dpi_get();
84   yres = ecore_wl_dpi_get();
85
86   dpiHorizontal = int(xres + 0.5f);  // rounding
87   dpiVertical   = int(yres + 0.5f);
88 }
89
90 } // namespace Adaptor
91
92 } // namespace Internal
93
94 } // namespace Dali