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.x] Fix flickering issues with low processor mode on Android #59606

Merged
merged 1 commit into from
Mar 29, 2022
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
3 changes: 2 additions & 1 deletion core/os/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class OS {
bool low_processor_usage_mode;
int low_processor_usage_mode_sleep_usec;
bool _update_vital_only;
bool _update_pending;
bool _verbose_stdout;
bool _debug_stdout;
String _local_clipboard;
Expand All @@ -77,6 +76,8 @@ class OS {
List<String> restart_commandline;

protected:
bool _update_pending;

void _set_logger(CompositeLogger *p_logger);

public:
Expand Down
4 changes: 4 additions & 0 deletions misc/scripts/clang_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ while IFS= read -rd '' f; do
continue 2
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/input/InputManager"* ]]; then
continue 2
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/GLSurfaceView"* ]]; then
continue 2
elif [[ "$f" == "platform/android/java/lib/src/org/godotengine/godot/gl/EGLLogWrapper"* ]]; then
continue 2
fi
python misc/scripts/copyright_headers.py "$f"
continue 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import android.app.Activity;
import android.hardware.SensorEvent;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

/**
Expand Down Expand Up @@ -66,13 +67,13 @@ public class GodotLib {
* Invoked on the GL thread when the underlying Android surface has changed size.
* @param width
* @param height
* @see android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(GL10, int, int)
* @see org.godotengine.godot.gl.GLSurfaceView.Renderer#onSurfaceChanged(GL10, int, int)
*/
public static native void resize(int width, int height);

/**
* Invoked on the GL thread when the underlying Android surface is created or recreated.
* @see android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)
* @see org.godotengine.godot.gl.GLSurfaceView.Renderer#onSurfaceCreated(GL10, EGLConfig)
*/
public static native void newcontext();

Expand All @@ -83,9 +84,9 @@ public class GodotLib {

/**
* Invoked on the GL thread to draw the current frame.
* @see android.opengl.GLSurfaceView.Renderer#onDrawFrame(GL10)
* @see org.godotengine.godot.gl.GLSurfaceView.Renderer#onDrawFrame(GL10)
*/
public static native void step();
public static native boolean step();

/**
* Forward touch events from the main thread to the GL thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@

package org.godotengine.godot;

import org.godotengine.godot.gl.GLSurfaceView;
import org.godotengine.godot.plugin.GodotPlugin;
import org.godotengine.godot.plugin.GodotPluginRegistry;
import org.godotengine.godot.utils.GLUtils;

import android.opengl.GLSurfaceView;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
Expand All @@ -50,19 +48,21 @@ class GodotRenderer implements GLSurfaceView.Renderer {
this.pluginRegistry = GodotPluginRegistry.getPluginRegistry();
}

public void onDrawFrame(GL10 gl) {
public boolean onDrawFrame(GL10 gl) {
if (activityJustResumed) {
GodotLib.onRendererResumed();
activityJustResumed = false;
}

GodotLib.step();
boolean swapBuffers = GodotLib.step();
for (int i = 0; i < Godot.singleton_count; i++) {
Godot.singletons[i].onGLDrawFrame(gl);
}
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
plugin.onGLDrawFrame(gl);
}

return swapBuffers;
}

public void onSurfaceChanged(GL10 gl, int width, int height) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

package org.godotengine.godot;

import org.godotengine.godot.gl.GLSurfaceView;
import org.godotengine.godot.input.GodotGestureHandler;
import org.godotengine.godot.input.GodotInputHandler;
import org.godotengine.godot.utils.GLUtils;
Expand All @@ -44,7 +45,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
Expand Down
Loading