2012-04-21 21:13:50 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2016-2017 - Brad Parker
|
2016-03-10 22:36:46 +00:00
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
2011-05-15 14:54:43 +00:00
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
2012-04-21 21:13:50 +00:00
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
2011-05-15 14:54:43 +00:00
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
2012-04-21 21:31:57 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
2011-05-15 14:54:43 +00:00
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-09-19 01:41:55 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-06-29 22:38:10 +00:00
|
|
|
#ifdef _XBOX1
|
|
|
|
#include <xtl.h>
|
|
|
|
#include <xgraphics.h>
|
|
|
|
#endif
|
|
|
|
|
2011-05-15 14:54:43 +00:00
|
|
|
#include <stdio.h>
|
2014-09-11 22:11:08 +00:00
|
|
|
#include <stddef.h>
|
2011-05-15 14:54:43 +00:00
|
|
|
#include <time.h>
|
2014-10-21 03:05:52 +00:00
|
|
|
#include <boolean.h>
|
2011-05-15 14:54:43 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
2015-06-29 22:38:10 +00:00
|
|
|
|
|
|
|
#include <file/file_path.h>
|
|
|
|
#include <compat/strl.h>
|
2016-05-17 13:02:25 +00:00
|
|
|
#include <string/stdstring.h>
|
2016-05-17 12:31:33 +00:00
|
|
|
#include <gfx/scaler/scaler.h>
|
2016-11-08 14:35:24 +00:00
|
|
|
#include <gfx/video_frame.h>
|
2015-06-29 22:38:10 +00:00
|
|
|
|
2016-06-07 04:14:28 +00:00
|
|
|
#ifdef HAVE_RBMP
|
2015-09-19 02:40:30 +00:00
|
|
|
#include <formats/rbmp.h>
|
2016-06-07 04:14:28 +00:00
|
|
|
#endif
|
2015-09-19 02:40:30 +00:00
|
|
|
|
2016-08-02 13:34:48 +00:00
|
|
|
#ifdef HAVE_RPNG
|
2015-06-29 22:38:10 +00:00
|
|
|
#include <formats/rpng.h>
|
2015-09-19 00:52:23 +00:00
|
|
|
#define IMG_EXT "png"
|
|
|
|
#else
|
|
|
|
#define IMG_EXT "bmp"
|
|
|
|
#endif
|
2015-06-29 22:38:10 +00:00
|
|
|
|
2016-07-30 23:20:00 +00:00
|
|
|
#include "../defaults.h"
|
2016-09-01 03:36:52 +00:00
|
|
|
#include "../configuration.h"
|
|
|
|
#include "../runloop.h"
|
2016-09-17 17:41:16 +00:00
|
|
|
#include "../paths.h"
|
2016-05-17 12:31:33 +00:00
|
|
|
#include "../msg_hash.h"
|
2016-05-04 14:34:13 +00:00
|
|
|
|
2016-05-17 12:31:33 +00:00
|
|
|
#include "../gfx/video_driver.h"
|
2011-05-15 14:54:43 +00:00
|
|
|
|
2016-07-30 23:20:00 +00:00
|
|
|
#include "tasks_internal.h"
|
|
|
|
|
2016-11-21 08:06:31 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-10-03 02:41:37 +00:00
|
|
|
#ifdef _XBOX1
|
|
|
|
D3DSurface *surf;
|
2016-01-25 00:01:57 +00:00
|
|
|
#endif
|
2016-10-03 02:41:37 +00:00
|
|
|
char filename[PATH_MAX_LENGTH];
|
|
|
|
char shotname[256];
|
|
|
|
#ifdef HAVE_RPNG
|
|
|
|
uint8_t *out_buffer;
|
|
|
|
struct scaler_ctx scaler;
|
|
|
|
#endif
|
|
|
|
const void *frame;
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
int pitch;
|
|
|
|
bool bgr24;
|
2016-12-11 09:34:12 +00:00
|
|
|
bool silence;
|
2016-10-03 02:41:37 +00:00
|
|
|
void *userbuf;
|
2017-01-22 17:17:48 +00:00
|
|
|
bool is_idle;
|
2017-01-03 03:42:10 +00:00
|
|
|
bool is_paused;
|
2017-01-03 03:35:13 +00:00
|
|
|
bool history_list_enable;
|
2016-10-03 02:41:37 +00:00
|
|
|
} screenshot_task_state_t;
|
2015-09-27 00:32:30 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
/**
|
|
|
|
* task_screenshot_handler:
|
|
|
|
* @task : the task being worked on
|
|
|
|
*
|
|
|
|
* Saves a screenshot to disk.
|
|
|
|
**/
|
|
|
|
static void task_screenshot_handler(retro_task_t *task)
|
|
|
|
{
|
|
|
|
screenshot_task_state_t *state = (screenshot_task_state_t*)task->state;
|
2016-11-21 08:06:31 +00:00
|
|
|
bool ret = false;
|
2016-10-03 02:41:37 +00:00
|
|
|
|
2016-12-29 05:50:18 +00:00
|
|
|
if (task_get_progress(task) == 100)
|
2016-03-10 22:36:46 +00:00
|
|
|
{
|
2016-12-29 05:50:18 +00:00
|
|
|
task_set_finished(task, true);
|
2015-09-27 00:32:30 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
if (state->userbuf)
|
|
|
|
free(state->userbuf);
|
|
|
|
|
|
|
|
free(state);
|
|
|
|
return;
|
|
|
|
}
|
2016-05-04 14:37:58 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
#if defined(_XBOX1)
|
|
|
|
if (XGWriteSurfaceToFile(state->surf, state->filename) == S_OK)
|
2015-09-27 00:32:30 +00:00
|
|
|
ret = true;
|
2016-10-03 02:41:37 +00:00
|
|
|
state->surf->Release();
|
2016-08-02 13:34:48 +00:00
|
|
|
#elif defined(HAVE_RPNG)
|
2016-11-08 14:26:15 +00:00
|
|
|
{
|
|
|
|
struct scaler_ctx *scaler = (struct scaler_ctx*)&state->scaler;
|
|
|
|
|
|
|
|
if (state->bgr24)
|
|
|
|
scaler->in_fmt = SCALER_FMT_BGR24;
|
|
|
|
else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888)
|
|
|
|
scaler->in_fmt = SCALER_FMT_ARGB8888;
|
|
|
|
else
|
|
|
|
scaler->in_fmt = SCALER_FMT_RGB565;
|
|
|
|
|
|
|
|
video_frame_convert_to_bgr24(
|
|
|
|
scaler,
|
|
|
|
state->out_buffer,
|
2016-12-04 18:08:24 +00:00
|
|
|
(const uint8_t*)state->frame + ((int)state->height - 1)
|
|
|
|
* state->pitch,
|
2016-11-08 14:26:15 +00:00
|
|
|
state->width, state->height,
|
|
|
|
-state->pitch);
|
|
|
|
}
|
2015-09-27 00:32:30 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
scaler_ctx_gen_reset(&state->scaler);
|
2015-09-27 00:32:30 +00:00
|
|
|
|
2016-03-20 04:12:53 +00:00
|
|
|
ret = rpng_save_image_bgr24(
|
2016-10-03 02:41:37 +00:00
|
|
|
state->filename,
|
|
|
|
state->out_buffer,
|
|
|
|
state->width,
|
|
|
|
state->height,
|
|
|
|
state->width * 3
|
2016-03-20 04:12:53 +00:00
|
|
|
);
|
2016-10-03 02:41:37 +00:00
|
|
|
|
|
|
|
free(state->out_buffer);
|
2016-06-07 04:14:28 +00:00
|
|
|
#elif defined(HAVE_RBMP)
|
2016-03-20 04:12:53 +00:00
|
|
|
enum rbmp_source_type bmp_type = RBMP_SOURCE_TYPE_DONT_CARE;
|
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
if (state->bgr24)
|
2016-03-20 04:12:53 +00:00
|
|
|
bmp_type = RBMP_SOURCE_TYPE_BGR24;
|
|
|
|
else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888)
|
2016-03-20 14:07:49 +00:00
|
|
|
bmp_type = RBMP_SOURCE_TYPE_XRGB888;
|
2016-03-20 04:12:53 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
ret = rbmp_save_image(state->filename,
|
|
|
|
state->frame,
|
|
|
|
state->width,
|
|
|
|
state->height,
|
|
|
|
state->pitch,
|
2016-03-20 04:12:53 +00:00
|
|
|
bmp_type);
|
2015-09-27 00:32:30 +00:00
|
|
|
#endif
|
|
|
|
|
2016-07-31 12:22:43 +00:00
|
|
|
#ifdef HAVE_IMAGEVIEWER
|
2016-12-11 09:34:12 +00:00
|
|
|
if (ret && !state->silence)
|
2016-12-24 02:21:29 +00:00
|
|
|
{
|
2016-12-20 21:48:10 +00:00
|
|
|
if (
|
2017-01-03 03:35:13 +00:00
|
|
|
state->history_list_enable
|
2016-12-20 21:48:10 +00:00
|
|
|
&& g_defaults.image_history
|
|
|
|
&& playlist_push(
|
|
|
|
g_defaults.image_history,
|
2016-12-04 18:08:24 +00:00
|
|
|
state->filename,
|
2016-12-20 21:48:10 +00:00
|
|
|
NULL,
|
|
|
|
"builtin",
|
|
|
|
"imageviewer",
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
)
|
|
|
|
)
|
2016-07-30 23:20:00 +00:00
|
|
|
playlist_write_file(g_defaults.image_history);
|
2016-12-24 02:21:29 +00:00
|
|
|
}
|
2016-10-03 02:41:37 +00:00
|
|
|
#endif
|
|
|
|
|
2016-12-29 05:50:18 +00:00
|
|
|
task_set_progress(task, 100);
|
2016-10-03 02:41:37 +00:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
{
|
2016-12-06 05:56:07 +00:00
|
|
|
char *msg = strdup(msg_hash_to_str(MSG_FAILED_TO_TAKE_SCREENSHOT));
|
2017-01-03 03:42:10 +00:00
|
|
|
runloop_msg_queue_push(msg, 1, state->is_paused ? 1 : 180, true);
|
2016-12-06 05:56:07 +00:00
|
|
|
free(msg);
|
2016-07-30 23:20:00 +00:00
|
|
|
}
|
2016-10-03 02:41:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Take frame bottom-up. */
|
|
|
|
static bool screenshot_dump(
|
|
|
|
const char *name_base,
|
|
|
|
const void *frame,
|
|
|
|
unsigned width,
|
|
|
|
unsigned height,
|
2017-01-22 17:17:48 +00:00
|
|
|
int pitch, bool bgr24,
|
|
|
|
void *userbuf, bool savestate,
|
|
|
|
bool is_idle,
|
2017-01-03 05:57:55 +00:00
|
|
|
bool is_paused)
|
2016-10-03 02:41:37 +00:00
|
|
|
{
|
2017-01-03 03:30:02 +00:00
|
|
|
char screenshot_path[PATH_MAX_LENGTH];
|
2016-11-21 08:06:31 +00:00
|
|
|
#ifdef _XBOX1
|
|
|
|
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true);
|
|
|
|
#endif
|
2016-10-03 02:41:37 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-11-21 08:06:31 +00:00
|
|
|
retro_task_t *task = (retro_task_t*)calloc(1, sizeof(*task));
|
2016-10-03 02:41:37 +00:00
|
|
|
screenshot_task_state_t *state = (screenshot_task_state_t*)
|
|
|
|
calloc(1, sizeof(*state));
|
2017-01-03 03:30:02 +00:00
|
|
|
const char *screenshot_dir = settings->directory.screenshot;
|
|
|
|
|
|
|
|
screenshot_path[0] = '\0';
|
|
|
|
|
2017-01-03 03:35:13 +00:00
|
|
|
if (string_is_empty(screenshot_dir))
|
2017-01-03 03:30:02 +00:00
|
|
|
{
|
|
|
|
fill_pathname_basedir(screenshot_path, name_base,
|
|
|
|
sizeof(screenshot_path));
|
|
|
|
screenshot_dir = screenshot_path;
|
|
|
|
}
|
2016-10-03 02:41:37 +00:00
|
|
|
|
2017-01-22 17:17:48 +00:00
|
|
|
state->is_idle = is_idle;
|
2017-01-03 05:57:55 +00:00
|
|
|
state->is_paused = is_paused;
|
2017-01-03 03:35:13 +00:00
|
|
|
state->bgr24 = bgr24;
|
|
|
|
state->height = height;
|
|
|
|
state->width = width;
|
|
|
|
state->pitch = pitch;
|
|
|
|
state->frame = frame;
|
|
|
|
state->userbuf = userbuf;
|
|
|
|
state->silence = savestate;
|
|
|
|
state->history_list_enable = settings->history_list_enable;
|
2016-10-03 02:41:37 +00:00
|
|
|
|
2016-12-01 22:24:16 +00:00
|
|
|
if (savestate)
|
|
|
|
snprintf(state->filename, sizeof(state->filename), "%s.png", name_base);
|
2016-10-03 02:41:37 +00:00
|
|
|
else
|
2016-12-01 22:24:16 +00:00
|
|
|
{
|
|
|
|
if (settings->auto_screenshot_filename)
|
2016-12-17 11:55:38 +00:00
|
|
|
fill_str_dated_filename(state->shotname, path_basename(name_base),
|
2016-12-01 22:24:16 +00:00
|
|
|
IMG_EXT, sizeof(state->shotname));
|
|
|
|
else
|
2016-12-04 18:08:24 +00:00
|
|
|
snprintf(state->shotname, sizeof(state->shotname),
|
|
|
|
"%s.png", path_basename(name_base));
|
2016-10-03 02:41:37 +00:00
|
|
|
|
2017-01-03 03:30:02 +00:00
|
|
|
fill_pathname_join(state->filename, screenshot_dir,
|
2016-12-04 18:08:24 +00:00
|
|
|
state->shotname, sizeof(state->filename));
|
2016-12-01 22:24:16 +00:00
|
|
|
}
|
2016-10-03 02:41:37 +00:00
|
|
|
|
|
|
|
#ifdef _XBOX1
|
|
|
|
d3d->dev->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &state->surf);
|
|
|
|
#elif defined(HAVE_RPNG)
|
|
|
|
state->out_buffer = (uint8_t*)malloc(width * height * 3);
|
|
|
|
if (!state->out_buffer)
|
2016-10-04 09:02:01 +00:00
|
|
|
{
|
|
|
|
if (task)
|
|
|
|
free(task);
|
2016-10-06 03:17:22 +00:00
|
|
|
free(state);
|
2016-10-03 02:41:37 +00:00
|
|
|
return false;
|
2016-10-04 09:02:01 +00:00
|
|
|
}
|
2016-07-31 12:22:43 +00:00
|
|
|
#endif
|
2016-07-30 23:20:00 +00:00
|
|
|
|
2017-01-03 03:37:52 +00:00
|
|
|
task->type = TASK_TYPE_BLOCKING;
|
|
|
|
task->state = state;
|
|
|
|
task->handler = task_screenshot_handler;
|
|
|
|
|
2016-12-01 19:32:13 +00:00
|
|
|
if (!savestate)
|
2017-01-23 13:15:26 +00:00
|
|
|
task->title = strdup(msg_hash_to_str(MSG_TAKING_SCREENSHOT));
|
2017-01-03 03:37:52 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
task_queue_ctl(TASK_QUEUE_CTL_PUSH, task);
|
|
|
|
|
|
|
|
return true;
|
2015-09-27 00:32:30 +00:00
|
|
|
}
|
|
|
|
|
2016-08-24 12:04:22 +00:00
|
|
|
#if !defined(VITA)
|
2017-01-03 05:57:55 +00:00
|
|
|
static bool take_screenshot_viewport(const char *name_base, bool savestate,
|
2017-01-22 17:17:48 +00:00
|
|
|
bool is_idle, bool is_paused)
|
2015-02-10 19:58:33 +00:00
|
|
|
{
|
2016-12-19 18:04:52 +00:00
|
|
|
struct video_viewport vp;
|
2015-06-12 15:00:37 +00:00
|
|
|
uint8_t *buffer = NULL;
|
|
|
|
bool retval = false;
|
2016-10-09 08:43:16 +00:00
|
|
|
|
2016-12-19 18:04:52 +00:00
|
|
|
vp.x = 0;
|
|
|
|
vp.y = 0;
|
|
|
|
vp.width = 0;
|
|
|
|
vp.height = 0;
|
|
|
|
vp.full_width = 0;
|
|
|
|
vp.full_height = 0;
|
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
video_driver_get_viewport_info(&vp);
|
2015-02-10 19:58:33 +00:00
|
|
|
|
|
|
|
if (!vp.width || !vp.height)
|
|
|
|
return false;
|
|
|
|
|
2016-05-17 13:00:18 +00:00
|
|
|
buffer = (uint8_t*)malloc(vp.width * vp.height * 3);
|
2016-10-03 02:41:37 +00:00
|
|
|
|
2016-05-17 13:00:18 +00:00
|
|
|
if (!buffer)
|
2015-02-10 19:58:33 +00:00
|
|
|
return false;
|
|
|
|
|
2017-01-22 17:17:48 +00:00
|
|
|
if (!video_driver_read_viewport(buffer, is_idle))
|
2016-10-03 02:41:37 +00:00
|
|
|
goto error;
|
2015-02-10 19:58:33 +00:00
|
|
|
|
|
|
|
/* Data read from viewport is in bottom-up order, suitable for BMP. */
|
2017-01-03 03:30:02 +00:00
|
|
|
if (!screenshot_dump(name_base,
|
2016-12-04 18:08:24 +00:00
|
|
|
buffer, vp.width, vp.height,
|
2017-01-22 17:17:48 +00:00
|
|
|
vp.width * 3, true, buffer, savestate, is_idle, is_paused))
|
2016-10-03 02:41:37 +00:00
|
|
|
goto error;
|
2015-02-10 19:58:33 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
return true;
|
2015-02-10 19:58:33 +00:00
|
|
|
|
2016-10-03 02:41:37 +00:00
|
|
|
error:
|
2015-02-10 19:58:33 +00:00
|
|
|
if (buffer)
|
|
|
|
free(buffer);
|
|
|
|
return retval;
|
|
|
|
}
|
2016-08-24 12:04:22 +00:00
|
|
|
#endif
|
2015-02-10 19:58:33 +00:00
|
|
|
|
2016-11-28 15:26:47 +00:00
|
|
|
static bool take_screenshot_raw(const char *name_base, void *userbuf,
|
2017-01-22 17:17:48 +00:00
|
|
|
bool savestate, bool is_idle, bool is_paused)
|
2015-02-10 19:58:33 +00:00
|
|
|
{
|
2015-05-20 19:29:23 +00:00
|
|
|
size_t pitch;
|
2016-11-21 08:06:31 +00:00
|
|
|
unsigned width, height;
|
2015-06-12 15:00:37 +00:00
|
|
|
const void *data = NULL;
|
2016-10-09 08:43:16 +00:00
|
|
|
|
2015-06-17 12:29:09 +00:00
|
|
|
video_driver_cached_frame_get(&data, &width, &height, &pitch);
|
2016-03-10 22:36:46 +00:00
|
|
|
|
2015-02-10 19:58:33 +00:00
|
|
|
/* Negative pitch is needed as screenshot takes bottom-up,
|
|
|
|
* but we use top-down.
|
|
|
|
*/
|
2017-01-03 03:30:02 +00:00
|
|
|
if (!screenshot_dump(name_base,
|
2015-02-10 19:58:33 +00:00
|
|
|
(const uint8_t*)data + (height - 1) * pitch,
|
2017-01-22 17:17:48 +00:00
|
|
|
width, height, -pitch, false, userbuf, savestate, is_idle, is_paused))
|
2016-07-30 23:20:00 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2015-02-10 19:58:33 +00:00
|
|
|
}
|
|
|
|
|
2017-01-03 05:57:55 +00:00
|
|
|
static bool take_screenshot_choice(const char *name_base, bool savestate,
|
|
|
|
bool is_paused, bool is_idle)
|
2015-02-10 19:58:33 +00:00
|
|
|
{
|
2017-01-03 03:30:02 +00:00
|
|
|
size_t old_pitch;
|
|
|
|
unsigned old_width, old_height;
|
2017-01-03 03:40:11 +00:00
|
|
|
bool ret = false;
|
|
|
|
void *frame_data = NULL;
|
|
|
|
const void* old_data = NULL;
|
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
const char *screenshot_dir = settings->directory.screenshot;
|
2015-02-10 19:58:33 +00:00
|
|
|
|
|
|
|
/* No way to infer screenshot directory. */
|
2017-01-03 03:40:11 +00:00
|
|
|
if ( string_is_empty(screenshot_dir)
|
2016-11-27 23:59:58 +00:00
|
|
|
&& string_is_empty(name_base))
|
2015-02-10 19:58:33 +00:00
|
|
|
return false;
|
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
if (video_driver_supports_viewport_read())
|
2015-02-10 19:58:33 +00:00
|
|
|
{
|
|
|
|
/* Avoid taking screenshot of GUI overlays. */
|
2015-03-22 17:59:16 +00:00
|
|
|
video_driver_set_texture_enable(false, false);
|
2017-01-03 05:57:55 +00:00
|
|
|
if (!is_idle)
|
2016-10-24 22:42:14 +00:00
|
|
|
video_driver_cached_frame();
|
2016-08-23 16:17:46 +00:00
|
|
|
#if defined(VITA)
|
2017-01-22 17:17:48 +00:00
|
|
|
return take_screenshot_raw(name_base, NULL, savestate, is_idle, is_paused);
|
2016-08-23 16:17:46 +00:00
|
|
|
#else
|
2017-01-22 17:17:48 +00:00
|
|
|
return take_screenshot_viewport(name_base, savestate, is_idle, is_paused);
|
2016-08-23 16:17:46 +00:00
|
|
|
#endif
|
2015-02-10 19:58:33 +00:00
|
|
|
}
|
2016-02-03 15:13:37 +00:00
|
|
|
|
2016-05-08 12:00:51 +00:00
|
|
|
if (!video_driver_cached_frame_has_valid_framebuffer())
|
2017-01-22 17:17:48 +00:00
|
|
|
return take_screenshot_raw(name_base, NULL, savestate, is_idle, is_paused);
|
2016-02-03 15:13:37 +00:00
|
|
|
|
2017-01-03 03:30:02 +00:00
|
|
|
if (!video_driver_supports_read_frame_raw())
|
|
|
|
return false;
|
2016-01-30 02:08:33 +00:00
|
|
|
|
2017-01-03 03:30:02 +00:00
|
|
|
video_driver_cached_frame_get(&old_data, &old_width, &old_height,
|
|
|
|
&old_pitch);
|
2015-05-20 19:29:23 +00:00
|
|
|
|
2017-01-03 03:30:02 +00:00
|
|
|
frame_data = video_driver_read_frame_raw(
|
|
|
|
&old_width, &old_height, &old_pitch);
|
2015-03-16 12:41:26 +00:00
|
|
|
|
2017-01-03 03:30:02 +00:00
|
|
|
video_driver_cached_frame_set(old_data, old_width, old_height,
|
|
|
|
old_pitch);
|
2016-01-30 02:08:33 +00:00
|
|
|
|
2017-01-03 03:30:02 +00:00
|
|
|
if (frame_data)
|
|
|
|
{
|
|
|
|
video_driver_set_cached_frame_ptr(frame_data);
|
2017-01-22 17:17:48 +00:00
|
|
|
if (take_screenshot_raw(name_base, frame_data, savestate, is_idle, is_paused))
|
2017-01-03 03:30:02 +00:00
|
|
|
ret = true;
|
2015-03-16 14:32:18 +00:00
|
|
|
}
|
2015-03-16 12:41:26 +00:00
|
|
|
|
2017-01-03 03:30:02 +00:00
|
|
|
return ret;
|
2016-01-30 02:08:33 +00:00
|
|
|
}
|
|
|
|
|
2016-12-06 05:52:57 +00:00
|
|
|
bool take_screenshot(const char *name_base, bool silence)
|
2016-11-28 00:57:48 +00:00
|
|
|
{
|
2017-01-03 05:57:55 +00:00
|
|
|
bool is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL);
|
|
|
|
bool is_idle = runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL);
|
|
|
|
bool ret = take_screenshot_choice(name_base, silence, is_paused, is_idle);
|
2016-11-28 00:57:48 +00:00
|
|
|
|
2017-01-03 05:57:55 +00:00
|
|
|
if (is_paused && !is_idle)
|
2016-11-28 00:57:48 +00:00
|
|
|
video_driver_cached_frame();
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|