blob: 8329fcd7ef4e2380e574b9ed8abadb957ad807dd [file] [log] [blame]
dyen2ce3e052016-03-09 21:03:491// 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 Spang7509e6d2018-05-16 17:08:288#include <vulkan/vulkan.h>
mostynb6682b1c42016-04-19 10:17:309
Michael Spang7509e6d2018-05-16 17:08:2810#include "gpu/vulkan/vulkan_device_queue.h"
dyen2ce3e052016-03-09 21:03:4911#include "gpu/vulkan/vulkan_export.h"
Michael Spang7509e6d2018-05-16 17:08:2812#include "gpu/vulkan/vulkan_swap_chain.h"
dyen4ec04ecc2016-03-30 22:45:4613#include "ui/gfx/geometry/size.h"
dyen4ec04ecc2016-03-30 22:45:4614#include "ui/gfx/swap_result.h"
dyen2ce3e052016-03-09 21:03:4915
16namespace gpu {
17
dyen8a145fb72016-03-31 00:37:5118class VulkanDeviceQueue;
dyen4ec04ecc2016-03-30 22:45:4619class VulkanSwapChain;
20
dyen2ce3e052016-03-09 21:03:4921class VULKAN_EXPORT VulkanSurface {
22 public:
dyen4ec04ecc2016-03-30 22:45:4623 // Minimum bit depth of surface.
24 enum Format {
sohan.jyoti02f16862016-05-13 01:18:3225 FORMAT_RGBA_32,
26 FORMAT_RGB_16,
dyen4ec04ecc2016-03-30 22:45:4627
28 NUM_SURFACE_FORMATS,
sohan.jyoti02f16862016-05-13 01:18:3229 DEFAULT_SURFACE_FORMAT = FORMAT_RGBA_32
dyen4ec04ecc2016-03-30 22:45:4630 };
31
Michael Spang7509e6d2018-05-16 17:08:2832 VulkanSurface(VkInstance vk_instance, VkSurfaceKHR surface);
dyen4ec04ecc2016-03-30 22:45:4633
Michael Spang7509e6d2018-05-16 17:08:2834 ~VulkanSurface();
dyen4ec04ecc2016-03-30 22:45:4635
Michael Spang7509e6d2018-05-16 17:08:2836 bool Initialize(VulkanDeviceQueue* device_queue,
37 VulkanSurface::Format format);
38 void Destroy();
dyen4ec04ecc2016-03-30 22:45:4639
Michael Spang7509e6d2018-05-16 17:08:2840 gfx::SwapResult SwapBuffers();
dyen4ec04ecc2016-03-30 22:45:4641
Michael Spang7509e6d2018-05-16 17:08:2842 VulkanSwapChain* GetSwapChain();
dyen4ec04ecc2016-03-30 22:45:4643
Michael Spang7509e6d2018-05-16 17:08:2844 void Finish();
dyen4ec04ecc2016-03-30 22:45:4645
Peng Huang6a416d162018-08-28 20:16:3046 bool SetSize(const gfx::Size& size);
47 const gfx::Size& size() const { return size_; }
Michael Spanga016d402018-09-18 22:20:5448 VkSurfaceFormatKHR surface_format() const { return surface_format_; }
Peng Huang6a416d162018-08-28 20:16:3049
dyen4ec04ecc2016-03-30 22:45:4650 private:
Michael Spang7509e6d2018-05-16 17:08:2851 const VkInstance vk_instance_;
52 gfx::Size size_;
53 VkSurfaceKHR surface_ = VK_NULL_HANDLE;
54 VkSurfaceFormatKHR surface_format_ = {};
55 VulkanDeviceQueue* device_queue_ = nullptr;
Peng Huang6a416d162018-08-28 20:16:3056 std::unique_ptr<VulkanSwapChain> swap_chain_;
Michael Spang7509e6d2018-05-16 17:08:2857
dyen4ec04ecc2016-03-30 22:45:4658 DISALLOW_COPY_AND_ASSIGN(VulkanSurface);
dyen2ce3e052016-03-09 21:03:4959};
60
61} // namespace gpu
62
63#endif // GPU_VULKAN_VULKAN_SURFACE_H_