8f85b945a5b14eed37e09193cac678b27f0769c0
[platform/core/uifw/vulkan-wsi-tizen.git] / wsi / wsi_factory.hpp
1
2 /*
3  * Copyright (c) 2019 Arm Limited.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to
9  * deal in the Software without restriction, including without limitation the
10  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11  * sell copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24  */
25
26 /**
27  * @file
28  * @brief Contains the factory methods for obtaining the specific surface and swapchain implementations.
29  */
30 #pragma once
31
32 #include "swapchain_base.hpp"
33 #include "surface_properties.hpp"
34 #include <layer/private_data.hpp>
35
36 namespace wsi
37 {
38
39 /**
40  * Obtains the surface properties for the specific surface type.
41  *
42  * @param surface The surface for which to get the properties.
43  *
44  * @return nullptr if surface type is unsupported.
45  */
46 surface_properties *get_surface_properties(VkSurfaceKHR surface);
47
48 /**
49  * Allocates a surface specific swapchain.
50  *
51  * @param surface    The surface for which a swapchain is allocated.
52  * @param dev_data   The device specific data.
53  * @param pAllocator The allocator from which to allocate any memory.
54  *
55  * @return nullptr on failure.
56  */
57 swapchain_base *allocate_surface_swapchain(VkSurfaceKHR surface, layer::device_private_data &dev_data,
58                                            const VkAllocationCallbacks *pAllocator);
59
60 /**
61  * Destroys a swapchain and frees memory. Used with @ref allocate_surface_swapchain.
62  *
63  * @param swapchain  Pointer to the swapchain to destroy.
64  * @param pAllocator The allocator to use for freeing memory.
65  */
66 void destroy_surface_swapchain(swapchain_base *swapchain, const VkAllocationCallbacks *pAllocator);
67
68 } // namespace wsi