Loading core/jni/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ LOCAL_SRC_FILES:= \ android/graphics/NinePatchImpl.cpp \ android/graphics/NinePatchPeeker.cpp \ android/graphics/Paint.cpp \ android/graphics/ParcelSurfaceTexture.cpp \ android/graphics/Path.cpp \ android/graphics/PathMeasure.cpp \ android/graphics/PathEffect.cpp \ Loading core/jni/AndroidRuntime.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ extern int register_android_graphics_ColorFilter(JNIEnv* env); extern int register_android_graphics_DrawFilter(JNIEnv* env); extern int register_android_graphics_Matrix(JNIEnv* env); extern int register_android_graphics_Paint(JNIEnv* env); extern int register_android_graphics_ParcelSurfaceTexture(JNIEnv* env); extern int register_android_graphics_Path(JNIEnv* env); extern int register_android_graphics_PathMeasure(JNIEnv* env); extern int register_android_graphics_Picture(JNIEnv*); Loading Loading @@ -1142,6 +1143,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_graphics_Movie), REG_JNI(register_android_graphics_NinePatch), REG_JNI(register_android_graphics_Paint), REG_JNI(register_android_graphics_ParcelSurfaceTexture), REG_JNI(register_android_graphics_Path), REG_JNI(register_android_graphics_PathMeasure), REG_JNI(register_android_graphics_PathEffect), Loading core/jni/android/graphics/ParcelSurfaceTexture.cpp 0 → 100644 +152 −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. */ #define LOG_TAG "ParcelSurfaceTexture" #include <gui/SurfaceTextureClient.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> #include <binder/Parcel.h> #include "android_util_Binder.h" #include "jni.h" #include "JNIHelp.h" #include "SurfaceTexture.h" // ---------------------------------------------------------------------------- namespace android { const char* const kParcelSurfaceTextureClassPathName = "android/graphics/ParcelSurfaceTexture"; struct fields_t { jfieldID iSurfaceTexture; }; static fields_t fields; #define ANDROID_GRAPHICS_ISURFACETEXTURE_JNI_ID "mISurfaceTexture" // ---------------------------------------------------------------------------- static void ParcelSurfaceTexture_setISurfaceTexture( JNIEnv* env, jobject thiz, const sp<ISurfaceTexture>& iSurfaceTexture) { ISurfaceTexture* const p = (ISurfaceTexture*)env->GetIntField(thiz, fields.iSurfaceTexture); if (iSurfaceTexture.get()) { iSurfaceTexture->incStrong(thiz); } if (p) { p->decStrong(thiz); } env->SetIntField(thiz, fields.iSurfaceTexture, (int)iSurfaceTexture.get()); } static sp<ISurfaceTexture> ParcelSurfaceTexture_getISurfaceTexture( JNIEnv* env, jobject thiz) { sp<ISurfaceTexture> iSurfaceTexture( (ISurfaceTexture*)env->GetIntField(thiz, fields.iSurfaceTexture)); return iSurfaceTexture; } sp<ANativeWindow> android_ParcelSurfaceTexture_getNativeWindow( JNIEnv* env, jobject thiz) { sp<ISurfaceTexture> iSurfaceTexture( ParcelSurfaceTexture_getISurfaceTexture(env, thiz)); sp<SurfaceTextureClient> surfaceTextureClient(iSurfaceTexture != NULL ? new SurfaceTextureClient(iSurfaceTexture) : NULL); return surfaceTextureClient; } bool android_ParcelSurfaceTexture_isInstanceOf(JNIEnv* env, jobject thiz) { jclass parcelSurfaceTextureClass = env->FindClass( kParcelSurfaceTextureClassPathName); return env->IsInstanceOf(thiz, parcelSurfaceTextureClass); } // ---------------------------------------------------------------------------- static void ParcelSurfaceTexture_classInit(JNIEnv* env, jclass clazz) { fields.iSurfaceTexture = env->GetFieldID(clazz, ANDROID_GRAPHICS_ISURFACETEXTURE_JNI_ID, "I"); if (fields.iSurfaceTexture == NULL) { LOGE("can't find android/graphics/ParcelSurfaceTexture.%s", ANDROID_GRAPHICS_ISURFACETEXTURE_JNI_ID); } } static void ParcelSurfaceTexture_init(JNIEnv* env, jobject thiz, jobject jSurfaceTexture) { sp<ISurfaceTexture> iSurfaceTexture( SurfaceTexture_getSurfaceTexture(env, jSurfaceTexture)); ParcelSurfaceTexture_setISurfaceTexture(env, thiz, iSurfaceTexture); } static void ParcelSurfaceTexture_finalize(JNIEnv* env, jobject thiz) { ParcelSurfaceTexture_setISurfaceTexture(env, thiz, 0); } static void ParcelSurfaceTexture_writeToParcel( JNIEnv* env, jobject thiz, jobject jParcel, jint flags) { Parcel* parcel = parcelForJavaObject(env, jParcel); sp<ISurfaceTexture> iSurfaceTexture( ParcelSurfaceTexture_getISurfaceTexture(env, thiz)); sp<IBinder> b(iSurfaceTexture->asBinder()); parcel->writeStrongBinder(b); } static void ParcelSurfaceTexture_readFromParcel( JNIEnv* env, jobject thiz, jobject jParcel) { Parcel* parcel = parcelForJavaObject(env, jParcel); sp<ISurfaceTexture> iSurfaceTexture( interface_cast<ISurfaceTexture>(parcel->readStrongBinder())); ParcelSurfaceTexture_setISurfaceTexture(env, thiz, iSurfaceTexture); } // ---------------------------------------------------------------------------- static JNINativeMethod gParcelSurfaceTextureMethods[] = { {"nativeClassInit", "()V", (void*)ParcelSurfaceTexture_classInit }, {"nativeInit", "(Landroid/graphics/SurfaceTexture;)V", (void *)ParcelSurfaceTexture_init }, { "nativeFinalize", "()V", (void *)ParcelSurfaceTexture_finalize }, { "nativeWriteToParcel", "(Landroid/os/Parcel;I)V", (void *)ParcelSurfaceTexture_writeToParcel }, { "nativeReadFromParcel", "(Landroid/os/Parcel;)V", (void *)ParcelSurfaceTexture_readFromParcel }, }; int register_android_graphics_ParcelSurfaceTexture(JNIEnv* env) { int err = 0; err = AndroidRuntime::registerNativeMethods(env, kParcelSurfaceTextureClassPathName, gParcelSurfaceTextureMethods, NELEM(gParcelSurfaceTextureMethods)); return err; } } // namespace android core/jni/android/graphics/SurfaceTexture.cpp +15 −3 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ namespace android { static const char* const OutOfResourcesException = "android/graphics/SurfaceTexture$OutOfResourcesException"; const char* const kSurfaceTextureClassPathName = "android/graphics/SurfaceTexture"; struct fields_t { jfieldID surfaceTexture; Loading Loading @@ -74,6 +75,12 @@ sp<ANativeWindow> android_SurfaceTexture_getNativeWindow( return surfaceTextureClient; } bool android_SurfaceTexture_isInstanceOf(JNIEnv* env, jobject thiz) { jclass surfaceTextureClass = env->FindClass(kSurfaceTextureClassPathName); return env->IsInstanceOf(thiz, surfaceTextureClass); } // ---------------------------------------------------------------------------- class JNISurfaceTextureContext : public SurfaceTexture::FrameAvailableListener Loading Loading @@ -123,7 +130,6 @@ static void SurfaceTexture_classInit(JNIEnv* env, jclass clazz) if (fields.postEvent == NULL) { LOGE("can't find android/graphics/SurfaceTexture.postEventFromNative"); } } static void SurfaceTexture_init(JNIEnv* env, jobject thiz, jint texName, Loading Loading @@ -156,6 +162,13 @@ static void SurfaceTexture_finalize(JNIEnv* env, jobject thiz) SurfaceTexture_setSurfaceTexture(env, thiz, 0); } static void SurfaceTexture_setDefaultBufferSize( JNIEnv* env, jobject thiz, jint width, jint height) { sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); surfaceTexture->setDefaultBufferSize(width, height); } static void SurfaceTexture_updateTexImage(JNIEnv* env, jobject thiz) { sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); Loading @@ -179,12 +192,11 @@ static jlong SurfaceTexture_getTimestamp(JNIEnv* env, jobject thiz) // ---------------------------------------------------------------------------- const char* const kSurfaceTextureClassPathName = "android/graphics/SurfaceTexture"; static JNINativeMethod gSurfaceTextureMethods[] = { {"nativeClassInit", "()V", (void*)SurfaceTexture_classInit }, {"nativeInit", "(ILjava/lang/Object;)V", (void*)SurfaceTexture_init }, {"nativeFinalize", "()V", (void*)SurfaceTexture_finalize }, {"nativeSetDefaultBufferSize", "(II)V", (void*)SurfaceTexture_setDefaultBufferSize }, {"nativeUpdateTexImage", "()V", (void*)SurfaceTexture_updateTexImage }, {"nativeGetTransformMatrix", "([F)V", (void*)SurfaceTexture_getTransformMatrix }, {"nativeGetTimestamp", "()J", (void*)SurfaceTexture_getTimestamp } Loading core/jni/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 <gui/SurfaceTexture.h> #include <utils/StrongPointer.h> #include "jni.h" namespace android { /* Gets the underlying SurfaceTexture from a SurfaceTexture Java object. */ sp<SurfaceTexture> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz); } // namespace android #endif // _ANDROID_GRAPHICS_SURFACETEXTURE_H Loading
core/jni/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ LOCAL_SRC_FILES:= \ android/graphics/NinePatchImpl.cpp \ android/graphics/NinePatchPeeker.cpp \ android/graphics/Paint.cpp \ android/graphics/ParcelSurfaceTexture.cpp \ android/graphics/Path.cpp \ android/graphics/PathMeasure.cpp \ android/graphics/PathEffect.cpp \ Loading
core/jni/AndroidRuntime.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ extern int register_android_graphics_ColorFilter(JNIEnv* env); extern int register_android_graphics_DrawFilter(JNIEnv* env); extern int register_android_graphics_Matrix(JNIEnv* env); extern int register_android_graphics_Paint(JNIEnv* env); extern int register_android_graphics_ParcelSurfaceTexture(JNIEnv* env); extern int register_android_graphics_Path(JNIEnv* env); extern int register_android_graphics_PathMeasure(JNIEnv* env); extern int register_android_graphics_Picture(JNIEnv*); Loading Loading @@ -1142,6 +1143,7 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_graphics_Movie), REG_JNI(register_android_graphics_NinePatch), REG_JNI(register_android_graphics_Paint), REG_JNI(register_android_graphics_ParcelSurfaceTexture), REG_JNI(register_android_graphics_Path), REG_JNI(register_android_graphics_PathMeasure), REG_JNI(register_android_graphics_PathEffect), Loading
core/jni/android/graphics/ParcelSurfaceTexture.cpp 0 → 100644 +152 −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. */ #define LOG_TAG "ParcelSurfaceTexture" #include <gui/SurfaceTextureClient.h> #include <android_runtime/AndroidRuntime.h> #include <utils/Log.h> #include <binder/Parcel.h> #include "android_util_Binder.h" #include "jni.h" #include "JNIHelp.h" #include "SurfaceTexture.h" // ---------------------------------------------------------------------------- namespace android { const char* const kParcelSurfaceTextureClassPathName = "android/graphics/ParcelSurfaceTexture"; struct fields_t { jfieldID iSurfaceTexture; }; static fields_t fields; #define ANDROID_GRAPHICS_ISURFACETEXTURE_JNI_ID "mISurfaceTexture" // ---------------------------------------------------------------------------- static void ParcelSurfaceTexture_setISurfaceTexture( JNIEnv* env, jobject thiz, const sp<ISurfaceTexture>& iSurfaceTexture) { ISurfaceTexture* const p = (ISurfaceTexture*)env->GetIntField(thiz, fields.iSurfaceTexture); if (iSurfaceTexture.get()) { iSurfaceTexture->incStrong(thiz); } if (p) { p->decStrong(thiz); } env->SetIntField(thiz, fields.iSurfaceTexture, (int)iSurfaceTexture.get()); } static sp<ISurfaceTexture> ParcelSurfaceTexture_getISurfaceTexture( JNIEnv* env, jobject thiz) { sp<ISurfaceTexture> iSurfaceTexture( (ISurfaceTexture*)env->GetIntField(thiz, fields.iSurfaceTexture)); return iSurfaceTexture; } sp<ANativeWindow> android_ParcelSurfaceTexture_getNativeWindow( JNIEnv* env, jobject thiz) { sp<ISurfaceTexture> iSurfaceTexture( ParcelSurfaceTexture_getISurfaceTexture(env, thiz)); sp<SurfaceTextureClient> surfaceTextureClient(iSurfaceTexture != NULL ? new SurfaceTextureClient(iSurfaceTexture) : NULL); return surfaceTextureClient; } bool android_ParcelSurfaceTexture_isInstanceOf(JNIEnv* env, jobject thiz) { jclass parcelSurfaceTextureClass = env->FindClass( kParcelSurfaceTextureClassPathName); return env->IsInstanceOf(thiz, parcelSurfaceTextureClass); } // ---------------------------------------------------------------------------- static void ParcelSurfaceTexture_classInit(JNIEnv* env, jclass clazz) { fields.iSurfaceTexture = env->GetFieldID(clazz, ANDROID_GRAPHICS_ISURFACETEXTURE_JNI_ID, "I"); if (fields.iSurfaceTexture == NULL) { LOGE("can't find android/graphics/ParcelSurfaceTexture.%s", ANDROID_GRAPHICS_ISURFACETEXTURE_JNI_ID); } } static void ParcelSurfaceTexture_init(JNIEnv* env, jobject thiz, jobject jSurfaceTexture) { sp<ISurfaceTexture> iSurfaceTexture( SurfaceTexture_getSurfaceTexture(env, jSurfaceTexture)); ParcelSurfaceTexture_setISurfaceTexture(env, thiz, iSurfaceTexture); } static void ParcelSurfaceTexture_finalize(JNIEnv* env, jobject thiz) { ParcelSurfaceTexture_setISurfaceTexture(env, thiz, 0); } static void ParcelSurfaceTexture_writeToParcel( JNIEnv* env, jobject thiz, jobject jParcel, jint flags) { Parcel* parcel = parcelForJavaObject(env, jParcel); sp<ISurfaceTexture> iSurfaceTexture( ParcelSurfaceTexture_getISurfaceTexture(env, thiz)); sp<IBinder> b(iSurfaceTexture->asBinder()); parcel->writeStrongBinder(b); } static void ParcelSurfaceTexture_readFromParcel( JNIEnv* env, jobject thiz, jobject jParcel) { Parcel* parcel = parcelForJavaObject(env, jParcel); sp<ISurfaceTexture> iSurfaceTexture( interface_cast<ISurfaceTexture>(parcel->readStrongBinder())); ParcelSurfaceTexture_setISurfaceTexture(env, thiz, iSurfaceTexture); } // ---------------------------------------------------------------------------- static JNINativeMethod gParcelSurfaceTextureMethods[] = { {"nativeClassInit", "()V", (void*)ParcelSurfaceTexture_classInit }, {"nativeInit", "(Landroid/graphics/SurfaceTexture;)V", (void *)ParcelSurfaceTexture_init }, { "nativeFinalize", "()V", (void *)ParcelSurfaceTexture_finalize }, { "nativeWriteToParcel", "(Landroid/os/Parcel;I)V", (void *)ParcelSurfaceTexture_writeToParcel }, { "nativeReadFromParcel", "(Landroid/os/Parcel;)V", (void *)ParcelSurfaceTexture_readFromParcel }, }; int register_android_graphics_ParcelSurfaceTexture(JNIEnv* env) { int err = 0; err = AndroidRuntime::registerNativeMethods(env, kParcelSurfaceTextureClassPathName, gParcelSurfaceTextureMethods, NELEM(gParcelSurfaceTextureMethods)); return err; } } // namespace android
core/jni/android/graphics/SurfaceTexture.cpp +15 −3 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ namespace android { static const char* const OutOfResourcesException = "android/graphics/SurfaceTexture$OutOfResourcesException"; const char* const kSurfaceTextureClassPathName = "android/graphics/SurfaceTexture"; struct fields_t { jfieldID surfaceTexture; Loading Loading @@ -74,6 +75,12 @@ sp<ANativeWindow> android_SurfaceTexture_getNativeWindow( return surfaceTextureClient; } bool android_SurfaceTexture_isInstanceOf(JNIEnv* env, jobject thiz) { jclass surfaceTextureClass = env->FindClass(kSurfaceTextureClassPathName); return env->IsInstanceOf(thiz, surfaceTextureClass); } // ---------------------------------------------------------------------------- class JNISurfaceTextureContext : public SurfaceTexture::FrameAvailableListener Loading Loading @@ -123,7 +130,6 @@ static void SurfaceTexture_classInit(JNIEnv* env, jclass clazz) if (fields.postEvent == NULL) { LOGE("can't find android/graphics/SurfaceTexture.postEventFromNative"); } } static void SurfaceTexture_init(JNIEnv* env, jobject thiz, jint texName, Loading Loading @@ -156,6 +162,13 @@ static void SurfaceTexture_finalize(JNIEnv* env, jobject thiz) SurfaceTexture_setSurfaceTexture(env, thiz, 0); } static void SurfaceTexture_setDefaultBufferSize( JNIEnv* env, jobject thiz, jint width, jint height) { sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); surfaceTexture->setDefaultBufferSize(width, height); } static void SurfaceTexture_updateTexImage(JNIEnv* env, jobject thiz) { sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz)); Loading @@ -179,12 +192,11 @@ static jlong SurfaceTexture_getTimestamp(JNIEnv* env, jobject thiz) // ---------------------------------------------------------------------------- const char* const kSurfaceTextureClassPathName = "android/graphics/SurfaceTexture"; static JNINativeMethod gSurfaceTextureMethods[] = { {"nativeClassInit", "()V", (void*)SurfaceTexture_classInit }, {"nativeInit", "(ILjava/lang/Object;)V", (void*)SurfaceTexture_init }, {"nativeFinalize", "()V", (void*)SurfaceTexture_finalize }, {"nativeSetDefaultBufferSize", "(II)V", (void*)SurfaceTexture_setDefaultBufferSize }, {"nativeUpdateTexImage", "()V", (void*)SurfaceTexture_updateTexImage }, {"nativeGetTransformMatrix", "([F)V", (void*)SurfaceTexture_getTransformMatrix }, {"nativeGetTimestamp", "()J", (void*)SurfaceTexture_getTimestamp } Loading
core/jni/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 <gui/SurfaceTexture.h> #include <utils/StrongPointer.h> #include "jni.h" namespace android { /* Gets the underlying SurfaceTexture from a SurfaceTexture Java object. */ sp<SurfaceTexture> SurfaceTexture_getSurfaceTexture(JNIEnv* env, jobject thiz); } // namespace android #endif // _ANDROID_GRAPHICS_SURFACETEXTURE_H