[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / windows / display-connection-impl-win.cpp
1 /*\r
2  * Copyright (c) 2021 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 INCLUDES\r
22 #include <dali/integration-api/debug.h>\r
23 \r
24 // INTERNAL INCLUDES\r
25 #include <dali/internal/graphics/gles/egl-graphics.h>\r
26 \r
27 namespace Dali\r
28 {\r
29 namespace Internal\r
30 {\r
31 namespace Adaptor\r
32 {\r
33 DisplayConnection* DisplayConnectionWin::New()\r
34 {\r
35   DisplayConnection* pDisplayConnection(new DisplayConnectionWin());\r
36 \r
37   return pDisplayConnection;\r
38 }\r
39 \r
40 DisplayConnectionWin::DisplayConnectionWin()\r
41 : mDisplay(NULL)\r
42 {\r
43 }\r
44 \r
45 DisplayConnectionWin::~DisplayConnectionWin()\r
46 {\r
47 }\r
48 \r
49 Any DisplayConnectionWin::GetDisplay()\r
50 {\r
51   return Any(mDisplay);\r
52 }\r
53 \r
54 void DisplayConnectionWin::ConsumeEvents()\r
55 {\r
56 }\r
57 \r
58 bool DisplayConnectionWin::InitializeEgl(EglInterface& egl)\r
59 {\r
60   EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);\r
61 \r
62   if(!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))\r
63   {\r
64     DALI_LOG_ERROR("Failed to initialize GLES.\n");\r
65     return false;\r
66   }\r
67 \r
68   return true;\r
69 }\r
70 \r
71 bool DisplayConnectionWin::InitializeGraphics()\r
72 {\r
73   auto               eglGraphics = static_cast<EglGraphics*>(mGraphics);\r
74   EglImplementation& eglImpl     = eglGraphics->GetEglImplementation();\r
75 \r
76   if(!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))\r
77   {\r
78     DALI_LOG_ERROR("Failed to initialize GLES.\n");\r
79     return false;\r
80   }\r
81 \r
82   return true;\r
83 }\r
84 \r
85 void DisplayConnectionWin::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)\r
86 {\r
87   if(type == Dali::RenderSurfaceInterface::WINDOW_RENDER_SURFACE)\r
88   {\r
89     mDisplay = GetDC(GetForegroundWindow());\r
90   }\r
91 }\r
92 \r
93 void DisplayConnectionWin::SetGraphicsInterface(GraphicsInterface& graphics)\r
94 {\r
95   mGraphics = &graphics;\r
96 }\r
97 \r
98 } // namespace Adaptor\r
99 \r
100 } // namespace Internal\r
101 \r
102 } // namespace Dali\r