Graphics and Vulkan integration within Adaptor
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / vulkan / x11 / vk-surface-xlib.cpp
1 /*
2  * Copyright (c) 2017 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 #include <adaptors/devel-api/adaptor-framework/render-surface.h>
19 #include <dali/internal/graphics/vulkan/x11/vk-surface-xlib.h>
20 #include <dali/internal/window-system/common/window-render-surface.h>
21
22 namespace Dali
23 {
24 namespace Graphics
25 {
26 namespace Vulkan
27 {
28
29 VkSurfaceXlib::VkSurfaceXlib(Dali::RenderSurface& renderSurface)
30 : VkSurfaceFactory()
31 {
32   auto ecoreSurface = dynamic_cast<Dali::ECore::WindowRenderSurface*>(&renderSurface);
33   assert( ecoreSurface != nullptr && "This is not ecore surface!");
34   mWindow = ecoreSurface->GetXWindow();
35   mDisplay = XOpenDisplay(nullptr);
36 }
37
38 VkSurfaceXlib::VkSurfaceXlib(Display* display, Window window)
39 : VkSurfaceFactory(), mDisplay(display), mWindow(window)
40 {
41 }
42
43 vk::SurfaceKHR VkSurfaceXlib::Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
44                                      vk::PhysicalDevice physicalDevice) const
45 {
46   vk::XlibSurfaceCreateInfoKHR info;
47   info.setDpy(mDisplay).setWindow(mWindow);
48   auto retval = instance.createXlibSurfaceKHR(info, allocCallbacks).value;
49   return retval;
50 }
51 }
52 }
53 }