diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2013-04-02 15:46:38 -0700 |
---|---|---|
committer | Eino-Ville Talvala <etalvala@google.com> | 2013-04-17 18:35:26 -0700 |
commit | 7005b67c127d229017840925d2bc1bd84c43aaf5 (patch) | |
tree | 4d31440aaf7fcc4d320a9eafecb602a35039f4dc /core/jni/android_hardware_Camera.cpp | |
parent | 3b9dd0a95869d93396e3346cb67b19bae50e0432 (diff) | |
download | frameworks_base-7005b67c127d229017840925d2bc1bd84c43aaf5.zip frameworks_base-7005b67c127d229017840925d2bc1bd84c43aaf5.tar.gz frameworks_base-7005b67c127d229017840925d2bc1bd84c43aaf5.tar.bz2 |
Camera: Add hidden camera preview to renderscript allocation API
- Camera.createPreviewAllocation() creates YUV allocations for use as
a preview buffer destination.
- Camera.setPreviewCallbackAllocation() sets such an allocation as the
target for preview data from camera.
Bug: 8563840
Change-Id: Ie42033976fed825d396550bbc033d434c8206b6b
Diffstat (limited to 'core/jni/android_hardware_Camera.cpp')
-rw-r--r-- | core/jni/android_hardware_Camera.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index 686e4e3..dec4cd4 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -586,6 +586,30 @@ static void android_hardware_Camera_setPreviewTexture(JNIEnv *env, } } +static void android_hardware_Camera_setPreviewCallbackSurface(JNIEnv *env, + jobject thiz, jobject jSurface) +{ + ALOGV("setPreviewCallbackSurface"); + JNICameraContext* context; + sp<Camera> camera = get_native_camera(env, thiz, &context); + if (camera == 0) return; + + sp<IGraphicBufferProducer> gbp; + sp<Surface> surface; + if (jSurface) { + surface = android_view_Surface_getSurface(env, jSurface); + if (surface != NULL) { + gbp = surface->getIGraphicBufferProducer(); + } + } + // Clear out normal preview callbacks + context->setCallbackMode(env, false, false); + // Then set up callback surface + if (camera->setPreviewCallbackTarget(gbp) != NO_ERROR) { + jniThrowException(env, "java/io/IOException", "setPreviewCallbackTarget failed"); + } +} + static void android_hardware_Camera_startPreview(JNIEnv *env, jobject thiz) { ALOGV("startPreview"); @@ -881,6 +905,9 @@ static JNINativeMethod camMethods[] = { { "setPreviewTexture", "(Landroid/graphics/SurfaceTexture;)V", (void *)android_hardware_Camera_setPreviewTexture }, + { "setPreviewCallbackSurface", + "(Landroid/view/Surface;)V", + (void *)android_hardware_Camera_setPreviewCallbackSurface }, { "startPreview", "()V", (void *)android_hardware_Camera_startPreview }, |