Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
vulkan::VulkanNativeSurfaceAndroid Class Reference

#include <vulkan_native_surface_android.h>

Inheritance diagram for vulkan::VulkanNativeSurfaceAndroid:
vulkan::VulkanNativeSurface

Public Member Functions

 VulkanNativeSurfaceAndroid (ANativeWindow *native_window)
 
 ~VulkanNativeSurfaceAndroid ()
 
const char * GetExtensionName () const override
 
VkSurfaceKHR CreateSurfaceHandle (VulkanProcTable &vk, const VulkanHandle< VkInstance > &instance) const override
 
bool IsValid () const override
 
SkISize GetSize () const override
 
- Public Member Functions inherited from vulkan::VulkanNativeSurface
virtual ~VulkanNativeSurface ()=default
 
virtual const char * GetExtensionName () const =0
 
virtual VkSurfaceKHR CreateSurfaceHandle (VulkanProcTable &vk, const VulkanHandle< VkInstance > &instance) const =0
 
virtual bool IsValid () const =0
 
virtual SkISize GetSize () const =0
 

Detailed Description

Definition at line 16 of file vulkan_native_surface_android.h.

Constructor & Destructor Documentation

◆ VulkanNativeSurfaceAndroid()

vulkan::VulkanNativeSurfaceAndroid::VulkanNativeSurfaceAndroid ( ANativeWindow native_window)
explicit

Create a native surface from the valid ANativeWindow reference. Ownership of the ANativeWindow is assumed by this instance.

Definition at line 13 of file vulkan_native_surface_android.cc.

15 : native_window_(native_window) {
16 if (native_window_ == nullptr) {
17 return;
18 }
19 ANativeWindow_acquire(native_window_);
20}

◆ ~VulkanNativeSurfaceAndroid()

vulkan::VulkanNativeSurfaceAndroid::~VulkanNativeSurfaceAndroid ( )

Definition at line 22 of file vulkan_native_surface_android.cc.

22 {
23 if (native_window_ == nullptr) {
24 return;
25 }
26 ANativeWindow_release(native_window_);
27}

Member Function Documentation

◆ CreateSurfaceHandle()

VkSurfaceKHR vulkan::VulkanNativeSurfaceAndroid::CreateSurfaceHandle ( VulkanProcTable vk,
const VulkanHandle< VkInstance > &  instance 
) const
overridevirtual

Implements vulkan::VulkanNativeSurface.

Definition at line 34 of file vulkan_native_surface_android.cc.

36 {
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}
VkInstance instance
Definition: main.cc:48
VkSurfaceKHR surface
Definition: main.cc:49
vk
Definition: malisc.py:42
@ 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)

◆ GetExtensionName()

const char * vulkan::VulkanNativeSurfaceAndroid::GetExtensionName ( ) const
overridevirtual

Implements vulkan::VulkanNativeSurface.

Definition at line 29 of file vulkan_native_surface_android.cc.

29 {
30 // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_android_surface.html
32}
#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME

◆ GetSize()

SkISize vulkan::VulkanNativeSurfaceAndroid::GetSize ( ) const
overridevirtual

Implements vulkan::VulkanNativeSurface.

Definition at line 62 of file vulkan_native_surface_android.cc.

62 {
63 return native_window_ == nullptr
64 ? SkISize::Make(0, 0)
65 : SkISize::Make(ANativeWindow_getWidth(native_window_),
66 ANativeWindow_getHeight(native_window_));
67}
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20

◆ IsValid()

bool vulkan::VulkanNativeSurfaceAndroid::IsValid ( ) const
overridevirtual

Implements vulkan::VulkanNativeSurface.

Definition at line 58 of file vulkan_native_surface_android.cc.

58 {
59 return native_window_ != nullptr;
60}

The documentation for this class was generated from the following files: