OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/vulkan/vulkan_surface.h" | 5 #include "gpu/vulkan/vulkan_surface.h" |
6 | 6 |
7 #include <vulkan/vulkan.h> | 7 #include <vulkan/vulkan.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "gpu/vulkan/vulkan_command_buffer.h" | 10 #include "gpu/vulkan/vulkan_command_buffer.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 VkXlibSurfaceCreateInfoKHR surface_create_info = {}; | 47 VkXlibSurfaceCreateInfoKHR surface_create_info = {}; |
48 surface_create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; | 48 surface_create_info.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; |
49 surface_create_info.dpy = gfx::GetXDisplay(); | 49 surface_create_info.dpy = gfx::GetXDisplay(); |
50 surface_create_info.window = window_; | 50 surface_create_info.window = window_; |
51 result = vkCreateXlibSurfaceKHR(GetVulkanInstance(), &surface_create_info, | 51 result = vkCreateXlibSurfaceKHR(GetVulkanInstance(), &surface_create_info, |
52 nullptr, &surface_); | 52 nullptr, &surface_); |
53 if (VK_SUCCESS != result) { | 53 if (VK_SUCCESS != result) { |
54 DLOG(ERROR) << "vkCreateXlibSurfaceKHR() failed: " << result; | 54 DLOG(ERROR) << "vkCreateXlibSurfaceKHR() failed: " << result; |
55 return false; | 55 return false; |
56 } | 56 } |
| 57 #elif defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 58 VkAndroidSurfaceCreateInfoKHR surface_create_info = {}; |
| 59 surface_create_info.sType = |
| 60 VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR; |
| 61 surface_create_info.window = window_; |
| 62 result = vkCreateAndroidSurfaceKHR( |
| 63 GetVulkanInstance(), &surface_create_info, nullptr, &surface_); |
| 64 if (VK_SUCCESS != result) { |
| 65 DLOG(ERROR) << "vkCreateAndroidSurfaceKHR() failed: " << result; |
| 66 return false; |
| 67 } |
57 #else | 68 #else |
58 #error Unsupported Vulkan Platform. | 69 #error Unsupported Vulkan Platform. |
59 #endif | 70 #endif |
60 | 71 |
61 DCHECK_NE(static_cast<VkSurfaceKHR>(VK_NULL_HANDLE), surface_); | 72 DCHECK_NE(static_cast<VkSurfaceKHR>(VK_NULL_HANDLE), surface_); |
62 DCHECK(device_queue); | 73 DCHECK(device_queue); |
63 device_queue_ = device_queue; | 74 device_queue_ = device_queue; |
64 | 75 |
65 // Get list of supported formats. | 76 // Get list of supported formats. |
66 uint32_t format_count = 0; | 77 uint32_t format_count = 0; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 162 |
152 // static | 163 // static |
153 std::unique_ptr<VulkanSurface> VulkanSurface::CreateViewSurface( | 164 std::unique_ptr<VulkanSurface> VulkanSurface::CreateViewSurface( |
154 gfx::AcceleratedWidget window) { | 165 gfx::AcceleratedWidget window) { |
155 return std::unique_ptr<VulkanSurface>(new VulkanWSISurface(window)); | 166 return std::unique_ptr<VulkanSurface>(new VulkanWSISurface(window)); |
156 } | 167 } |
157 | 168 |
158 VulkanSurface::VulkanSurface() {} | 169 VulkanSurface::VulkanSurface() {} |
159 | 170 |
160 } // namespace gpu | 171 } // namespace gpu |
OLD | NEW |