dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 1 | // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef GPU_VULKAN_VULKAN_SURFACE_H_ | ||||
6 | #define GPU_VULKAN_VULKAN_SURFACE_H_ | ||||
7 | |||||
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 8 | #include <vulkan/vulkan.h> |
mostynb | 6682b1c4 | 2016-04-19 10:17:30 | [diff] [blame] | 9 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 10 | #include "gpu/vulkan/vulkan_device_queue.h" |
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 11 | #include "gpu/vulkan/vulkan_export.h" |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 12 | #include "gpu/vulkan/vulkan_swap_chain.h" |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 13 | #include "ui/gfx/geometry/size.h" |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 14 | #include "ui/gfx/swap_result.h" |
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 15 | |
16 | namespace gpu { | ||||
17 | |||||
dyen | 8a145fb7 | 2016-03-31 00:37:51 | [diff] [blame] | 18 | class VulkanDeviceQueue; |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 19 | class VulkanSwapChain; |
20 | |||||
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 21 | class VULKAN_EXPORT VulkanSurface { |
22 | public: | ||||
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 23 | // Minimum bit depth of surface. |
24 | enum Format { | ||||
sohan.jyoti | 02f1686 | 2016-05-13 01:18:32 | [diff] [blame] | 25 | FORMAT_RGBA_32, |
26 | FORMAT_RGB_16, | ||||
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 27 | |
28 | NUM_SURFACE_FORMATS, | ||||
sohan.jyoti | 02f1686 | 2016-05-13 01:18:32 | [diff] [blame] | 29 | DEFAULT_SURFACE_FORMAT = FORMAT_RGBA_32 |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 30 | }; |
31 | |||||
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 32 | VulkanSurface(VkInstance vk_instance, VkSurfaceKHR surface); |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 33 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 34 | ~VulkanSurface(); |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 35 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 36 | bool Initialize(VulkanDeviceQueue* device_queue, |
37 | VulkanSurface::Format format); | ||||
38 | void Destroy(); | ||||
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 39 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 40 | gfx::SwapResult SwapBuffers(); |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 41 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 42 | VulkanSwapChain* GetSwapChain(); |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 43 | |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 44 | void Finish(); |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 45 | |
Peng Huang | 6a416d16 | 2018-08-28 20:16:30 | [diff] [blame] | 46 | bool SetSize(const gfx::Size& size); |
47 | const gfx::Size& size() const { return size_; } | ||||
Michael Spang | a016d40 | 2018-09-18 22:20:54 | [diff] [blame] | 48 | VkSurfaceFormatKHR surface_format() const { return surface_format_; } |
Peng Huang | 6a416d16 | 2018-08-28 20:16:30 | [diff] [blame] | 49 | |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 50 | private: |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 51 | const VkInstance vk_instance_; |
52 | gfx::Size size_; | ||||
53 | VkSurfaceKHR surface_ = VK_NULL_HANDLE; | ||||
54 | VkSurfaceFormatKHR surface_format_ = {}; | ||||
55 | VulkanDeviceQueue* device_queue_ = nullptr; | ||||
Peng Huang | 6a416d16 | 2018-08-28 20:16:30 | [diff] [blame] | 56 | std::unique_ptr<VulkanSwapChain> swap_chain_; |
Michael Spang | 7509e6d | 2018-05-16 17:08:28 | [diff] [blame] | 57 | |
dyen | 4ec04ecc | 2016-03-30 22:45:46 | [diff] [blame] | 58 | DISALLOW_COPY_AND_ASSIGN(VulkanSurface); |
dyen | 2ce3e05 | 2016-03-09 21:03:49 | [diff] [blame] | 59 | }; |
60 | |||||
61 | } // namespace gpu | ||||
62 | |||||
63 | #endif // GPU_VULKAN_VULKAN_SURFACE_H_ |