Flutter Engine
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
 
uint32_t GetSkiaExtensionName () 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
 

Detailed Description

Definition at line 16 of file vulkan_native_surface_android.h.

Constructor & Destructor Documentation

◆ VulkanNativeSurfaceAndroid()

vulkan::VulkanNativeSurfaceAndroid::VulkanNativeSurfaceAndroid ( ANativeWindow native_window)

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 37 of file vulkan_native_surface_android.cc.

References vulkan::VulkanProcTable::IsValid(), and VK_CALL_LOG_ERROR.

39  {
40  if (!vk.IsValid() || !instance) {
41  return VK_NULL_HANDLE;
42  }
43 
44  const VkAndroidSurfaceCreateInfoKHR create_info = {
45  .sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR,
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 }
#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  return VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
31 }

◆ GetSize()

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

Implements vulkan::VulkanNativeSurface.

Definition at line 65 of file vulkan_native_surface_android.cc.

65  {
66  return native_window_ == nullptr
67  ? SkISize::Make(0, 0)
68  : SkISize::Make(ANativeWindow_getWidth(native_window_),
69  ANativeWindow_getHeight(native_window_));
70 }

◆ GetSkiaExtensionName()

uint32_t vulkan::VulkanNativeSurfaceAndroid::GetSkiaExtensionName ( ) const
overridevirtual

Implements vulkan::VulkanNativeSurface.

Definition at line 33 of file vulkan_native_surface_android.cc.

33  {
34  return kKHR_android_surface_GrVkExtensionFlag;
35 }

◆ IsValid()

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

Implements vulkan::VulkanNativeSurface.

Definition at line 61 of file vulkan_native_surface_android.cc.

61  {
62  return native_window_ != nullptr;
63 }

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