Turn macro back into function

This commit is contained in:
twinaphex 2017-05-13 19:37:16 +02:00
parent 17a15273ba
commit b22d7902f1
6 changed files with 43 additions and 30 deletions

View File

@ -1945,7 +1945,8 @@ bool command_event(enum event_command cmd, void *data)
} }
break; break;
case CMD_EVENT_TAKE_SCREENSHOT: case CMD_EVENT_TAKE_SCREENSHOT:
if (!take_screenshot(path_get(RARCH_PATH_BASENAME), false)) if (!take_screenshot(path_get(RARCH_PATH_BASENAME), false,
video_driver_cached_frame_has_valid_framebuffer()))
return false; return false;
break; break;
case CMD_EVENT_UNLOAD_CORE: case CMD_EVENT_UNLOAD_CORE:

View File

@ -132,7 +132,7 @@ static bool video_driver_state_out_rgb32 = false;
static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555; static enum retro_pixel_format video_driver_pix_fmt = RETRO_PIXEL_FORMAT_0RGB1555;
const void *frame_cache_data = NULL; static const void *frame_cache_data = NULL;
static unsigned frame_cache_width = 0; static unsigned frame_cache_width = 0;
static unsigned frame_cache_height = 0; static unsigned frame_cache_height = 0;
static size_t frame_cache_pitch = 0; static size_t frame_cache_pitch = 0;
@ -2926,3 +2926,10 @@ bool video_driver_has_windowed(void)
return false; return false;
#endif #endif
} }
bool video_driver_cached_frame_has_valid_framebuffer(void)
{
if (frame_cache_data)
return (frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID);
return false;
}

View File

@ -523,7 +523,7 @@ bool video_driver_is_focused(void);
bool video_driver_has_windowed(void); bool video_driver_has_windowed(void);
#define video_driver_cached_frame_has_valid_framebuffer() (frame_cache_data ? (frame_cache_data == RETRO_HW_FRAME_BUFFER_VALID) : false) bool video_driver_cached_frame_has_valid_framebuffer(void);
void video_driver_destroy(void); void video_driver_destroy(void);
void video_driver_set_cached_frame_ptr(const void *data); void video_driver_set_cached_frame_ptr(const void *data);
@ -858,8 +858,6 @@ extern const gfx_ctx_driver_t gfx_ctx_khr_display;
extern const gfx_ctx_driver_t gfx_ctx_gdi; extern const gfx_ctx_driver_t gfx_ctx_gdi;
extern const gfx_ctx_driver_t gfx_ctx_null; extern const gfx_ctx_driver_t gfx_ctx_null;
extern const void *frame_cache_data;
extern void *video_driver_data; extern void *video_driver_data;
extern video_driver_t *current_video; extern video_driver_t *current_video;

View File

