/ chapters / VK_KHR_android_surface / platformCreateSurface_android.txt
platformCreateSurface_android.txt
 1  // Copyright (c) 2014-2019 Khronos Group. This work is licensed under a
 2  // Creative Commons Attribution 4.0 International License; see
 3  // http://creativecommons.org/licenses/by/4.0/
 4  
 5  [[platformCreateSurface_android,platformCreateSurface_android]]
 6  
 7  === Android Platform
 8  
 9  [open,refpage='vkCreateAndroidSurfaceKHR',desc='Create a slink:VkSurfaceKHR object for an Android native window',type='protos']
10  --
11  
12  To create a sname:VkSurfaceKHR object for an Android native window, call:
13  
14  include::{generated}/api/protos/vkCreateAndroidSurfaceKHR.txt[]
15  
16    * pname:instance is the instance to associate the surface with.
17    * pname:pCreateInfo is a pointer to an instance of the
18      sname:VkAndroidSurfaceCreateInfoKHR structure containing parameters
19      affecting the creation of the surface object.
20    * pname:pAllocator is the allocator used for host memory allocated for the
21      surface object when there is no more specific allocator available (see
22      <<memory-allocation,Memory Allocation>>).
23    * pname:pSurface points to a slink:VkSurfaceKHR handle in which the
24      created surface object is returned.
25  
26  During the lifetime of a surface created using a particular
27  dlink:ANativeWindow handle any attempts to create another surface for the
28  same dlink:ANativeWindow and any attempts to connect to the same
29  dlink:ANativeWindow through other platform mechanisms will fail.
30  
31  [NOTE]
32  .Note
33  ====
34  In particular, only one sname:VkSurfaceKHR can: exist at a time for a given
35  window.
36  Similarly, a native window cannot: be used by both a sname:VkSurfaceKHR and
37  code:EGLSurface simultaneously.
38  ====
39  
40  If successful, fname:vkCreateAndroidSurfaceKHR increments the
41  dlink:ANativeWindow's reference count, and fname:vkDestroySurfaceKHR will
42  decrement it.
43  
44  On Android, when a swapchain's pname:imageExtent does not match the
45  surface's pname:currentExtent, the presentable images will be scaled to the
46  surface's dimensions during presentation.
47  pname:minImageExtent is [eq]#(1,1)#, and pname:maxImageExtent is the maximum
48  image size supported by the consumer.
49  For the system compositor, pname:currentExtent is the window size (i.e. the
50  consumer's preferred size).
51  
52  include::{generated}/validity/protos/vkCreateAndroidSurfaceKHR.txt[]
53  --
54  
55  [open,refpage='VkAndroidSurfaceCreateInfoKHR',desc='Structure specifying parameters of a newly created Android surface object',type='structs']
56  --
57  
58  The sname:VkAndroidSurfaceCreateInfoKHR structure is defined as:
59  
60  include::{generated}/api/structs/VkAndroidSurfaceCreateInfoKHR.txt[]
61  
62    * pname:sType is the type of this structure.
63    * pname:pNext is `NULL` or a pointer to an extension-specific structure.
64    * pname:flags is reserved for future use.
65    * pname:window is a pointer to the dlink:ANativeWindow to associate the
66      surface with.
67  
68  .Valid Usage
69  ****
70    * [[VUID-VkAndroidSurfaceCreateInfoKHR-window-01248]]
71      pname:window must: point to a valid Android dlink:ANativeWindow.
72  ****
73  
74  include::{generated}/validity/structs/VkAndroidSurfaceCreateInfoKHR.txt[]
75  --
76  
77  [open,refpage='ANativeWindow',desc='Android native window type',type='defines']
78  --
79  To remove an unnecessary compile-time dependency, an incomplete type
80  definition of dlink:ANativeWindow is provided in the Vulkan headers:
81  
82  include::{generated}/api/defines/ANativeWindow.txt[]
83  
84  The actual dlink:ANativeWindow type is defined in Android NDK headers.
85  --