summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2011-03-11 16:31:55 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-03-11 16:31:55 -0800
commit7647091436c45af2d82f12c9ea9ec77fa309b49b (patch)
treea18e2556ba41a194b754d60c6929bc467cffbdc8 /native
parentf0230cca194c840684bab959856c56725fc40b87 (diff)
parent846db33313aa0899fa7928256c6734964bd92520 (diff)
downloadframeworks_base-7647091436c45af2d82f12c9ea9ec77fa309b49b.zip
frameworks_base-7647091436c45af2d82f12c9ea9ec77fa309b49b.tar.gz
frameworks_base-7647091436c45af2d82f12c9ea9ec77fa309b49b.tar.bz2
Merge "Bug 3515073 Add ANativeWindow_fromSurfaceTexture" into honeycomb-mr1
Diffstat (limited to 'native')
-rw-r--r--native/android/native_window.cpp9
-rw-r--r--native/include/android/native_window_jni.h8
2 files changed, 17 insertions, 0 deletions
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 @@ ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface) {
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);
}
diff --git a/native/include/android/native_window_jni.h b/native/include/android/native_window_jni.h
index b9e72ef..408c263 100644
--- a/native/include/android/native_window_jni.h
+++ b/native/include/android/native_window_jni.h
@@ -33,6 +33,14 @@ extern "C" {
*/
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
+/**
+ * Return the ANativeWindow associated with a Java SurfaceTexture object,
+ * for interacting with it through native code. This acquires a reference
+ * on the ANativeWindow that is returned; be sure to use ANativeWindow_release()
+ * when done with it so that it doesn't leak.
+ */
+ANativeWindow* ANativeWindow_fromSurfaceTexture(JNIEnv* env, jobject surfaceTexture);
+
#ifdef __cplusplus
};
#endif