Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / 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/display-connection-impl-ecore-wl.h>
20
21 // EXTERNAL_HEADERS
22 #include <Ecore_Wayland.h>
23 #include <dali/integration-api/debug.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 namespace Adaptor
32 {
33
34 DisplayConnection* DisplayConnectionEcoreWl::New()
35 {
36   DisplayConnection* pDisplayConnection(new DisplayConnectionEcoreWl());
37
38   return pDisplayConnection;
39 }
40
41 DisplayConnectionEcoreWl::DisplayConnectionEcoreWl()
42 : mDisplay( NULL ),
43   mSurfaceType( RenderSurface::WINDOW_RENDER_SURFACE )
44 {
45 }
46
47 DisplayConnectionEcoreWl::~DisplayConnectionEcoreWl()
48 {
49   if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
50   {
51     ReleaseNativeDisplay();
52   }
53 }
54
55 Any DisplayConnectionEcoreWl::GetDisplay()
56 {
57   return Any( mDisplay );
58 }
59
60 void DisplayConnectionEcoreWl::ConsumeEvents()
61 {
62 }
63
64 bool DisplayConnectionEcoreWl::InitializeEgl(EglInterface& egl)
65 {
66   EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);
67
68   if( !eglImpl.InitializeGles( mDisplay ) )
69   {
70     DALI_LOG_ERROR("Failed to initialize GLES.\n");
71     return false;
72   }
73
74   return true;
75 }
76
77 void DisplayConnectionEcoreWl::SetSurfaceType( RenderSurface::Type type )
78 {
79   mSurfaceType = type;
80
81   if( mSurfaceType == RenderSurface::NATIVE_RENDER_SURFACE )
82   {
83     mDisplay = GetNativeDisplay();
84   }
85   else
86   {
87     mDisplay = reinterpret_cast< EGLNativeDisplayType >( ecore_wl_display_get() );
88   }
89 }
90
91 EGLNativeDisplayType DisplayConnectionEcoreWl::GetNativeDisplay()
92 {
93   return EGLNativeDisplayType();
94 }
95
96 void DisplayConnectionEcoreWl::ReleaseNativeDisplay()
97 {
98
99 }
100
101 } // namespace Adaptor
102
103 } // namespace Internal
104
105 } // namespace Dali