Lines Matching defs:env
86 JNIImageReaderContext(JNIEnv* env, jobject weakThiz, jclass clazz, int maxImages);
138 JNIImageReaderContext::JNIImageReaderContext(JNIEnv* env,
140 mWeakThiz(env->NewGlobalRef(weakThiz)),
141 mClazz((jclass)env->NewGlobalRef(clazz)) {
153 JNIEnv* env = AndroidRuntime::getJNIEnv();
154 if (env == NULL) {
157 int result = vm->AttachCurrentThread(&env, (void*) &args);
164 return env;
207 JNIEnv* env = getJNIEnv(&needsDetach);
208 if (env != NULL) {
209 env->DeleteGlobalRef(mWeakThiz);
210 env->DeleteGlobalRef(mClazz);
243 JNIEnv* env = getJNIEnv(&needsDetach);
244 if (env != NULL) {
245 env->CallStaticVoidMethod(mClazz, gImageReaderClassInfo.postEventFromNative, mWeakThiz);
263 static JNIImageReaderContext* ImageReader_getContext(JNIEnv* env, jobject thiz)
267 (env->GetLongField(thiz, gImageReaderClassInfo.mNativeContext));
271 static CpuConsumer* ImageReader_getCpuConsumer(JNIEnv* env, jobject thiz)
274 JNIImageReaderContext* const ctx = ImageReader_getContext(env, thiz);
276 jniThrowRuntimeException(env, "ImageReaderContext is not initialized");
281 jniThrowException(env, "java/lang/IllegalStateException",
289 static IGraphicBufferProducer* ImageReader_getProducer(JNIEnv* env, jobject thiz)
292 JNIImageReaderContext* const ctx = ImageReader_getContext(env, thiz);
294 jniThrowRuntimeException(env, "ImageReaderContext is not initialized");
301 static void ImageReader_setNativeContext(JNIEnv* env,
305 JNIImageReaderContext* const p = ImageReader_getContext(env, thiz);
312 env->SetLongField(thiz, gImageReaderClassInfo.mNativeContext,
316 static CpuConsumer::LockedBuffer* Image_getLockedBuffer(JNIEnv* env, jobject image)
319 env->GetLongField(image, gSurfaceImageClassInfo.mNativeBuffer));
322 static void Image_setBuffer(JNIEnv* env, jobject thiz,
325 env->SetLongField(thiz, gSurfaceImageClassInfo.mNativeBuffer, reinterpret_cast<jlong>(buffer));
328 static void Image_setOpaqueBuffer(JNIEnv* env, jobject thiz,
331 env->SetLongField(thiz, gSurfaceImageClassInfo.mNativeBuffer, reinterpret_cast<jlong>(buffer));
383 static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* buffer, int idx,
534 jniThrowExceptionFmt(env, "java/lang/UnsupportedOperationException",
543 static jint Image_imageGetPixelStride(JNIEnv* env, CpuConsumer::LockedBuffer* buffer, int idx,
597 jniThrowExceptionFmt(env, "java/lang/UnsupportedOperationException",
605 static jint Image_imageGetRowStride(JNIEnv* env, CpuConsumer::LockedBuffer* buffer, int idx,
674 jniThrowException(env, "java/lang/UnsupportedOperationException",
702 static BufferItemConsumer* ImageReader_getOpaqueConsumer(JNIEnv* env, jobject thiz)
705 JNIImageReaderContext* const ctx = ImageReader_getContext(env, thiz);
707 jniThrowRuntimeException(env, "ImageReaderContext is not initialized");
712 jniThrowException(env, "java/lang/IllegalStateException",
719 static BufferItem* Image_getOpaqueBuffer(JNIEnv* env, jobject image)
722 env->GetLongField(image, gSurfaceImageClassInfo.mNativeBuffer));
748 static void ImageReader_classInit(JNIEnv* env, jclass clazz)
752 jclass imageClazz = env->FindClass("android/media/ImageReader$SurfaceImage");
755 gSurfaceImageClassInfo.mNativeBuffer = env->GetFieldID(
761 gSurfaceImageClassInfo.mTimestamp = env->GetFieldID(
767 gImageReaderClassInfo.mNativeContext = env->GetFieldID(
773 gImageReaderClassInfo.postEventFromNative = env->GetStaticMethodID(
778 jclass planeClazz = env->FindClass("android/media/ImageReader$SurfaceImage$SurfacePlane");
781 gSurfacePlaneClassInfo.clazz = (jclass) env->NewGlobalRef(planeClazz);
782 gSurfacePlaneClassInfo.ctor = env->GetMethodID(gSurfacePlaneClassInfo.clazz, "<init>",
788 static void ImageReader_init(JNIEnv* env, jobject thiz, jobject weakThiz,
804 jclass clazz = env->GetObjectClass(thiz);
806 jniThrowRuntimeException(env, "Can't find android/graphics/ImageReader");
809 sp<JNIImageReaderContext> ctx(new JNIImageReaderContext(env, weakThiz, clazz, maxImages));
827 jniThrowRuntimeException(env, "Failed to allocate native opaque consumer");
837 jniThrowRuntimeException(env, "Failed to allocate native CpuConsumer");
847 ImageReader_setNativeContext(env, thiz, ctx);
858 jniThrowException(env, "java/lang/IllegalStateException",
864 jniThrowException(env, "java/lang/IllegalStateException",
869 jniThrowException(env, "java/lang/IllegalStateException",
875 jniThrowException(env, "java/lang/IllegalStateException",
881 jniThrowException(env, "java/lang/IllegalStateException",
886 jniThrowException(env, "java/lang/IllegalStateException",
892 static void ImageReader_close(JNIEnv* env, jobject thiz)
896 JNIImageReaderContext* const ctx = ImageReader_getContext(env, thiz);
904 consumer = ImageReader_getOpaqueConsumer(env, thiz);
906 consumer = ImageReader_getCpuConsumer(env, thiz);
913 ImageReader_setNativeContext(env, thiz, NULL);
916 static void ImageReader_imageRelease(JNIEnv* env, jobject thiz, jobject image)
919 JNIImageReaderContext* ctx = ImageReader_getContext(env, thiz);
927 BufferItem* opaqueBuffer = Image_getOpaqueBuffer(env, image);
929 Image_setOpaqueBuffer(env, image, NULL);
934 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, image);
940 Image_setBuffer(env, image, NULL);
946 static jint ImageReader_opaqueImageSetup(JNIEnv* env, JNIImageReaderContext* ctx, jobject image) {
949 jniThrowRuntimeException(env, "ImageReaderContext is not initialized");
977 Image_setOpaqueBuffer(env, image, buffer);
978 env->SetLongField(image, gSurfaceImageClassInfo.mTimestamp,
984 static jint ImageReader_lockedImageSetup(JNIEnv* env, JNIImageReaderContext* ctx, jobject image) {
1001 jniThrowExceptionFmt(env, "java/lang/AssertionError",
1010 jniThrowException(env, "java/lang/UnsupportedOperationException",
1019 jniThrowExceptionFmt(env, "java/lang/UnsupportedOperationException",
1064 jniThrowException(env, "java/lang/UnsupportedOperationException",
1070 Image_setBuffer(env, image, buffer);
1071 env->SetLongField(image, gSurfaceImageClassInfo.mTimestamp,
1077 static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, jobject image) {
1079 JNIImageReaderContext* ctx = ImageReader_getContext(env, thiz);
1081 jniThrowRuntimeException(env, "ImageReaderContext is not initialized");
1086 return ImageReader_opaqueImageSetup(env, ctx, image);
1088 return ImageReader_lockedImageSetup(env, ctx, image);
1092 static jint ImageReader_detachImage(JNIEnv* env, jobject thiz, jobject image) {
1094 JNIImageReaderContext* ctx = ImageReader_getContext(env, thiz);
1096 jniThrowException(env, "java/lang/IllegalStateException", "ImageReader was already closed");
1103 jniThrowRuntimeException(env,
1109 BufferItem* opaqueBuffer = Image_getOpaqueBuffer(env, image);
1113 jniThrowException(env, "java/lang/IllegalStateException",
1121 jniThrowRuntimeException(env,
1128 static jobject ImageReader_getSurface(JNIEnv* env, jobject thiz)
1132 IGraphicBufferProducer* gbp = ImageReader_getProducer(env, thiz);
1134 jniThrowRuntimeException(env, "CpuConsumer is uninitialized");
1139 return android_view_Surface_createFromIGraphicBufferProducer(env, gbp);
1142 static jobject Image_createSurfacePlane(JNIEnv* env, jobject thiz, int idx, int readerFormat)
1151 jniThrowException(env, "java/lang/IllegalStateException",
1156 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
1160 jniThrowException(env, "java/lang/IllegalStateException", "Image was released");
1163 rowStride = Image_imageGetRowStride(env, buffer, idx, halReaderFormat);
1164 pixelStride = Image_imageGetPixelStride(env, buffer, idx, halReaderFormat);
1166 jobject surfPlaneObj = env->NewObject(gSurfacePlaneClassInfo.clazz,
1172 static jobject Image_getByteBuffer(JNIEnv* env, jobject thiz, int idx, int readerFormat)
1184 jniThrowException(env, "java/lang/IllegalStateException",
1189 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
1192 jniThrowException(env, "java/lang/IllegalStateException", "Image was released");
1196 Image_getLockedBufferInfo(env, buffer, idx, &base, &size, readerHalFormat);
1200 jniThrowExceptionFmt(env, "java/lang/IllegalStateException",
1205 byteBuffer = env->NewDirectByteBuffer(base, size);
1207 if ((byteBuffer == NULL) && (env->ExceptionCheck() == false)) {
1208 jniThrowException(env, "java/lang/IllegalStateException", "Failed to allocate ByteBuffer");
1214 static jint Image_getWidth(JNIEnv* env, jobject thiz, jint format)
1217 BufferItem* opaqueBuffer = Image_getOpaqueBuffer(env, thiz);
1220 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
1225 static jint Image_getHeight(JNIEnv* env, jobject thiz, jint format)
1228 BufferItem* opaqueBuffer = Image_getOpaqueBuffer(env, thiz);
1231 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
1236 static jint Image_getFormat(JNIEnv* env, jobject thiz, jint readerFormat)
1242 CpuConsumer::LockedBuffer* buffer = Image_getLockedBuffer(env, thiz);
1275 int register_android_media_ImageReader(JNIEnv *env) {
1277 int ret1 = AndroidRuntime::registerNativeMethods(env,
1280 int ret2 = AndroidRuntime::registerNativeMethods(env,