This commit is contained in:
twinaphex 2020-08-18 14:48:30 +02:00
parent ed94465503
commit 7a77d58f96
2 changed files with 38 additions and 40 deletions

View File

@ -54,25 +54,13 @@ enum scaler_type
struct scaler_filter
{
int16_t *filter;
int filter_len;
int filter_stride;
int *filter_pos;
int *filter_pos;
int filter_len;
int filter_stride;
};
struct scaler_ctx
{
int in_width;
int in_height;
int in_stride;
int out_width;
int out_height;
int out_stride;
enum scaler_pix_fmt in_fmt;
enum scaler_pix_fmt out_fmt;
enum scaler_type scaler_type;
void (*scaler_horiz)(const struct scaler_ctx*,
const void*, int);
void (*scaler_vert)(const struct scaler_ctx*,
@ -83,9 +71,7 @@ struct scaler_ctx
void (*in_pixconv)(void*, const void*, int, int, int, int);
void (*out_pixconv)(void*, const void*, int, int, int, int);
void (*direct_pixconv)(void*, const void*, int, int, int, int);
bool unscaled;
struct scaler_filter horiz, vert;
struct scaler_filter horiz, vert; /* ptr alignment */
struct
{
@ -106,6 +92,20 @@ struct scaler_ctx
uint32_t *frame;
int stride;
} output;
int in_width;
int in_height;
int in_stride;
int out_width;
int out_height;
int out_stride;
enum scaler_pix_fmt in_fmt;
enum scaler_pix_fmt out_fmt;
enum scaler_type scaler_type;
bool unscaled;
};
bool scaler_ctx_gen_filter(struct scaler_ctx *ctx);

View File

@ -305,7 +305,8 @@ struct libretro_vfs_implementation_file
libretro_vfs_implementation_file *retro_vfs_file_open_impl(
const char *path, unsigned mode, unsigned hints)
{
char *dirpath, *filename;
char dirpath[PATH_MAX_LENGTH];
char filename[PATH_MAX_LENGTH];
wchar_t *dirpath_wide;
wchar_t *filename_wide;
Platform::String^ filename_str;
@ -322,20 +323,18 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
if (PATH_CHAR_IS_SLASH(path[strlen(path) - 1]))
return NULL;
dirpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
fill_pathname_basedir(dirpath, path, PATH_MAX_LENGTH);
dirpath[0] = filename[0] = '\0';
fill_pathname_basedir(dirpath, path, sizeof(dirpath));
dirpath_wide = utf8_to_utf16_string_alloc(dirpath);
windowsize_path(dirpath_wide);
dirpath_str = ref new Platform::String(dirpath_wide);
free(dirpath_wide);
free(dirpath);
filename = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
fill_pathname_base(filename, path, PATH_MAX_LENGTH);
fill_pathname_base(filename, path, sizeof(filename));
filename_wide = utf8_to_utf16_string_alloc(filename);
filename_str = ref new Platform::String(filename_wide);
free(filename_wide);
free(filename);
retro_assert(!dirpath_str->IsEmpty() && !filename_str->IsEmpty());
@ -577,8 +576,8 @@ int retro_vfs_file_remove_impl(const char *path)
/* TODO: this may not work if trying to move a directory */
int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
{
char *new_file_name;
char *new_dir_path;
char new_file_name[PATH_MAX_LENGTH];
char new_dir_path[PATH_MAX_LENGTH];
wchar_t *new_file_name_wide;
wchar_t *old_path_wide, *new_dir_path_wide;
Platform::String^ old_path_str;
@ -588,24 +587,23 @@ int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
if (!old_path || !*old_path || !new_path || !*new_path)
return -1;
new_file_name[0] = '\0';
new_dir_path [0] = '\0';
old_path_wide = utf8_to_utf16_string_alloc(old_path);
old_path_str = ref new Platform::String(old_path_wide);
free(old_path_wide);
new_dir_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
fill_pathname_basedir(new_dir_path, new_path, PATH_MAX_LENGTH);
fill_pathname_basedir(new_dir_path, new_path, sizeof(new_dir_path));
new_dir_path_wide = utf8_to_utf16_string_alloc(new_dir_path);
windowsize_path(new_dir_path_wide);
new_dir_path_str = ref new Platform::String(new_dir_path_wide);
free(new_dir_path_wide);
free(new_dir_path);
new_file_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
fill_pathname_base(new_file_name, new_path, PATH_MAX_LENGTH);
fill_pathname_base(new_file_name, new_path, sizeof(new_file_name));
new_file_name_wide = utf8_to_utf16_string_alloc(new_file_name);
new_file_name_str = ref new Platform::String(new_file_name_wide);
free(new_file_name_wide);
free(new_file_name);
retro_assert(!old_path_str->IsEmpty() && !new_dir_path_str->IsEmpty() && !new_file_name_str->IsEmpty());
@ -667,10 +665,14 @@ int retro_vfs_mkdir_impl(const char *dir)
Platform::String^ parent_path_str;
Platform::String^ dir_name_str;
wchar_t *dir_name_wide, *parent_path_wide;
char *dir_local, *tmp, *dir_name, *parent_path;
char *dir_local, *tmp, *dir_name;
char parent_path[PATH_MAX_LENGTH];
char dir_name[PATH_MAX_LENGTH];
if (!dir || !*dir)
return -1;
dir_name[0] = '\0';
/* If the path ends with a slash, we have to remove
* it for basename to work */
dir_local = strdup(dir);
@ -679,20 +681,16 @@ int retro_vfs_mkdir_impl(const char *dir)
if (PATH_CHAR_IS_SLASH(*tmp))
*tmp = 0;
dir_name = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
fill_pathname_base(dir_name, dir_local, PATH_MAX_LENGTH);
fill_pathname_base(dir_name, dir_local, sizeof(dir_name));
dir_name_wide = utf8_to_utf16_string_alloc(dir_name);
dir_name_str = ref new Platform::String(dir_name_wide);
free(dir_name_wide);
free(dir_name);
parent_path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
fill_pathname_parent_dir(parent_path, dir_local, PATH_MAX_LENGTH);
fill_pathname_parent_dir(parent_path, dir_local, sizeof(parent_path));
parent_path_wide = utf8_to_utf16_string_alloc(parent_path);
windowsize_path(parent_path_wide);
parent_path_str = ref new Platform::String(parent_path_wide);
free(parent_path_wide);
free(parent_path);
retro_assert(!dir_name_str->IsEmpty()
&& !parent_path_str->IsEmpty());