Loading media/java/android/media/ImageReader.java +9 −8 Original line number Diff line number Diff line Loading @@ -655,26 +655,26 @@ public class ImageReader implements AutoCloseable { @Override public int getFormat() { throwISEIfImageIsInvalid(); int readerFormat = ImageReader.this.getImageFormat(); // Assume opaque reader always produce opaque images. mFormat = (readerFormat == ImageFormat.PRIVATE) ? readerFormat : nativeGetFormat(readerFormat); return mFormat; } @Override public int getWidth() { throwISEIfImageIsInvalid(); if (mWidth == -1) { mWidth = (getFormat() == ImageFormat.JPEG) ? ImageReader.this.getWidth() : nativeGetWidth(mFormat); } return mWidth; } @Override public int getHeight() { throwISEIfImageIsInvalid(); if (mHeight == -1) { mHeight = (getFormat() == ImageFormat.JPEG) ? ImageReader.this.getHeight() : nativeGetHeight(mFormat); } return mHeight; } Loading Loading @@ -822,6 +822,7 @@ public class ImageReader implements AutoCloseable { private synchronized native SurfacePlane nativeCreatePlane(int idx, int readerFormat); private synchronized native int nativeGetWidth(int format); private synchronized native int nativeGetHeight(int format); private synchronized native int nativeGetFormat(int readerFormat); } private synchronized native void nativeInit(Object weakSelf, int w, int h, Loading media/jni/android_media_ImageReader.cpp +16 −2 Original line number Diff line number Diff line Loading @@ -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" // ---------------------------------------------------------------------------- Loading @@ -1242,6 +1255,7 @@ static JNINativeMethod gImageMethods[] = { (void*)Image_createSurfacePlane }, {"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) { Loading Loading
media/java/android/media/ImageReader.java +9 −8 Original line number Diff line number Diff line Loading @@ -655,26 +655,26 @@ public class ImageReader implements AutoCloseable { @Override public int getFormat() { throwISEIfImageIsInvalid(); int readerFormat = ImageReader.this.getImageFormat(); // Assume opaque reader always produce opaque images. mFormat = (readerFormat == ImageFormat.PRIVATE) ? readerFormat : nativeGetFormat(readerFormat); return mFormat; } @Override public int getWidth() { throwISEIfImageIsInvalid(); if (mWidth == -1) { mWidth = (getFormat() == ImageFormat.JPEG) ? ImageReader.this.getWidth() : nativeGetWidth(mFormat); } return mWidth; } @Override public int getHeight() { throwISEIfImageIsInvalid(); if (mHeight == -1) { mHeight = (getFormat() == ImageFormat.JPEG) ? ImageReader.this.getHeight() : nativeGetHeight(mFormat); } return mHeight; } Loading Loading @@ -822,6 +822,7 @@ public class ImageReader implements AutoCloseable { private synchronized native SurfacePlane nativeCreatePlane(int idx, int readerFormat); private synchronized native int nativeGetWidth(int format); private synchronized native int nativeGetHeight(int format); private synchronized native int nativeGetFormat(int readerFormat); } private synchronized native void nativeInit(Object weakSelf, int w, int h, Loading
media/jni/android_media_ImageReader.cpp +16 −2 Original line number Diff line number Diff line Loading @@ -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" // ---------------------------------------------------------------------------- Loading @@ -1242,6 +1255,7 @@ static JNINativeMethod gImageMethods[] = { (void*)Image_createSurfacePlane }, {"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) { Loading