Graphics and Vulkan integration within Adaptor
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / vulkan / x11 / vk-surface-xlib2xcb.h
1 #ifndef DALI_GRAPHICS_VULKAN_VKSURFACEXLIB2XCB_H
2 #define DALI_GRAPHICS_VULKAN_VKSURFACEXLIB2XCB_H
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 #ifndef VK_USE_PLATFORM_XLIB_KHR
22 #define VK_USE_PLATFORM_XLIB_KHR
23 #endif
24 #ifndef VK_USE_PLATFORM_XCB_KHR
25 #define VK_USE_PLATFORM_XCB_KHR
26 #endif
27
28 // INTERNAL INCLUDES
29 #include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
30
31 // EXTERNAL INCLUDES
32 #include <vulkan/vulkan.hpp>
33
34 namespace Dali
35 {
36 class RenderSurface;
37
38 namespace Graphics
39 {
40 namespace Vulkan
41 {
42 /**
43  * This surface exists only because of ( probably ) Nvidia driver bug.
44  * Presenting swapchain that uses Xlib surface crashes. Class VkSurfaceXlib2Xcb
45  * takes Xlib window arguments but creates Xcb surface. It's a workaround.
46  */
47 class VkSurfaceXlib2Xcb final : public Dali::Integration::Graphics::Vulkan::VkSurfaceFactory
48 {
49 public:
50   VkSurfaceXlib2Xcb(Dali::RenderSurface& renderSurface);
51
52   VkSurfaceXlib2Xcb(Display* display, Window window);
53
54   virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
55                                 vk::PhysicalDevice physicalDevice) const override;
56
57 private:
58   xcb_connection_t* mConnection;
59   xcb_window_t      mWindow;
60   vk::SurfaceKHR    mSurface;
61 };
62
63 } // Namespace Vulkan
64 } // Namespace Graphics
65 } // Namespace Dali
66
67 #endif // DALI_GRAPHICS_VULKAN_VKSURFACEXLIB2XCB_H