Loading core/jni/android/graphics/SurfaceTexture.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <stdio.h> #include <gui/SurfaceTexture.h> #include <gui/SurfaceTextureClient.h> #include <android_runtime/AndroidRuntime.h> Loading Loading @@ -64,6 +65,15 @@ sp<SurfaceTexture> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz) return surfaceTexture; } sp<ANativeWindow> android_SurfaceTexture_getNativeWindow( JNIEnv* env, jobject thiz) { sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); sp<SurfaceTextureClient> surfaceTextureClient(surfaceTexture != NULL ? new SurfaceTextureClient(surfaceTexture) : NULL); return surfaceTextureClient; } // ---------------------------------------------------------------------------- class JNISurfaceTextureContext : public SurfaceTexture::FrameAvailableListener Loading include/android_runtime/android_graphics_SurfaceTexture.h 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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. */ #ifndef _ANDROID_GRAPHICS_SURFACETEXTURE_H #define _ANDROID_GRAPHICS_SURFACETEXTURE_H #include <android/native_window.h> #include "jni.h" namespace android { extern sp<ANativeWindow> android_SurfaceTexture_getNativeWindow( JNIEnv* env, jobject thiz); } // namespace android #endif // _ANDROID_GRAPHICS_SURFACETEXTURE_H native/android/native_window.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading native/include/android/native_window_jni.h +8 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
core/jni/android/graphics/SurfaceTexture.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <stdio.h> #include <gui/SurfaceTexture.h> #include <gui/SurfaceTextureClient.h> #include <android_runtime/AndroidRuntime.h> Loading Loading @@ -64,6 +65,15 @@ sp<SurfaceTexture> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz) return surfaceTexture; } sp<ANativeWindow> android_SurfaceTexture_getNativeWindow( JNIEnv* env, jobject thiz) { sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); sp<SurfaceTextureClient> surfaceTextureClient(surfaceTexture != NULL ? new SurfaceTextureClient(surfaceTexture) : NULL); return surfaceTextureClient; } // ---------------------------------------------------------------------------- class JNISurfaceTextureContext : public SurfaceTexture::FrameAvailableListener Loading
include/android_runtime/android_graphics_SurfaceTexture.h 0 → 100644 +31 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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. */ #ifndef _ANDROID_GRAPHICS_SURFACETEXTURE_H #define _ANDROID_GRAPHICS_SURFACETEXTURE_H #include <android/native_window.h> #include "jni.h" namespace android { extern sp<ANativeWindow> android_SurfaceTexture_getNativeWindow( JNIEnv* env, jobject thiz); } // namespace android #endif // _ANDROID_GRAPHICS_SURFACETEXTURE_H
native/android/native_window.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading
native/include/android/native_window_jni.h +8 −0 Original line number Diff line number Diff line Loading @@ -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 Loading