Skip to content

Commit

Permalink
Merge pull request godotengine#93571 from Alex2782/g3.x_fix_GLSurface…
Browse files Browse the repository at this point in the history
…View

[3.x] Fix lost old callback when continuous call `requestRenderAndNotify`
  • Loading branch information
lawnjelly authored Jul 18, 2024
2 parents 863ab17 + e482dcb commit 9a6b424
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ public void destroySurface(EGL10 egl, EGLDisplay display,
*/
public interface EGLConfigChooser {
/**
* Choose a configuration from the list. Implementors typically
* Choose a configuration from the list. Implementers typically
* implement this method by calling
* {@link EGL10#eglChooseConfig} and iterating through the results. Please consult the
* EGL specification available from The Khronos Group to learn how to call eglChooseConfig.
Expand Down Expand Up @@ -1673,7 +1673,24 @@ public void requestRenderAndNotify(Runnable finishDrawing) {
mWantRenderNotification = true;
mRequestRender = true;
mRenderComplete = false;
mFinishDrawingRunnable = finishDrawing;

// fix lost old callback when continuous call requestRenderAndNotify
//
// If continuous call requestRenderAndNotify before trigger old
// callback, old callback will lose, cause VRI will wait for SV's
// draw to finish forever not calling finishDraw.
// https://android.googlesource.com/platform/frameworks/base/+/044fce0b826f2da3a192aac56785b5089143e693%5E%21/
//+++++++++++++++++++++++++++++++++++++++++++++++++++
final Runnable oldCallback = mFinishDrawingRunnable;
mFinishDrawingRunnable = () -> {
if (oldCallback != null) {
oldCallback.run();
}
if (finishDrawing != null) {
finishDrawing.run();
}
};
//----------------------------------------------------

sGLThreadManager.notifyAll();
}
Expand Down Expand Up @@ -1938,4 +1955,3 @@ public void releaseEglContextLocked(GLThread thread) {
private int mEGLContextClientVersion;
private boolean mPreserveEGLContextOnPause;
}

0 comments on commit 9a6b424

Please sign in to comment.