Skip to content

Commit

Permalink
Merge pull request #59606 from m4gr3d/fix_low_processor_mode_3x
Browse files Browse the repository at this point in the history
[3.x] Fix flickering issues with low processor mode on Android
  • Loading branch information
akien-mga authored Mar 29, 2022
2 parents 2ad8298 + 8ca32d1 commit 3c0d325
Show file tree
Hide file tree
Showing 19 changed files with 2,548 additions and 41 deletions.
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

0 comments on commit 3c0d325

Please sign in to comment.