diff options
author | Zhijun He <zhijunhe@google.com> | 2015-05-06 10:08:37 -0700 |
---|---|---|
committer | Zhijun He <zhijunhe@google.com> | 2015-05-06 12:14:36 -0700 |
commit | 7c3997d96a2571295a97457264832d54b05ee966 (patch) | |
tree | 932a3d2b2b52b423d7ad56698a40656ea9de4dfc /media/jni | |
parent | 71b0cb043f410d7f0a7852b2f297124fa9aed0e2 (diff) | |
download | frameworks_base-7c3997d96a2571295a97457264832d54b05ee966.zip frameworks_base-7c3997d96a2571295a97457264832d54b05ee966.tar.gz frameworks_base-7c3997d96a2571295a97457264832d54b05ee966.tar.bz2 |
ImageReader: Image getFormat should return the Image buffer format
Also return buffer size correctly.
Bug: 19527410
Change-Id: I9a912afc61d577571c1b2a7f6df21da40838e925
Diffstat (limited to 'media/jni')
-rw-r--r-- | media/jni/android_media_ImageReader.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index 043e20b..49614bd 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -1222,6 +1222,19 @@ static jint Image_getHeight(JNIEnv* env, jobject thiz, jint format) } } +static jint Image_getFormat(JNIEnv* env, jobject thiz, jint readerFormat) +{ + if (isFormatOpaque(readerFormat)) { + // Assuming opaque reader produce opaque images. + return static_cast<jint>(PublicFormat::PRIVATE); + } else { + CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz); + PublicFormat publicFmt = android_view_Surface_mapHalFormatDataspaceToPublicFormat( + buffer->flexFormat, buffer->dataSpace); + return static_cast<jint>(publicFmt); + } +} + } // extern "C" // ---------------------------------------------------------------------------- @@ -1240,8 +1253,9 @@ static JNINativeMethod gImageMethods[] = { {"nativeImageGetBuffer", "(II)Ljava/nio/ByteBuffer;", (void*)Image_getByteBuffer }, {"nativeCreatePlane", "(II)Landroid/media/ImageReader$SurfaceImage$SurfacePlane;", (void*)Image_createSurfacePlane }, - {"nativeGetWidth", "(I)I", (void*)Image_getWidth }, - {"nativeGetHeight", "(I)I", (void*)Image_getHeight }, + {"nativeGetWidth", "(I)I", (void*)Image_getWidth }, + {"nativeGetHeight", "(I)I", (void*)Image_getHeight }, + {"nativeGetFormat", "(I)I", (void*)Image_getFormat }, }; int register_android_media_ImageReader(JNIEnv *env) { |