[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / windows / display-connection-impl-win.cpp
1 /*\r
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  *\r
16  */\r
17 \r
18 // CLASS HEADER\r
19 #include <dali/internal/window-system/windows/display-connection-impl-win.h>\r
20 \r
21 // EXTERNAL_HEADERS\r
22 #include <dali/integration-api/debug.h>\r
23 \r
24 // INTERNAL HEADERS\r
25 #include <dali/internal/window-system/windows/pixmap-render-surface-win.h>\r
26 \r
27 namespace Dali\r
28 {\r
29 \r
30 namespace Internal\r
31 {\r
32 \r
33 namespace Adaptor\r
34 {\r
35 \r
36 DisplayConnection* DisplayConnectionWin::New()\r
37 {\r
38   DisplayConnection* pDisplayConnection(new DisplayConnectionWin());\r
39 \r
40   return pDisplayConnection;\r
41 }\r
42 \r
43 DisplayConnectionWin::DisplayConnectionWin()\r
44 : mDisplay(NULL)\r
45 {\r
46 }\r
47 \r
48 DisplayConnectionWin::~DisplayConnectionWin()\r
49 {\r
50   if(mDisplay)\r
51   {\r
52     //XCloseDisplay(mDisplay);\r
53   }\r
54 }\r
55 \r
56 Any DisplayConnectionWin::GetDisplay()\r
57 {\r
58   return Any(mDisplay);\r
59 }\r
60 \r
61 void DisplayConnectionWin::ConsumeEvents()\r
62 {\r
63   // check events so that we can flush the queue and avoid any potential memory leaks in X\r
64   // looping if events remain\r
65   int events(0);\r
66   do\r
67   {\r
68     // Check if there are any events in the queue\r
69     //events = XEventsQueued(mDisplay, QueuedAfterFlush);\r
70 \r
71     //if (events > 0)\r
72     //{\r
73     //  // Just flush event to prevent memory leak from event queue as the events get built up in\r
74     //  // memory but are only deleted when we retrieve them\r
75     //  XEvent ev;\r
76     //  XNextEvent(mDisplay, &ev);\r
77     //}\r
78   }\r
79   while (events > 0);\r
80 }\r
81 \r
82 bool DisplayConnectionWin::InitializeEgl(EglInterface& egl)\r
83 {\r
84   EglImplementation& eglImpl = static_cast<EglImplementation&>( egl );\r
85 \r
86   if( !eglImpl.InitializeGles( reinterpret_cast<EGLNativeDisplayType>( mDisplay ) ) )\r
87   {\r
88     DALI_LOG_ERROR( "Failed to initialize GLES.\n" );\r
89     return false;\r
90   }\r
91 \r
92   return true;\r
93 }\r
94 \r
95 void DisplayConnectionWin::SetSurfaceType( RenderSurface::Type type )\r
96 {\r
97   if( type == RenderSurface::WINDOW_RENDER_SURFACE )\r
98   {\r
99      mDisplay = GetDC( GetForegroundWindow() );\r
100   }\r
101 }\r
102 \r
103 } // namespace Adaptor\r
104 \r
105 } // namespace Internal\r
106 \r
107 } // namespace Dali\r