mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
Add RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER
This commit is contained in:
parent
0d5c928e68
commit
6286e4b74c
@ -1499,7 +1499,7 @@ bool event_command(enum event_command cmd)
|
|||||||
event_command(EVENT_CMD_AUDIO_STOP);
|
event_command(EVENT_CMD_AUDIO_STOP);
|
||||||
|
|
||||||
if (settings->video.black_frame_insertion)
|
if (settings->video.black_frame_insertion)
|
||||||
video_driver_cached_frame();
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2950,7 +2950,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
video_driver_cached_frame();
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
|
|
||||||
dst = buffer;
|
dst = buffer;
|
||||||
src = (const uint8_t*)gl->readback_buffer_screenshot;
|
src = (const uint8_t*)gl->readback_buffer_screenshot;
|
||||||
|
@ -627,7 +627,7 @@ static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer)
|
|||||||
rarch_perf_init(&sdl2_gfx_read_viewport, "sdl2_gfx_read_viewport");
|
rarch_perf_init(&sdl2_gfx_read_viewport, "sdl2_gfx_read_viewport");
|
||||||
retro_perf_start(&sdl2_gfx_read_viewport);
|
retro_perf_start(&sdl2_gfx_read_viewport);
|
||||||
|
|
||||||
video_driver_cached_frame();
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
|
|
||||||
surf = SDL_GetWindowSurface(vid->window);
|
surf = SDL_GetWindowSurface(vid->window);
|
||||||
bgr24 = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_BGR24, 0);
|
bgr24 = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_BGR24, 0);
|
||||||
|
@ -790,39 +790,6 @@ void video_driver_get_video_output_prev(void)
|
|||||||
poke->get_video_output_prev(driver->video_data);
|
poke->get_video_output_prev(driver->video_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* video_driver_cached_frame:
|
|
||||||
*
|
|
||||||
* Renders the current video frame.
|
|
||||||
**/
|
|
||||||
void video_driver_cached_frame(void)
|
|
||||||
{
|
|
||||||
bool is_idle;
|
|
||||||
driver_t *driver = driver_get_ptr();
|
|
||||||
void *recording = driver ? driver->recording_data : NULL;
|
|
||||||
|
|
||||||
rarch_main_ctl(RARCH_MAIN_CTL_IS_IDLE, &is_idle);
|
|
||||||
|
|
||||||
if (is_idle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Cannot allow recording when pushing duped frames. */
|
|
||||||
driver->recording_data = NULL;
|
|
||||||
|
|
||||||
/* Not 100% safe, since the library might have
|
|
||||||
* freed the memory, but no known implementations do this.
|
|
||||||
* It would be really stupid at any rate ...
|
|
||||||
*/
|
|
||||||
if (driver->retro_ctx.frame_cb)
|
|
||||||
driver->retro_ctx.frame_cb(
|
|
||||||
(video_state.frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID)
|
|
||||||
? NULL : video_state.frame_cache.data,
|
|
||||||
video_state.frame_cache.width,
|
|
||||||
video_state.frame_cache.height,
|
|
||||||
video_state.frame_cache.pitch);
|
|
||||||
|
|
||||||
driver->recording_data = recording;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool video_driver_cached_frame_has_valid_fb(void)
|
bool video_driver_cached_frame_has_valid_fb(void)
|
||||||
{
|
{
|
||||||
@ -1179,11 +1146,49 @@ void video_driver_set_pixel_format(enum retro_pixel_format fmt)
|
|||||||
video_state.pix_fmt = fmt;
|
video_state.pix_fmt = fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* video_driver_cached_frame:
|
||||||
|
*
|
||||||
|
* Renders the current video frame.
|
||||||
|
**/
|
||||||
|
static bool video_driver_cached_frame(void)
|
||||||
|
{
|
||||||
|
bool is_idle;
|
||||||
|
driver_t *driver = driver_get_ptr();
|
||||||
|
void *recording = driver ? driver->recording_data : NULL;
|
||||||
|
|
||||||
|
rarch_main_ctl(RARCH_MAIN_CTL_IS_IDLE, &is_idle);
|
||||||
|
|
||||||
|
if (is_idle)
|
||||||
|
return true; /* Maybe return false here for indication of idleness? */
|
||||||
|
|
||||||
|
/* Cannot allow recording when pushing duped frames. */
|
||||||
|
driver->recording_data = NULL;
|
||||||
|
|
||||||
|
/* Not 100% safe, since the library might have
|
||||||
|
* freed the memory, but no known implementations do this.
|
||||||
|
* It would be really stupid at any rate ...
|
||||||
|
*/
|
||||||
|
if (driver->retro_ctx.frame_cb)
|
||||||
|
driver->retro_ctx.frame_cb(
|
||||||
|
(video_state.frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID)
|
||||||
|
? NULL : video_state.frame_cache.data,
|
||||||
|
video_state.frame_cache.width,
|
||||||
|
video_state.frame_cache.height,
|
||||||
|
video_state.frame_cache.pitch);
|
||||||
|
|
||||||
|
driver->recording_data = recording;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
|
bool video_driver_ctl(enum rarch_display_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
case RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER:
|
||||||
|
return video_driver_cached_frame();
|
||||||
case RARCH_DISPLAY_CTL_IS_FOCUSED:
|
case RARCH_DISPLAY_CTL_IS_FOCUSED:
|
||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
|
@ -225,6 +225,8 @@ enum rarch_display_ctl_state
|
|||||||
RARCH_DISPLAY_CTL_FRAME_FILTER_IS_32BIT,
|
RARCH_DISPLAY_CTL_FRAME_FILTER_IS_32BIT,
|
||||||
RARCH_DISPLAY_CTL_HAS_WINDOWED,
|
RARCH_DISPLAY_CTL_HAS_WINDOWED,
|
||||||
RARCH_DISPLAY_CTL_IS_FOCUSED,
|
RARCH_DISPLAY_CTL_IS_FOCUSED,
|
||||||
|
/* Renders the current video frame. */
|
||||||
|
RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER,
|
||||||
RARCH_DISPLAY_CTL_GET_FRAME_COUNT
|
RARCH_DISPLAY_CTL_GET_FRAME_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -368,13 +370,6 @@ enum retro_pixel_format video_driver_get_pixel_format(void);
|
|||||||
|
|
||||||
void video_driver_set_pixel_format(enum retro_pixel_format fmt);
|
void video_driver_set_pixel_format(enum retro_pixel_format fmt);
|
||||||
|
|
||||||
/**
|
|
||||||
* video_driver_cached_frame:
|
|
||||||
*
|
|
||||||
* Renders the current video frame.
|
|
||||||
**/
|
|
||||||
void video_driver_cached_frame(void);
|
|
||||||
|
|
||||||
void video_driver_cached_frame_set(const void *data, unsigned width,
|
void video_driver_cached_frame_set(const void *data, unsigned width,
|
||||||
unsigned height, size_t pitch);
|
unsigned height, size_t pitch);
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc
|
|||||||
/* We can read safely
|
/* We can read safely
|
||||||
*
|
*
|
||||||
* read_viewport() in GL driver calls
|
* read_viewport() in GL driver calls
|
||||||
* video_driver_cached_frame() to be able to read from
|
* 'cached frame render' to be able to read from
|
||||||
* back buffer.
|
* back buffer.
|
||||||
*
|
*
|
||||||
* This means frame() callback in threaded wrapper will
|
* This means frame() callback in threaded wrapper will
|
||||||
|
@ -324,8 +324,7 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
video_driver_cached_frame();
|
return video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
return true;
|
|
||||||
case MENU_DISPLAY_CTL_SET_WIDTH:
|
case MENU_DISPLAY_CTL_SET_WIDTH:
|
||||||
{
|
{
|
||||||
unsigned *ptr = (unsigned*)data;
|
unsigned *ptr = (unsigned*)data;
|
||||||
|
@ -449,7 +449,7 @@ bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
|
|||||||
if (cmd->fullscreen_toggle)
|
if (cmd->fullscreen_toggle)
|
||||||
{
|
{
|
||||||
event_command(EVENT_CMD_FULLSCREEN_TOGGLE);
|
event_command(EVENT_CMD_FULLSCREEN_TOGGLE);
|
||||||
video_driver_cached_frame();
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check_is_oneshot)
|
if (!check_is_oneshot)
|
||||||
@ -469,7 +469,7 @@ bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (settings->video.black_frame_insertion)
|
if (settings->video.black_frame_insertion)
|
||||||
video_driver_cached_frame();
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
|
|
||||||
if (state_manager_frame_is_reversed())
|
if (state_manager_frame_is_reversed())
|
||||||
rarch_main_msg_queue_push_new(MSG_SLOW_MOTION_REWIND, 0, 30, true);
|
rarch_main_msg_queue_push_new(MSG_SLOW_MOTION_REWIND, 0, 30, true);
|
||||||
|
@ -229,7 +229,7 @@ bool take_screenshot(void)
|
|||||||
video_driver_set_texture_enable(false, false);
|
video_driver_set_texture_enable(false, false);
|
||||||
|
|
||||||
if (driver->video)
|
if (driver->video)
|
||||||
video_driver_cached_frame();
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewport_read)
|
if (viewport_read)
|
||||||
@ -284,7 +284,7 @@ bool take_screenshot(void)
|
|||||||
rarch_main_msg_queue_push(msg, 1, is_paused ? 1 : 180, true);
|
rarch_main_msg_queue_push(msg, 1, is_paused ? 1 : 180, true);
|
||||||
|
|
||||||
if (is_paused)
|
if (is_paused)
|
||||||
video_driver_cached_frame();
|
video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user