Flutter Engine
The Flutter Engine
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
30 // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_android_surface.html
32}
33
37 if (!vk.IsValid() || !instance) {
38 return VK_NULL_HANDLE;
39 }
40
41 const VkAndroidSurfaceCreateInfoKHR create_info = {
43 .pNext = nullptr,
44 .flags = 0,
45 .window = native_window_,
46 };
47
48 VkSurfaceKHR surface = VK_NULL_HANDLE;
49
50 if (VK_CALL_LOG_ERROR(vk.CreateAndroidSurfaceKHR(
51 instance, &create_info, nullptr, &surface)) != VK_SUCCESS) {
52 return VK_NULL_HANDLE;
53 }
54
55 return surface;
56}
57
59 return native_window_ != nullptr;
60}
61
63 return native_window_ == nullptr
64 ? SkISize::Make(0, 0)
65 : SkISize::Make(ANativeWindow_getWidth(native_window_),
66 ANativeWindow_getHeight(native_window_));
67}
68
69} // namespace vulkan
VulkanNativeSurfaceAndroid(ANativeWindow *native_window)
VkSurfaceKHR CreateSurfaceHandle(VulkanProcTable &vk, const VulkanHandle< VkInstance > &instance) const override
const char * GetExtensionName() const override
VkInstance instance
Definition: main.cc:48
VkSurfaceKHR surface
Definition: main.cc:49
vk
Definition: malisc.py:42
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME
@ VK_SUCCESS
Definition: vulkan_core.h:141
#define VK_NULL_HANDLE
Definition: vulkan_core.h:46
@ VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR
Definition: vulkan_core.h:432
#define VK_CALL_LOG_ERROR(expression)
struct ANativeWindow ANativeWindow