diff options
Diffstat (limited to 'include/android')
-rw-r--r-- | include/android/hardware_buffer_jni.h | 8 | ||||
-rw-r--r-- | include/android/keycodes.h | 4 | ||||
-rw-r--r-- | include/android/sensor.h | 4 | ||||
-rw-r--r-- | include/android/surface_texture.h | 162 | ||||
-rw-r--r-- | include/android/surface_texture_jni.h | 53 |
5 files changed, 225 insertions, 6 deletions
diff --git a/include/android/hardware_buffer_jni.h b/include/android/hardware_buffer_jni.h index 60208701b6..7c4be24dbd 100644 --- a/include/android/hardware_buffer_jni.h +++ b/include/android/hardware_buffer_jni.h @@ -31,9 +31,11 @@ __BEGIN_DECLS /** * Return the AHardwareBuffer associated with a Java HardwareBuffer object, - * for interacting with it through native code. This acquires a reference - * on the AHardwareBuffer that is returned; be sure to use - * AHardwareBuffer_release() when done with it so that it doesn't leak. + * for interacting with it through native code. This method does not acquire any + * additional reference to the AHardwareBuffer that is returned. To keep the + * AHardwareBuffer live after the Java HardwareBuffer object got garbage + * collected, be sure to use AHardwareBuffer_acquire() to acquire an additional + * reference. */ AHardwareBuffer* AHardwareBuffer_fromHardwareBuffer(JNIEnv* env, jobject hardwareBufferObj); diff --git a/include/android/keycodes.h b/include/android/keycodes.h index 2164d6163e..59d67f35f2 100644 --- a/include/android/keycodes.h +++ b/include/android/keycodes.h @@ -767,7 +767,9 @@ enum { /** fingerprint navigation key, right. */ AKEYCODE_SYSTEM_NAVIGATION_RIGHT = 283, /** all apps */ - AKEYCODE_ALL_APPS = 284 + AKEYCODE_ALL_APPS = 284, + /** refresh key */ + AKEYCODE_REFRESH = 285 // NOTE: If you add a new keycode here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. diff --git a/include/android/sensor.h b/include/android/sensor.h index 029db0a2fe..191777cee5 100644 --- a/include/android/sensor.h +++ b/include/android/sensor.h @@ -288,7 +288,7 @@ enum { * A sensor event. */ -/* NOTE: Must match hardware/sensors.h */ +/* NOTE: changes to these structs have to be backward compatible */ typedef struct ASensorVector { union { float v[3]; @@ -350,7 +350,7 @@ typedef struct { }; } AAdditionalInfoEvent; -/* NOTE: Must match hardware/sensors.h */ +/* NOTE: changes to this struct has to be backward compatible */ typedef struct ASensorEvent { int32_t version; /* sizeof(struct ASensorEvent) */ int32_t sensor; diff --git a/include/android/surface_texture.h b/include/android/surface_texture.h new file mode 100644 index 0000000000..56b3342166 --- /dev/null +++ b/include/android/surface_texture.h @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup SurfaceTexture + * @{ + */ + +/** + * @file surface_texture.h + */ + +#ifndef ANDROID_NATIVE_SURFACE_TEXTURE_H +#define ANDROID_NATIVE_SURFACE_TEXTURE_H + +/****************************************************************** + * + * IMPORTANT NOTICE: + * + * This file is part of Android's set of stable system headers + * exposed by the Android NDK (Native Development Kit). + * + * Third-party source AND binary code relies on the definitions + * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. + * + * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) + * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS + * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY + * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES + */ + +#include <stdint.h> + +#include <android/native_window.h> + +__BEGIN_DECLS + +struct ASurfaceTexture; + +/** + * {@link ASurfaceTexture} is an opaque type to manage SurfaceTexture from native code + * + * {@link ASurfaceTexture} can be obtained from an android.graphics.SurfaceTexture object using + * ASurfaceTexture_fromSurfaceTexture(). + */ +typedef struct ASurfaceTexture ASurfaceTexture; + +/** + * Release the reference to the native ASurfaceTexture acquired with + * ASurfaceTexture_fromSurfaceTexture(). + * Failing to do so will result in leaked memory and graphic resources. + * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() + */ +void ASurfaceTexture_release(ASurfaceTexture* st); + +/** + * Returns a reference to an ANativeWindow (i.e. the Producer) for this SurfaceTexture. + * This is equivalent to Java's: Surface sur = new Surface(surfaceTexture); + * + * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() + * @return A reference to an ANativeWindow. This reference MUST BE released when no longer needed + * using ANativeWindow_release(). Failing to do so will result in leaked resources. nullptr is + * returned if \st is null or if it's not an instance of android.graphics.SurfaceTexture + */ +ANativeWindow* ASurfaceTexture_acquireANativeWindow(ASurfaceTexture* st); + +/** + * Attach the SurfaceTexture to the OpenGL ES context that is current on the calling thread. A + * new OpenGL ES texture object is created and populated with the SurfaceTexture image frame + * that was current at the time of the last call to {@link #detachFromGLContext}. This new + * texture is bound to the GL_TEXTURE_EXTERNAL_OES texture target. + * + * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES + * contexts. Note, however, that the image contents are only accessible from one OpenGL ES + * context at a time. + * + * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() + * \param texName The name of the OpenGL ES texture that will be created. This texture name + * must be unusued in the OpenGL ES context that is current on the calling thread. + * \return 0 on success, negative posix error code otherwise (see <errno.h>) + */ +int ASurfaceTexture_attachToGLContext(ASurfaceTexture* st, uint32_t texName); + +/** + * Detach the SurfaceTexture from the OpenGL ES context that owns the OpenGL ES texture object. + * This call must be made with the OpenGL ES context current on the calling thread. The OpenGL + * ES texture object will be deleted as a result of this call. After calling this method all + * calls to {@link #updateTexImage} will fail until a successful call to {@link #attachToGLContext} + * is made. + * + * This can be used to access the SurfaceTexture image contents from multiple OpenGL ES + * contexts. Note, however, that the image contents are only accessible from one OpenGL ES + * context at a time. + * + * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() + * \return 0 on success, negative posix error code otherwise (see <errno.h>) + */ +int ASurfaceTexture_detachFromGLContext(ASurfaceTexture* st); + +/** + * Update the texture image to the most recent frame from the image stream. This may only be + * called while the OpenGL ES context that owns the texture is current on the calling thread. + * It will implicitly bind its texture to the GL_TEXTURE_EXTERNAL_OES texture target. + * + * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() + * \return 0 on success, negative posix error code otherwise (see <errno.h>) + */ +int ASurfaceTexture_updateTexImage(ASurfaceTexture* st); + +/** + * Retrieve the 4x4 texture coordinate transform matrix associated with the texture image set by + * the most recent call to updateTexImage. + * + * This transform matrix maps 2D homogeneous texture coordinates of the form (s, t, 0, 1) with s + * and t in the inclusive range [0, 1] to the texture coordinate that should be used to sample + * that location from the texture. Sampling the texture outside of the range of this transform + * is undefined. + * + * The matrix is stored in column-major order so that it may be passed directly to OpenGL ES via + * the glLoadMatrixf or glUniformMatrix4fv functions. + * + * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() + * \param mtx the array into which the 4x4 matrix will be stored. The array must have exactly + * 16 elements. + */ +void ASurfaceTexture_getTransformMatrix(ASurfaceTexture* st, float mtx[16]); + +/** + * Retrieve the timestamp associated with the texture image set by the most recent call to + * updateTexImage. + * + * This timestamp is in nanoseconds, and is normally monotonically increasing. The timestamp + * should be unaffected by time-of-day adjustments, and for a camera should be strictly + * monotonic but for a MediaPlayer may be reset when the position is set. The + * specific meaning and zero point of the timestamp depends on the source providing images to + * the SurfaceTexture. Unless otherwise specified by the image source, timestamps cannot + * generally be compared across SurfaceTexture instances, or across multiple program + * invocations. It is mostly useful for determining time offsets between subsequent frames. + * + * For EGL/Vulkan producers, this timestamp is the desired present time set with the + * EGL_ANDROID_presentation_time or VK_GOOGLE_display_timing extensions + * + * \param st A ASurfaceTexture reference acquired with ASurfaceTexture_fromSurfaceTexture() + */ +int64_t ASurfaceTexture_getTimestamp(ASurfaceTexture* st); + +__END_DECLS + +#endif /* ANDROID_NATIVE_SURFACE_TEXTURE_H */ diff --git a/include/android/surface_texture_jni.h b/include/android/surface_texture_jni.h new file mode 100644 index 0000000000..b0e1edd590 --- /dev/null +++ b/include/android/surface_texture_jni.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup SurfaceTexture + * @{ + */ + +/** + * @file surface_texture_jni.h + */ + +#ifndef ANDROID_NATIVE_SURFACE_TEXTURE_JNI_H +#define ANDROID_NATIVE_SURFACE_TEXTURE_JNI_H + +#include <android/surface_texture.h> + +#include <jni.h> + +__BEGIN_DECLS + +/** + * Get a reference to the native ASurfaceTexture from the corresponding java object. + * + * The caller must keep a reference to the Java SurfaceTexture during the lifetime of the returned + * ASurfaceTexture. Failing to do so could result in the ASurfaceTexture to stop functioning + * properly once the Java object gets finalized. + * However, this will not result in program termination. + * + * \param env JNI environment + * \param surfacetexture Instance of Java SurfaceTexture object + * \return native ASurfaceTexture reference or nullptr if the java object is not a SurfaceTexture. + * The returned reference MUST BE released when it's no longer needed using + * ASurfaceTexture_release(). + */ +ASurfaceTexture* ASurfaceTexture_fromSurfaceTexture(JNIEnv* env, jobject surfacetexture); + +__END_DECLS + +#endif /* ANDROID_NATIVE_SURFACE_TEXTURE_JNI_H */ |