@ -45,6 +45,7 @@
#include "../core.h" #include "../core.h"
#include "../file_path_special.h" #include "../file_path_special.h"
#include "../configuration.h" #include "../configuration.h"
#include "../gfx/video_driver.h"
#include "../msg_hash.h" #include "../msg_hash.h"
#include "../retroarch.h" #include "../retroarch.h"
#include "../verbosity.h" #include "../verbosity.h"
@ -91,6 +92,7 @@ typedef struct
bool mute; bool mute;
int state_slot; int state_slot;
bool thumbnail_enable; bool thumbnail_enable;
bool has_valid_framebuffer;
} save_task_state_t; } save_task_state_t;
typedef save_task_state_t load_task_data_t; typedef save_task_state_t load_task_data_t;
@ -207,26 +209,26 @@ static autosave_t *autosave_new(const char *path,
const void *data, size_t size, const void *data, size_t size,
unsigned interval) unsigned interval)
{ {
autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle)); autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
if (!handle) if (!handle)
goto error; goto error;
handle->bufsize = size; handle->bufsize = size;
handle->interval = interval; handle->interval = interval;
handle->path = path; handle->path = path;
handle->buffer = malloc(size); handle->buffer = malloc(size);
handle->retro_buffer = data; handle->retro_buffer = data;
if (!handle->buffer) if (!handle->buffer)
goto error; goto error;
memcpy(handle->buffer, handle->retro_buffer, handle->bufsize); memcpy(handle->buffer, handle->retro_buffer, handle->bufsize);
handle->lock = slock_new(); handle->lock = slock_new();
handle->cond_lock = slock_new(); handle->cond_lock = slock_new();
handle->cond = scond_new(); handle->cond = scond_new();
handle->thread = sthread_create(autosave_thread, handle); handle->thread = sthread_create(autosave_thread, handle);
return handle; return handle;
@ -644,16 +646,17 @@ static bool task_push_undo_save_state(const char *path, void *data, size_t size)
goto error; goto error;
strlcpy(state->path, path, sizeof(state->path)); strlcpy(state->path, path, sizeof(state->path));
state->data = data; state->data = data;
state->size = size; state->size = size;
state->undo_save = true; state->undo_save = true;
state->state_slot = settings->ints.state_slot; state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->type = TASK_TYPE_BLOCKING; task->type = TASK_TYPE_BLOCKING;
task->state = state; task->state = state;
task->handler = task_save_handler; task->handler = task_save_handler;
task->callback = undo_save_state_cb; task->callback = undo_save_state_cb;
task->title = strdup(msg_hash_to_str(MSG_UNDOING_SAVE_STATE)); task->title = strdup(msg_hash_to_str(MSG_UNDOING_SAVE_STATE));
task_queue_ctl(TASK_QUEUE_CTL_PUSH, task); task_queue_ctl(TASK_QUEUE_CTL_PUSH, task);
@ -977,7 +980,7 @@ static void save_state_cb(void *task_data,
char *path = strdup(state->path); char *path = strdup(state->path);
if (state->thumbnail_enable) if (state->thumbnail_enable)
take_screenshot(path, true); take_screenshot(path, true, state->has_valid_framebuffer);
free(path); free(path);
} }
@ -1006,6 +1009,7 @@ static void task_push_save_state(const char *path, void *data, size_t size, bool
state->mute = autosave; /* don't show OSD messages if we are auto-saving */ state->mute = autosave; /* don't show OSD messages if we are auto-saving */
state->thumbnail_enable = settings->bools.savestate_thumbnail_enable; state->thumbnail_enable = settings->bools.savestate_thumbnail_enable;
state->state_slot = settings->ints.state_slot; state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->type = TASK_TYPE_BLOCKING; task->type = TASK_TYPE_BLOCKING;
task->state = state; task->state = state;
@ -1076,6 +1080,7 @@ static void task_push_load_and_save_state(const char *path, void *data,
state->autosave = autosave; state->autosave = autosave;
state->mute = autosave; /* don't show OSD messages if we are auto-saving */ state->mute = autosave; /* don't show OSD messages if we are auto-saving */
state->state_slot = settings->ints.state_slot; state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->state = state; task->state = state;
task->type = TASK_TYPE_BLOCKING; task->type = TASK_TYPE_BLOCKING;
@ -1212,6 +1217,7 @@ bool content_load_state(const char *path,
state->load_to_backup_buffer = load_to_backup_buffer; state->load_to_backup_buffer = load_to_backup_buffer;
state->autoload = autoload; state->autoload = autoload;
state->state_slot = settings->ints.state_slot; state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->type = TASK_TYPE_BLOCKING; task->type = TASK_TYPE_BLOCKING;
task->state = state; task->state = state;

View File

@ -334,7 +334,7 @@ static bool take_screenshot_raw(const char *name_base, void *userbuf,
} }
static bool take_screenshot_choice(const char *name_base, bool savestate, static bool take_screenshot_choice(const char *name_base, bool savestate,
bool is_paused, bool is_idle) bool is_paused, bool is_idle, bool has_valid_framebuffer)
{ {
size_t old_pitch; size_t old_pitch;
unsigned old_width, old_height; unsigned old_width, old_height;
@ -362,7 +362,7 @@ static bool take_screenshot_choice(const char *name_base, bool savestate,
#endif #endif
} }
if (!video_driver_cached_frame_has_valid_framebuffer()) if (!has_valid_framebuffer)
return take_screenshot_raw(name_base, NULL, savestate, is_idle, is_paused); return take_screenshot_raw(name_base, NULL, savestate, is_idle, is_paused);
if (!video_driver_supports_read_frame_raw()) if (!video_driver_supports_read_frame_raw())
@ -387,7 +387,7 @@ static bool take_screenshot_choice(const char *name_base, bool savestate,
return ret; return ret;
} }
bool take_screenshot(const char *name_base, bool silence) bool take_screenshot(const char *name_base, bool silence, bool has_valid_framebuffer)
{ {
bool is_paused = false; bool is_paused = false;
bool is_idle = false; bool is_idle = false;
@ -397,7 +397,8 @@ bool take_screenshot(const char *name_base, bool silence)
runloop_get_status(&is_paused, &is_idle, &is_slowmotion, &is_perfcnt_enable); runloop_get_status(&is_paused, &is_idle, &is_slowmotion, &is_perfcnt_enable);
ret = take_screenshot_choice(name_base, silence, is_paused, is_idle); ret = take_screenshot_choice(name_base, silence, is_paused, is_idle,
has_valid_framebuffer);
if (is_paused && !is_idle) if (is_paused && !is_idle)
video_driver_cached_frame(); video_driver_cached_frame();

View File

@ -204,7 +204,7 @@ bool task_push_load_content_with_core_from_menu(
void task_file_load_handler(retro_task_t *task); void task_file_load_handler(retro_task_t *task);
bool take_screenshot(const char *path, bool silence); bool take_screenshot(const char *path, bool silence, bool has_valid_framebuffer);
bool event_load_save_files(void); bool event_load_save_files(void);