Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit de1467a

Browse files
committed
migrate to interface
1 parent 07b0520 commit de1467a

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

shell/platform/android/jni/platform_view_android_jni.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ class PlatformViewAndroidJNI {
130130
int y,
131131
int width,
132132
int height) = 0;
133+
//----------------------------------------------------------------------------
134+
/// @brief Initiates the initialization of a frame if using hybrid
135+
/// composition.
136+
///
137+
/// @note Must be called from the platform thread.
138+
///
139+
virtual void FlutterViewBeginFrame() = 0;
133140
};
134141

135142
} // namespace flutter

shell/platform/android/platform_view_android_jni_impl.cc

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ static jmethodID g_update_custom_accessibility_actions_method = nullptr;
7979
static jmethodID g_on_first_frame_method = nullptr;
8080

8181
static jmethodID g_on_engine_restart_method = nullptr;
82-
void FlutterViewOnPreEngineRestart(JNIEnv* env, jobject obj) {
83-
env->CallVoidMethod(obj, g_on_engine_restart_method);
84-
FML_CHECK(CheckException(env));
85-
}
8682

8783
static jmethodID g_on_begin_frame_method = nullptr;
8884
void FlutterViewBeginFrame(JNIEnv* env, jobject obj) {
@@ -720,8 +716,16 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
720716
return false;
721717
}
722718

719+
g_on_display_platform_view_method = env->GetMethodID(
720+
g_flutter_jni_class->obj(), "onDisplayPlatformView", "(IIIII)V");
721+
722+
if (g_on_display_platform_view_method == nullptr) {
723+
FML_LOG(ERROR) << "Could not locate onDisplayPlatformView method";
724+
return false;
725+
}
726+
723727
g_on_begin_frame_method =
724-
env->GetMethodID(g_flutter_jni_class->obj(), "onBeginFrame", "()V");
728+
env->GetMethodID(g_flutter_jni_class->obj(), "onBeginFrame", "()V");
725729

726730
if (g_on_begin_frame_method == nullptr) {
727731
FML_LOG(ERROR) << "Could not locate onBeginFrame method";
@@ -1044,4 +1048,17 @@ void PlatformViewAndroidJNIImpl::FlutterViewDisplayOverlaySurface(
10441048
FML_CHECK(CheckException(env));
10451049
}
10461050

1051+
void PlatformViewAndroidJNIImpl::FlutterViewBeginFrame() {
1052+
JNIEnv* env = fml::jni::AttachCurrentThread();
1053+
1054+
auto java_object = java_object_.get(env);
1055+
if (java_object.is_null()) {
1056+
return;
1057+
}
1058+
1059+
env->CallVoidMethod(java_object.obj(), g_on_begin_frame_method);
1060+
1061+
FML_CHECK(CheckException(env));
1062+
}
1063+
10471064
} // namespace flutter

shell/platform/android/platform_view_android_jni_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class PlatformViewAndroidJNIImpl final : public PlatformViewAndroidJNI {
6262
int width,
6363
int height) override;
6464

65+
void FlutterViewBeginFrame() override;
66+
67+
6568
private:
6669
// Reference to FlutterJNI object.
6770
const fml::jni::JavaObjectWeakGlobalRef java_object_;

0 commit comments

Comments
 (0)