2929#define ANDROID_SHELL_HOLDER \
3030 (reinterpret_cast <AndroidShellHolder*>(shell_holder))
3131
32+ #define SURFACE_TEXTURE_LOCAL_REF \
33+ (std::any_cast<fml::jni::JavaObjectWeakGlobalRef>(surface_texture))
34+
3235namespace flutter {
3336
3437namespace {
@@ -750,7 +753,11 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
750753
751754PlatformViewAndroidJNIImpl::PlatformViewAndroidJNIImpl (
752755 fml::jni::JavaObjectWeakGlobalRef java_object)
753- : java_object_(java_object) {}
756+ : java_object_(java_object) {
757+ // FML_LOG(ERROR) << b;
758+
759+ // surface_texture_ = any_cast<fml::jni::JavaObjectWeakGlobalRef>(test_);
760+ }
754761
755762PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl () = default ;
756763
@@ -886,37 +893,35 @@ void PlatformViewAndroidJNIImpl::FlutterViewOnPreEngineRestart() {
886893 FML_CHECK (CheckException (env));
887894}
888895
889- void PlatformViewAndroidJNIImpl::SetCurrentSurfaceTexture (
890- fml::jni::JavaObjectWeakGlobalRef& surface_texture) {
891- surface_texture_ = surface_texture;
892- }
893-
894896void PlatformViewAndroidJNIImpl::SurfaceTextureAttachToGLContext (
897+ std::any surface_texture,
895898 int textureId) {
896899 JNIEnv* env = fml::jni::AttachCurrentThread ();
897900
898- fml::jni::ScopedJavaLocalRef<jobject> surface_texture =
899- surface_texture_ .get (env);
900- if (surface_texture .is_null ()) {
901+ fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
902+ SURFACE_TEXTURE_LOCAL_REF .get (env);
903+ if (surface_texture_local_ref .is_null ()) {
901904 return ;
902905 }
903906
904- env->CallVoidMethod (surface_texture .obj (), g_attach_to_gl_context_method ,
905- textureId);
907+ env->CallVoidMethod (surface_texture_local_ref .obj (),
908+ g_attach_to_gl_context_method, textureId);
906909
907910 FML_CHECK (CheckException (env));
908911}
909912
910- void PlatformViewAndroidJNIImpl::SurfaceTextureUpdateTexImage () {
913+ void PlatformViewAndroidJNIImpl::SurfaceTextureUpdateTexImage (
914+ std::any surface_texture) {
911915 JNIEnv* env = fml::jni::AttachCurrentThread ();
912916
913- fml::jni::ScopedJavaLocalRef<jobject> surface_texture =
914- surface_texture_ .get (env);
915- if (surface_texture .is_null ()) {
917+ fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
918+ SURFACE_TEXTURE_LOCAL_REF .get (env);
919+ if (surface_texture_local_ref .is_null ()) {
916920 return ;
917921 }
918922
919- env->CallVoidMethod (surface_texture.obj (), g_update_tex_image_method);
923+ env->CallVoidMethod (surface_texture_local_ref.obj (),
924+ g_update_tex_image_method);
920925
921926 FML_CHECK (CheckException (env));
922927}
@@ -934,20 +939,21 @@ SkSize ScaleToFill(float scaleX, float scaleY) {
934939}
935940
936941void PlatformViewAndroidJNIImpl::SurfaceTextureGetTransformMatrix (
942+ std::any surface_texture,
937943 SkMatrix& transform) {
938944 JNIEnv* env = fml::jni::AttachCurrentThread ();
939945
940- fml::jni::ScopedJavaLocalRef<jobject> surface_texture =
941- surface_texture_ .get (env);
942- if (surface_texture .is_null ()) {
946+ fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
947+ SURFACE_TEXTURE_LOCAL_REF .get (env);
948+ if (surface_texture_local_ref .is_null ()) {
943949 return ;
944950 }
945951
946952 fml::jni::ScopedJavaLocalRef<jfloatArray> transformMatrix (
947953 env, env->NewFloatArray (16 ));
948954
949- env->CallVoidMethod (surface_texture .obj (), g_get_transform_matrix_method ,
950- transformMatrix.obj ());
955+ env->CallVoidMethod (surface_texture_local_ref .obj (),
956+ g_get_transform_matrix_method, transformMatrix.obj ());
951957 FML_CHECK (CheckException (env));
952958
953959 float * m = env->GetFloatArrayElements (transformMatrix.obj (), nullptr );
@@ -962,16 +968,18 @@ void PlatformViewAndroidJNIImpl::SurfaceTextureGetTransformMatrix(
962968 transform.set9 (matrix3);
963969}
964970
965- void PlatformViewAndroidJNIImpl::SurfaceTextureDetachFromGLContext () {
971+ void PlatformViewAndroidJNIImpl::SurfaceTextureDetachFromGLContext (
972+ std::any surface_texture) {
966973 JNIEnv* env = fml::jni::AttachCurrentThread ();
967974
968- fml::jni::ScopedJavaLocalRef<jobject> surface_texture =
969- surface_texture_ .get (env);
970- if (surface_texture .is_null ()) {
975+ fml::jni::ScopedJavaLocalRef<jobject> surface_texture_local_ref =
976+ SURFACE_TEXTURE_LOCAL_REF .get (env);
977+ if (surface_texture_local_ref .is_null ()) {
971978 return ;
972979 }
973980
974- env->CallVoidMethod (surface_texture.obj (), g_detach_from_gl_context_method);
981+ env->CallVoidMethod (surface_texture_local_ref.obj (),
982+ g_detach_from_gl_context_method);
975983
976984 FML_CHECK (CheckException (env));
977985}
0 commit comments