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

[Android] Stop calling eglSwapBuffers immediately. #3076

Merged
merged 1 commit into from
Apr 30, 2024
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
5 changes: 5 additions & 0 deletions starboard/android/shared/android_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
namespace starboard {
namespace android {
namespace shared {

atomic_bool g_block_swapbuffers;

namespace {

using ::starboard::shared::starboard::CommandLine;
Expand Down Expand Up @@ -314,13 +317,15 @@ void OnWindowFocusChanged(GameActivity* activity, bool focused) {
}

void OnNativeWindowCreated(GameActivity* activity, ANativeWindow* window) {
g_block_swapbuffers.store(false);
if (g_app_running.load()) {
ApplicationAndroid::Get()->SendAndroidCommand(
AndroidCommand::kNativeWindowCreated, window);
}
}

void OnNativeWindowDestroyed(GameActivity* activity, ANativeWindow* window) {
g_block_swapbuffers.store(true);
if (g_app_running.load()) {
ApplicationAndroid::Get()->SendAndroidCommand(
AndroidCommand::kNativeWindowDestroyed);
Expand Down
11 changes: 11 additions & 0 deletions starboard/android/shared/egl_swap_buffers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@
#include <GLES2/gl2.h>

#include "starboard/android/shared/video_window.h"
#include "starboard/common/atomic.h"
#include "starboard/shared/gles/gl_call.h"

namespace starboard {
namespace android {
namespace shared {
extern atomic_bool g_block_swapbuffers;
} // namespace shared
} // namespace android
} // namespace starboard

extern "C" {
EGLBoolean __real_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);

// This needs to be exported to ensure shared_library targets include it.
SB_EXPORT_PLATFORM EGLBoolean __wrap_eglSwapBuffers(EGLDisplay dpy,
EGLSurface surface) {
if (starboard::android::shared::g_block_swapbuffers.load())
return;
// Kick off the GPU while waiting for new player bounds to take effect.
GL_CALL(glFlush());

Expand Down
Loading