OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2016 Google Inc. | 3 * Copyright 2016 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "WindowContextFactory_android.h" | 9 #include "WindowContextFactory_android.h" |
10 #include "../VulkanWindowContext.h" | 10 #include "../VulkanWindowContext.h" |
11 | 11 |
12 namespace sk_app { | 12 namespace sk_app { |
13 | 13 |
14 namespace window_context_factory { | 14 namespace window_context_factory { |
15 | 15 |
16 WindowContext* NewVulkanForAndroid(ANativeWindow* window, const DisplayParams& p
arams) { | 16 WindowContext* NewVulkanForAndroid(ANativeWindow* window, const DisplayParams& p
arams) { |
17 auto createVkSurface = [window] (VkInstance instance) -> VkSurfaceKHR { | 17 auto createVkSurface = [window] (VkInstance instance) -> VkSurfaceKHR { |
18 static PFN_vkCreateAndroidSurfaceKHR createAndroidSurfaceKHR = nullptr; | 18 PFN_vkCreateAndroidSurfaceKHR createAndroidSurfaceKHR = |
19 if (!createAndroidSurfaceKHR) { | 19 (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr(instance, |
20 createAndroidSurfaceKHR = (PFN_vkCreateAndroidSurfaceKHR)vkGetInstan
ceProcAddr( | 20 "vkCreateAn
droidSurfaceKHR"); |
21 instance, "vkCreateAndroidSurfaceKHR"); | |
22 } | |
23 | 21 |
24 if (!window) { | 22 if (!window) { |
25 return VK_NULL_HANDLE; | 23 return VK_NULL_HANDLE; |
26 } | 24 } |
27 VkSurfaceKHR surface; | 25 VkSurfaceKHR surface; |
28 | 26 |
29 VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo; | 27 VkAndroidSurfaceCreateInfoKHR surfaceCreateInfo; |
30 memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR)); | 28 memset(&surfaceCreateInfo, 0, sizeof(VkAndroidSurfaceCreateInfoKHR)); |
31 surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_
KHR; | 29 surfaceCreateInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_
KHR; |
32 surfaceCreateInfo.pNext = nullptr; | 30 surfaceCreateInfo.pNext = nullptr; |
(...skipping 10 matching lines...) Expand all Loading... |
43 WindowContext* ctx = new VulkanWindowContext(params, createVkSurface, canPre
sent); | 41 WindowContext* ctx = new VulkanWindowContext(params, createVkSurface, canPre
sent); |
44 if (!ctx->isValid()) { | 42 if (!ctx->isValid()) { |
45 delete ctx; | 43 delete ctx; |
46 return nullptr; | 44 return nullptr; |
47 } | 45 } |
48 return ctx; | 46 return ctx; |
49 } | 47 } |
50 | 48 |
51 } // namespace window_context_factory | 49 } // namespace window_context_factory |
52 } // namespace sk_app | 50 } // namespace sk_app |
OLD | NEW |