Merge pull request #6143 from ToadKing/emscripten-bfi

Enable black frame insertion on Emscripten
This commit is contained in:
Twinaphex 2018-01-20 21:54:47 +01:00 committed by GitHub
commit 84d4822901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

3
.gitignore vendored
View File

@ -140,3 +140,6 @@ retroarch.js
retroarch.js.mem
*.bc
*.wasm
# only ignore .js files in the repo root
/*.js

View File

@ -24,6 +24,8 @@
#include <file/file_path.h>
#include <string/stdstring.h>
#include <retro_timers.h>
#include <gfx/video_frame.h>
#include <glsym/glsym.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
@ -47,6 +49,7 @@
void RWebAudioRecalibrateTime(void);
static unsigned emscripten_fullscreen_reinit;
static unsigned emscripten_frame_count = 0;
static EM_BOOL emscripten_fullscreenchange_cb(int event_type,
const EmscriptenFullscreenChangeEvent *fullscreen_change_event,
@ -63,11 +66,32 @@ static EM_BOOL emscripten_fullscreenchange_cb(int event_type,
static void emscripten_mainloop(void)
{
unsigned sleep_ms = 0;
int ret;
video_frame_info_t video_info;
unsigned sleep_ms = 0;
RWebAudioRecalibrateTime();
emscripten_frame_count++;
video_driver_build_info(&video_info);
/* Disable BFI during fast forward, slow-motion,
* and pause to prevent flicker. */
if (
video_info.black_frame_insertion
&& !video_info.input_driver_nonblock_state
&& !video_info.runloop_is_slowmotion
&& !video_info.runloop_is_paused)
{
if ((emscripten_frame_count & 1) == 0)
{
glClear(GL_COLOR_BUFFER_BIT);
video_info.cb_swap_buffers(video_info.context_data, &video_info);
return;
}
}
if (emscripten_fullscreen_reinit != 0)
{
if (--emscripten_fullscreen_reinit == 0)

View File

@ -1188,6 +1188,8 @@ static bool gl_frame(void *data, const void *frame,
#endif
gl_pbo_async_readback(gl);
/* emscripten has to do black frame insertion in its main loop */
#ifndef EMSCRIPTEN
/* Disable BFI during fast forward, slow-motion,
* and pause to prevent flicker. */
if (
@ -1199,6 +1201,7 @@ static bool gl_frame(void *data, const void *frame,
video_info->cb_swap_buffers(video_info->context_data, video_info);
glClear(GL_COLOR_BUFFER_BIT);
}
#endif
video_info->cb_swap_buffers(video_info->context_data, video_info);