diff --git a/starboard/android/shared/android_main.cc b/starboard/android/shared/android_main.cc index af76d2dc9977..eb73257ef5f6 100644 --- a/starboard/android/shared/android_main.cc +++ b/starboard/android/shared/android_main.cc @@ -41,6 +41,9 @@ namespace starboard { namespace android { namespace shared { + +atomic_bool g_block_swapbuffers; + namespace { using ::starboard::shared::starboard::CommandLine; @@ -325,6 +328,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); @@ -332,6 +336,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());