1 /* 2 __ 3 / _| 4 __ _ _ _ _ __ ___ _ __ __ _ | |_ ___ ___ ___ 5 / _` | | | | '__/ _ \| '__/ _` | | _/ _ \/ __/ __| 6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \ 7 \__,_|\__,_|_| \___/|_| \__,_| |_| \___/|___/___/ 8 9 Copyright (C) 2018 The Android Open Source Project. 10 Copyright (C) 2018-2019 Aurora Free Open Source Software. 11 12 This file is part of the Aurora Free Open Source Software. This 13 organization promote free and open source software that you can 14 redistribute and/or modify under the terms of the GNU Lesser General 15 Public License Version 3 as published by the Free Software Foundation or 16 (at your option) any later version approved by the Aurora Free Open Source 17 Software Organization. The license is available in the package root path 18 as 'LICENSE' file. Please review the following information to ensure the 19 GNU Lesser General Public License version 3 requirements will be met: 20 https://www.gnu.org/licenses/lgpl.html . 21 22 Alternatively, this file may be used under the terms of the GNU General 23 Public License version 3 or later as published by the Free Software 24 Foundation. Please review the following information to ensure the GNU 25 General Public License requirements will be met: 26 https://www.gnu.org/licenses/gpl-3.0.html. 27 28 NOTE: All products, services or anything associated to trademarks and 29 service marks used or referenced on this file are the property of their 30 respective companies/owners or its subsidiaries. Other names and brands 31 may be claimed as the property of others. 32 33 For more info about intellectual property visit: aurorafoss.org or 34 directly send an email to: contact (at) aurorafoss.org . 35 36 This file has bindings for an existing code, part of The Android Open Source 37 Project implementation. Check it out at android.googlesource.com . 38 */ 39 40 module aurorafw.android.platform.surface_texture; 41 42 /** 43 * @addtogroup SurfaceTexture 44 * @{ 45 */ 46 47 /** 48 * @file aurorafw/android/platform/surface_texture.d 49 */ 50 51 version (Android): 52 extern (C): 53 @system: 54 nothrow: 55 @nogc: 56 57 /****************************************************************** 58 * 59 * IMPORTANT NOTICE: 60 * 61 * This file is part of Android's set of stable system headers 62 * exposed by the Android NDK (Native Development Kit). 63 * 64 * Third-party source AND binary code relies on the definitions 65 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. 66 * 67 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) 68 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS 69 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY 70 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES 71 */ 72 73 struct ASurfaceTexture; 74 75 /** 76 * {@link ASurfaceTexture} is an opaque type to manage SurfaceTexture from native code 77 * 78 * {@link ASurfaceTexture} can be obtained from an android.graphics.SurfaceTexture object using 79 * ASurfaceTexture_fromSurfaceTexture(). 80 */ 81 82 /** 83 * Release the reference to the native ASurfaceTexture acquired with 84 * ASurfaceTexture_fromSurfaceTexture(). 85 * Failing to do so will result in leaked memory and graphic resources. 86 * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() 87 */ 88 void ASurfaceTexture_release (ASurfaceTexture* st); 89 90 /** 91 * Returns a reference to an ANativeWindow (i.e. the Producer) for this SurfaceTexture. 92 * This is equivalent to Java's: Surface sur = new Surface(surfaceTexture); 93 * 94 * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() 95 * @return A reference to an ANativeWindow. This reference MUST BE released when no longer needed 96 * using ANativeWindow_release(). Failing to do so will result in leaked resources. nullptr is 97 * returned if \p st is null or if it's not an instance of android.graphics.SurfaceTexture 98 */ 99 ANativeWindow* ASurfaceTexture_acquireANativeWindow (ASurfaceTexture* st); 100 101 /** 102 * Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread. A 103 * new OpenGL ES texture object is created and populated with the SurfaceTexture image frame 104 * that was current at the time of the last call to {@link #detachFromGLContext}. This new 105 * texture is bound to the GL_TEXTURE_EXTERNAL_OES texture target. 106 * 107 * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES 108 * contexts. Note, however, that the image contents are only accessible from one OpenGL ES 109 * context at a time. 110 * 111 * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() 112 * \param texName The name of the OpenGL ES texture that will be created. This texture name 113 * must be unusued in the OpenGL ES context that is current on the calling thread. 114 * \return 0 on success, negative posix error code otherwise (see <errno.h>) 115 */ 116 int ASurfaceTexture_attachToGLContext (ASurfaceTexture* st, uint texName); 117 118 /** 119 * Detach the SurfaceTexture from the OpenGL ES context that owns the OpenGL ES texture object. 120 * This call must be made with the OpenGL ES context current on the calling thread. The OpenGL 121 * ES texture object will be deleted as a result of this call. After calling this method all 122 * calls to {@link #updateTexImage} will fail until a successful call to {@link #attachToGLContext} 123 * is made. 124 * 125 * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES 126 * contexts. Note, however, that the image contents are only accessible from one OpenGL ES 127 * context at a time. 128 * 129 * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() 130 * \return 0 on success, negative posix error code otherwise (see <errno.h>) 131 */ 132 int ASurfaceTexture_detachFromGLContext (ASurfaceTexture* st); 133 134 /** 135 * Update the texture image to the most recent frame from the image stream. This may only be 136 * called while the OpenGL ES context that owns the texture is current on the calling thread. 137 * It will implicitly bind its texture to the GL_TEXTURE_EXTERNAL_OES texture target. 138 * 139 * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() 140 * \return 0 on success, negative posix error code otherwise (see <errno.h>) 141 */ 142 int ASurfaceTexture_updateTexImage (ASurfaceTexture* st); 143 144 /** 145 * Retrieve the 4x4 texture coordinate transform matrix associated with the texture image set by 146 * the most recent call to updateTexImage. 147 * 148 * This transform matrix maps 2D homogeneous texture coordinates of the form (s, t, 0, 1) with s 149 * and t in the inclusive range [0, 1] to the texture coordinate that should be used to sample 150 * that location from the texture. Sampling the texture outside of the range of this transform 151 * is undefined. 152 * 153 * The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via 154 * the glLoadMatrixf or glUniformMatrix4fv functions. 155 * 156 * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() 157 * \param mtx the array into which the 4x4 matrix will be stored. The array must have exactly 158 * 16 elements. 159 */ 160 void ASurfaceTexture_getTransformMatrix (ASurfaceTexture* st, ref float[16] mtx); 161 162 /** 163 * Retrieve the timestamp associated with the texture image set by the most recent call to 164 * updateTexImage. 165 * 166 * This timestamp is in nanoseconds, and is normally monotonically increasing. The timestamp 167 * should be unaffected by time-of-day adjustments, and for a camera should be strictly 168 * monotonic but for a MediaPlayer may be reset when the position is set. The 169 * specific meaning and zero point of the timestamp depends on the source providing images to 170 * the SurfaceTexture. Unless otherwise specified by the image source, timestamps cannot 171 * generally be compared across SurfaceTexture instances, or across multiple program 172 * invocations. It is mostly useful for determining time offsets between subsequent frames. 173 * 174 * For EGL/Vulkan producers, this timestamp is the desired present time set with the 175 * EGL_ANDROID_presentation_time or VK_GOOGLE_display_timing extensions 176 * 177 * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() 178 */ 179 long ASurfaceTexture_getTimestamp (ASurfaceTexture* st); 180 181 /* __ANDROID_API__ >= 28 */ 182 183 /* ANDROID_NATIVE_SURFACE_TEXTURE_H */