Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2] Update the naming scheme for the GodotPlugin's methods #37175

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions platform/android/java/lib/src/org/godotengine/godot/Godot.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
};

/**
* Invoked on the GL thread when the Godot main loop has started.
* Invoked on the render thread when the Godot main loop has started.
*/
@CallSuper
protected void onGLGodotMainLoopStarted() {
protected void onGodotMainLoopStarted() {
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onGLGodotMainLoopStarted();
plugin.onGodotMainLoopStarted();
}
}

Expand Down Expand Up @@ -343,7 +343,7 @@ public void run() {

// Must occur after GodotLib.setup has completed.
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onGLRegisterPluginWithGodotNative();
plugin.onRegisterPluginWithGodotNative();
}

setKeepScreenOn("True".equals(GodotLib.getGlobal("display/window/energy_saving/keep_screen_on")));
Expand Down Expand Up @@ -912,11 +912,11 @@ public void run() {
}

/**
* Queue a runnable to be run on the GL thread.
* Queue a runnable to be run on the render thread.
* <p>
* This must be called after the GL thread has started.
* This must be called after the render thread has started.
*/
public final void runOnGLThread(@NonNull Runnable action) {
public final void runOnRenderThread(@NonNull Runnable action) {
if (mView != null) {
mView.queueEvent(action);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ protected Godot getGodot() {

/**
* Register the plugin with Godot native code.
*
* This method is invoked on the render thread.
*/
public final void onGLRegisterPluginWithGodotNative() {
public final void onRegisterPluginWithGodotNative() {
nativeRegisterSingleton(getPluginName(), this);

Class clazz = getClass();
Expand Down Expand Up @@ -169,9 +171,9 @@ public void onMainDestroy() {}
public boolean onMainBackPressed() { return false; }

/**
* Invoked on the GL thread when the Godot main loop has started.
* Invoked on the render thread when the Godot main loop has started.
*/
public void onGLGodotMainLoopStarted() {}
public void onGodotMainLoopStarted() {}

/**
* Invoked once per frame on the GL thread after the frame is drawn.
Expand Down Expand Up @@ -225,12 +227,12 @@ protected void runOnUiThread(Runnable action) {
}

/**
* Queue the specified action to be run on the GL thread.
* Queue the specified action to be run on the render thread.
*
* @param action the action to run on the GL thread
* @param action the action to run on the render thread
*/
protected void runOnGLThread(Runnable action) {
godot.runOnGLThread(action);
protected void runOnRenderThread(Runnable action) {
godot.runOnRenderThread(action);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion platform/android/java_godot_lib_jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jcl
}

os_android->main_loop_begin();
godot_java->on_gl_godot_main_loop_started(env);
godot_java->on_godot_main_loop_started(env);
++step;
}

Expand Down
8 changes: 4 additions & 4 deletions platform/android/java_godot_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_godot_instance) {
_is_activity_resumed = p_env->GetMethodID(cls, "isActivityResumed", "()Z");
_vibrate = p_env->GetMethodID(cls, "vibrate", "(I)V");
_get_input_fallback_mapping = p_env->GetMethodID(cls, "getInputFallbackMapping", "()Ljava/lang/String;");
_on_gl_godot_main_loop_started = p_env->GetMethodID(cls, "onGLGodotMainLoopStarted", "()V");
_on_godot_main_loop_started = p_env->GetMethodID(cls, "onGodotMainLoopStarted", "()V");
}

GodotJavaWrapper::~GodotJavaWrapper() {
Expand Down Expand Up @@ -115,13 +115,13 @@ void GodotJavaWrapper::on_video_init(JNIEnv *p_env) {
p_env->CallVoidMethod(godot_instance, _on_video_init);
}

void GodotJavaWrapper::on_gl_godot_main_loop_started(JNIEnv *p_env) {
if (_on_gl_godot_main_loop_started) {
void GodotJavaWrapper::on_godot_main_loop_started(JNIEnv *p_env) {
if (_on_godot_main_loop_started) {
if (p_env == NULL) {
p_env = ThreadAndroid::get_env();
}
}
p_env->CallVoidMethod(godot_instance, _on_gl_godot_main_loop_started);
p_env->CallVoidMethod(godot_instance, _on_godot_main_loop_started);
}

void GodotJavaWrapper::restart(JNIEnv *p_env) {
Expand Down
4 changes: 2 additions & 2 deletions platform/android/java_godot_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class GodotJavaWrapper {
jmethodID _is_activity_resumed = 0;
jmethodID _vibrate = 0;
jmethodID _get_input_fallback_mapping = 0;
jmethodID _on_gl_godot_main_loop_started = 0;
jmethodID _on_godot_main_loop_started = 0;

public:
GodotJavaWrapper(JNIEnv *p_env, jobject p_godot_instance);
Expand All @@ -74,7 +74,7 @@ class GodotJavaWrapper {

void gfx_init(bool gl2);
void on_video_init(JNIEnv *p_env = NULL);
void on_gl_godot_main_loop_started(JNIEnv *p_env = NULL);
void on_godot_main_loop_started(JNIEnv *p_env = NULL);
void restart(JNIEnv *p_env = NULL);
void force_quit(JNIEnv *p_env = NULL);
void set_keep_screen_on(bool p_enabled);
Expand Down