Bug 3515073 Add ANativeWindow_fromSurfaceTexture
This is similar to ANativeWindow_fromSurface.
Change-Id: Iaadc06a5d0d50685c34876aa89488c16e7cfaa65
diff --git a/native/android/native_window.cpp b/native/android/native_window.cpp
index 7f92eec..219cd19 100644
--- a/native/android/native_window.cpp
+++ b/native/android/native_window.cpp
@@ -20,6 +20,7 @@
#include <android/native_window_jni.h>
#include <surfaceflinger/Surface.h>
#include <android_runtime/android_view_Surface.h>
+#include <android_runtime/android_graphics_SurfaceTexture.h>
using namespace android;
@@ -31,6 +32,14 @@
return win.get();
}
+ANativeWindow* ANativeWindow_fromSurfaceTexture(JNIEnv* env, jobject surfaceTexture) {
+ sp<ANativeWindow> win = android_SurfaceTexture_getNativeWindow(env, surfaceTexture);
+ if (win != NULL) {
+ win->incStrong((void*)ANativeWindow_acquire);
+ }
+ return win.get();
+}
+
void ANativeWindow_acquire(ANativeWindow* window) {
window->incStrong((void*)ANativeWindow_acquire);
}