Flutter Engine
The 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
10
11namespace vulkan {
12
14 ANativeWindow* native_window)
15 : native_window_(native_window) {
16 if (native_window_ == nullptr) {
17 return;
18 }
19 ANativeWindow_acquire(native_window_);
20}
21
23 if (native_window_ == nullptr) {
24 return;
25 }
26 ANativeWindow_release(native_window_);
27}
28
32
36
40 if (!vk.IsValid() || !instance) {
41 return VK_NULL_HANDLE;
42 }
43
44 const VkAndroidSurfaceCreateInfoKHR create_info = {
46 .pNext = nullptr,
47 .flags = 0,
48 .window = native_window_,
49 };
50
51 VkSurfaceKHR surface = VK_NULL_HANDLE;
52
53 if (VK_CALL_LOG_ERROR(vk.CreateAndroidSurfaceKHR(
54 instance, &create_info, nullptr, &surface)) != VK_SUCCESS) {
55 return VK_NULL_HANDLE;
56 }
57
58 return surface;
59}
60
62 return native_window_ != nullptr;
63}
64
66 return native_window_ == nullptr
67 ? SkISize::Make(0, 0)
68 : SkISize::Make(ANativeWindow_getWidth(native_window_),
69 ANativeWindow_getHeight(native_window_));
70}
71
72} // namespace vulkan
@ kKHR_android_surface_GrVkExtensionFlag
VulkanNativeSurfaceAndroid(ANativeWindow *native_window)
VkSurfaceKHR CreateSurfaceHandle(VulkanProcTable &vk, const VulkanHandle< VkInstance > &instance) const override
VkInstance instance
Definition main.cc:48
VkSurfaceKHR surface
Definition main.cc:49
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
@ VK_SUCCESS
#define VK_NULL_HANDLE
Definition vulkan_core.h:46
@ VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR
#define VK_CALL_LOG_ERROR(expression)
struct ANativeWindow ANativeWindow