diff --git a/starboard/android/shared/android_main.cc b/starboard/android/shared/android_main.cc index ce7e75ae9ea3..514bc8d28f39 100644 --- a/starboard/android/shared/android_main.cc +++ b/starboard/android/shared/android_main.cc @@ -38,6 +38,9 @@ namespace starboard { namespace android { namespace shared { + +atomic_bool g_block_swapbuffers; + namespace { using ::starboard::shared::starboard::CommandLine; @@ -314,6 +317,7 @@ 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); @@ -321,6 +325,7 @@ void OnNativeWindowCreated(GameActivity* activity, ANativeWindow* window) { } void OnNativeWindowDestroyed(GameActivity* activity, ANativeWindow* window) { + g_block_swapbuffers.store(true); if (g_app_running.load()) { ApplicationAndroid::Get()->SendAndroidCommand( AndroidCommand::kNativeWindowDestroyed); diff --git a/starboard/android/shared/egl_swap_buffers.cc b/starboard/android/shared/egl_swap_buffers.cc index ed9d8fc1b259..8cc824127f3b 100644 --- a/starboard/android/shared/egl_swap_buffers.cc +++ b/starboard/android/shared/egl_swap_buffers.cc @@ -16,14 +16,25 @@ #include #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());