Flutter Engine
 
Loading...
Searching...
No Matches
vulkan_native_surface_android.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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
6
8
9namespace vulkan {
10
12 ANativeWindow* native_window)
13 : native_window_(native_window) {
14 if (native_window_ == nullptr) {
15 return;
16 }
17 ANativeWindow_acquire(native_window_);
18}
19
21 if (native_window_ == nullptr) {
22 return;
23 }
24 ANativeWindow_release(native_window_);
25}
26
28 // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_android_surface.html
29 return VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
30}
31
35 if (!vk.IsValid() || !instance) {
36 return VK_NULL_HANDLE;
37 }
38
39 const VkAndroidSurfaceCreateInfoKHR create_info = {
40 .sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR,
41 .pNext = nullptr,
42 .flags = 0,
43 .window = native_window_,
44 };
45
46 VkSurfaceKHR surface = VK_NULL_HANDLE;
47
48 if (VK_CALL_LOG_ERROR(vk.CreateAndroidSurfaceKHR(
49 instance, &create_info, nullptr, &surface)) != VK_SUCCESS) {
50 return VK_NULL_HANDLE;
51 }
52
53 return surface;
54}
55
57 return native_window_ != nullptr;
58}
59
61 return native_window_ == nullptr
62 ? SkISize::Make(0, 0)
63 : SkISize::Make(ANativeWindow_getWidth(native_window_),
64 ANativeWindow_getHeight(native_window_));
65}
66
67} // namespace vulkan
VulkanNativeSurfaceAndroid(ANativeWindow *native_window)
VkSurfaceKHR CreateSurfaceHandle(VulkanProcTable &vk, const VulkanHandle< VkInstance > &instance) const override
VkInstance instance
Definition main.cc:64
VkSurfaceKHR surface
Definition main.cc:65
#define VK_CALL_LOG_ERROR(expression)
struct ANativeWindow ANativeWindow