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;
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;
break;
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;
const void *frame_cache_data = NULL;
static const void *frame_cache_data = NULL;
static unsigned frame_cache_width = 0;
static unsigned frame_cache_height = 0;
static size_t frame_cache_pitch = 0;
@ -2926,3 +2926,10 @@ bool video_driver_has_windowed(void)
return false;
#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);
#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_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_null;
extern const void *frame_cache_data;
extern void *video_driver_data;
extern video_driver_t *current_video;

View File

@ -45,6 +45,7 @@
#include "../core.h"
#include "../file_path_special.h"
#include "../configuration.h"
#include "../gfx/video_driver.h"
#include "../msg_hash.h"
#include "../retroarch.h"
#include "../verbosity.h"
@ -91,6 +92,7 @@ typedef struct
bool mute;
int state_slot;
bool thumbnail_enable;
bool has_valid_framebuffer;
} save_task_state_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,
unsigned interval)
{
autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
if (!handle)
goto error;
handle->bufsize = size;
handle->interval = interval;
handle->path = path;
handle->buffer = malloc(size);
handle->retro_buffer = data;
handle->bufsize = size;
handle->interval = interval;
handle->path = path;
handle->buffer = malloc(size);
handle->retro_buffer = data;
if (!handle->buffer)
goto error;
memcpy(handle->buffer, handle->retro_buffer, handle->bufsize);
handle->lock = slock_new();
handle->cond_lock = slock_new();
handle->cond = scond_new();
handle->lock = slock_new();
handle->cond_lock = slock_new();
handle->cond = scond_new();
handle->thread = sthread_create(autosave_thread, handle);
handle->thread = sthread_create(autosave_thread, handle);
return handle;
@ -644,16 +646,17 @@ static bool task_push_undo_save_state(const char *path, void *data, size_t size)
goto error;
strlcpy(state->path, path, sizeof(state->path));
state->data = data;
state->size = size;
state->undo_save = true;
state->state_slot = settings->ints.state_slot;
state->data = data;
state->size = size;
state->undo_save = true;
state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->type = TASK_TYPE_BLOCKING;
task->state = state;
task->handler = task_save_handler;
task->callback = undo_save_state_cb;
task->title = strdup(msg_hash_to_str(MSG_UNDOING_SAVE_STATE));
task->type = TASK_TYPE_BLOCKING;
task->state = state;
task->handler = task_save_handler;
task->callback = undo_save_state_cb;
task->title = strdup(msg_hash_to_str(MSG_UNDOING_SAVE_STATE));
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);
if (state->thumbnail_enable)
take_screenshot(path, true);
take_screenshot(path, true, state->has_valid_framebuffer);
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->thumbnail_enable = settings->bools.savestate_thumbnail_enable;
state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->type = TASK_TYPE_BLOCKING;
task->state = state;
@ -1076,6 +1080,7 @@ static void task_push_load_and_save_state(const char *path, void *data,
state->autosave = autosave;
state->mute = autosave; /* don't show OSD messages if we are auto-saving */
state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->state = state;
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->autoload = autoload;
state->state_slot = settings->ints.state_slot;
state->has_valid_framebuffer = video_driver_cached_frame_has_valid_framebuffer();
task->type = TASK_TYPE_BLOCKING;
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,
bool is_paused, bool is_idle)
bool is_paused, bool is_idle, bool has_valid_framebuffer)
{
size_t old_pitch;
unsigned old_width, old_height;
@ -362,7 +362,7 @@ static bool take_screenshot_choice(const char *name_base, bool savestate,
#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);
if (!video_driver_supports_read_frame_raw())
@ -387,7 +387,7 @@ static bool take_screenshot_choice(const char *name_base, bool savestate,
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_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);
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)
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);
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);