mirror of
https://github.com/libretro/libretro-common.git
synced 2024-06-15 18:57:45 -04:00
Resync
This commit is contained in:
parent
ef8eb61ea2
commit
79eaf02ada
|
@ -85,7 +85,7 @@ void convert_float_to_s16(int16_t *out,
|
|||
|
||||
void convert_float_to_s16_init_simd(void)
|
||||
{
|
||||
unsigned cpu = cpu_features_get();
|
||||
uint64_t cpu = cpu_features_get();
|
||||
|
||||
if (cpu & RETRO_SIMD_NEON)
|
||||
float_to_s16_neon_enabled = true;
|
||||
|
|
|
@ -84,7 +84,7 @@ void convert_s16_to_float(float *out,
|
|||
|
||||
void convert_s16_to_float_init_simd(void)
|
||||
{
|
||||
unsigned cpu = cpu_features_get();
|
||||
uint64_t cpu = cpu_features_get();
|
||||
|
||||
if (cpu & RETRO_SIMD_NEON)
|
||||
s16_to_float_neon_enabled = true;
|
||||
|
|
|
@ -91,4 +91,100 @@ static INLINE uint32_t prev_pow2(uint32_t v)
|
|||
return v - (v >> 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* clamp:
|
||||
* @v : initial value
|
||||
*
|
||||
* Get the clamped value based on initial value.
|
||||
*
|
||||
* Returns: clamped value (derived from @v).
|
||||
**/
|
||||
static INLINE float clamp_value(float v, float min, float max)
|
||||
{
|
||||
return v <= min ? min : v >= max ? max : v;
|
||||
}
|
||||
|
||||
/**
|
||||
* saturate_value:
|
||||
* @v : initial value
|
||||
*
|
||||
* Get the clamped 0.0-1.0 value based on initial value.
|
||||
*
|
||||
* Returns: clamped 0.0-1.0 value (derived from @v).
|
||||
**/
|
||||
static INLINE float saturate_value(float v)
|
||||
{
|
||||
return clamp_value(v, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* dot_product:
|
||||
* @a : left hand vector value
|
||||
* @b : right hand vector value
|
||||
*
|
||||
* Get the dot product of the two passed in vectors.
|
||||
*
|
||||
* Returns: dot product value (derived from @a and @b).
|
||||
**/
|
||||
static INLINE float dot_product(const float* a, const float* b)
|
||||
{
|
||||
return (a[0] * b[0]) + (a[1] * b[1]) + (a[2] * b[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* convert_rgb_to_yxy:
|
||||
* @rgb : in RGB colour space value
|
||||
* @Yxy : out Yxy colour space value
|
||||
*
|
||||
* Convert from RGB colour space to Yxy colour space.
|
||||
*
|
||||
* Returns: Yxy colour space value (derived from @rgb).
|
||||
**/
|
||||
static INLINE void convert_rgb_to_yxy(const float* rgb, float* Yxy)
|
||||
{
|
||||
float inv;
|
||||
float xyz[3];
|
||||
float one[3] = {1.0, 1.0, 1.0};
|
||||
float rgb_xyz[3][3] = {
|
||||
{0.4124564, 0.3575761, 0.1804375},
|
||||
{0.2126729, 0.7151522, 0.0721750},
|
||||
{0.0193339, 0.1191920, 0.9503041}
|
||||
};
|
||||
|
||||
xyz[0] = dot_product(rgb_xyz[0], rgb);
|
||||
xyz[1] = dot_product(rgb_xyz[1], rgb);
|
||||
xyz[2] = dot_product(rgb_xyz[2], rgb);
|
||||
|
||||
inv = 1.0f / dot_product(xyz, one);
|
||||
Yxy[0] = xyz[1];
|
||||
Yxy[1] = xyz[0] * inv;
|
||||
Yxy[2] = xyz[1] * inv;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert_yxy_to_rgb:
|
||||
* @rgb : in Yxy colour space value
|
||||
* @Yxy : out rgb colour space value
|
||||
*
|
||||
* Convert from Yxy colour space to rgb colour space.
|
||||
*
|
||||
* Returns: rgb colour space value (derived from @Yxy).
|
||||
**/
|
||||
static INLINE void convert_yxy_to_rgb(const float* Yxy, float* rgb)
|
||||
{
|
||||
float xyz[3];
|
||||
float xyz_rgb[3][3] = {
|
||||
{3.2404542, -1.5371385, -0.4985314},
|
||||
{-0.9692660, 1.8760108, 0.0415560},
|
||||
{0.0556434, -0.2040259, 1.0572252}
|
||||
};
|
||||
xyz[0] = Yxy[0] * Yxy[1] / Yxy[2];
|
||||
xyz[1] = Yxy[0];
|
||||
xyz[2] = Yxy[0] * (1.0 - Yxy[1] - Yxy[2]) / Yxy[2];
|
||||
|
||||
rgb[0] = dot_product(xyz_rgb[0], xyz);
|
||||
rgb[1] = dot_product(xyz_rgb[1], xyz);
|
||||
rgb[2] = dot_product(xyz_rgb[2], xyz);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -177,15 +177,15 @@ namespace
|
|||
}
|
||||
catch (Platform::AccessDeniedException^ e)
|
||||
{
|
||||
Windows::UI::Popups::MessageDialog^ dialog =
|
||||
ref new Windows::UI::Popups::MessageDialog("Path \"" + path + "\" is not currently accessible. Please open any containing directory to access it.");
|
||||
//for some reason the path is inaccessible from within here???
|
||||
Windows::UI::Popups::MessageDialog^ dialog = ref new Windows::UI::Popups::MessageDialog("Path is not currently accessible. Please open any containing directory to access it.");
|
||||
dialog->Commands->Append(ref new Windows::UI::Popups::UICommand("Open file picker"));
|
||||
dialog->Commands->Append(ref new Windows::UI::Popups::UICommand("Cancel"));
|
||||
return concurrency::create_task(dialog->ShowAsync()).then([path](Windows::UI::Popups::IUICommand^ cmd) {
|
||||
if (cmd->Label == "Open file picker")
|
||||
{
|
||||
return TriggerPickerAddDialog().then([path](Platform::String^ added_path) {
|
||||
/* Retry */
|
||||
// Retry
|
||||
return LocateStorageItem<T>(path);
|
||||
});
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(
|
|||
creationDisposition = (mode & RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING) != 0 ?
|
||||
OPEN_ALWAYS : CREATE_ALWAYS;
|
||||
}
|
||||
|
||||
path_str = "\\\\?\\" + path_str;
|
||||
file_handle = CreateFile2FromAppW(path_str->Data(), desireAccess, FILE_SHARE_READ, creationDisposition, NULL);
|
||||
|
||||
if (file_handle != INVALID_HANDLE_VALUE)
|
||||
|
@ -991,7 +991,7 @@ int uwp_move_path(std::filesystem::path old_path, std::filesystem::path new_path
|
|||
bool fail = false;
|
||||
do
|
||||
{
|
||||
if (findDataResult.cFileName != L"." && findDataResult.cFileName != L"..")
|
||||
if (wcscmp(findDataResult.cFileName, L".") != 0 && wcscmp(findDataResult.cFileName, L"..") != 0)
|
||||
{
|
||||
std::filesystem::path temp_old = old_path;
|
||||
std::filesystem::path temp_new = new_path;
|
||||
|
@ -1113,30 +1113,93 @@ struct libretro_vfs_implementation_dir
|
|||
char *entry_name;
|
||||
};
|
||||
|
||||
libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *name, bool include_hidden)
|
||||
libretro_vfs_implementation_dir* retro_vfs_opendir_impl(const char* name, bool include_hidden)
|
||||
{
|
||||
wchar_t *name_wide;
|
||||
Platform::String^ name_str;
|
||||
libretro_vfs_implementation_dir *rdir;
|
||||
wchar_t* name_wide;
|
||||
Platform::String^ name_str;
|
||||
libretro_vfs_implementation_dir* rdir;
|
||||
|
||||
if (!name || !*name)
|
||||
return NULL;
|
||||
if (!name || !*name)
|
||||
return NULL;
|
||||
|
||||
rdir = (libretro_vfs_implementation_dir*)calloc(1, sizeof(*rdir));
|
||||
if (!rdir)
|
||||
return NULL;
|
||||
rdir = (libretro_vfs_implementation_dir*)calloc(1, sizeof(*rdir));
|
||||
if (!rdir)
|
||||
return NULL;
|
||||
|
||||
name_wide = utf8_to_utf16_string_alloc(name);
|
||||
windowsize_path(name_wide);
|
||||
name_str = ref new Platform::String(name_wide);
|
||||
free(name_wide);
|
||||
name_wide = utf8_to_utf16_string_alloc(name);
|
||||
windowsize_path(name_wide);
|
||||
name_str = ref new Platform::String(name_wide);
|
||||
free(name_wide);
|
||||
|
||||
rdir->directory = RunAsyncAndCatchErrors<IVectorView<IStorageItem^>^>([&]() {
|
||||
return concurrency::create_task(LocateStorageItem<StorageFolder>(name_str)).then([&](StorageFolder^ folder) {
|
||||
return folder->GetItemsAsync();
|
||||
});
|
||||
}, nullptr);
|
||||
|
||||
WIN32_FILE_ATTRIBUTE_DATA lpFileInfo;
|
||||
std::filesystem::path dir(name);
|
||||
|
||||
if (dir.empty())
|
||||
return NULL;
|
||||
|
||||
if (!(rdir->directory))
|
||||
{
|
||||
//check if file attributes can be gotten successfully
|
||||
if (GetFileAttributesExFromAppW(dir.parent_path().wstring().c_str(), GetFileExInfoStandard, &lpFileInfo))
|
||||
{
|
||||
//check that the files attributes are not null or empty
|
||||
if (lpFileInfo.dwFileAttributes != INVALID_FILE_ATTRIBUTES && lpFileInfo.dwFileAttributes != 0)
|
||||
{
|
||||
if (lpFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
std::wstring filteredPath(dir.wstring().c_str());
|
||||
WIN32_FIND_DATA findDataResult;
|
||||
if (filteredPath[filteredPath.size() - 1] == '\\')
|
||||
filteredPath.erase(filteredPath.size() - 1);
|
||||
filteredPath += L"\\*.*";
|
||||
HANDLE searchResults = FindFirstFileExFromAppW(filteredPath.c_str(), FindExInfoBasic, &findDataResult, FindExSearchNameMatch, nullptr, FIND_FIRST_EX_LARGE_FETCH);
|
||||
if (searchResults != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Platform::Collections::Vector<IStorageItem^>^ result = ref new Platform::Collections::Vector<IStorageItem^>();
|
||||
do
|
||||
{
|
||||
if (wcscmp(findDataResult.cFileName, L".") != 0 && wcscmp(findDataResult.cFileName, L"..") != 0)
|
||||
{
|
||||
if (!((findDataResult.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) || (findDataResult.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)))
|
||||
{
|
||||
std::filesystem::path temp_new = dir;
|
||||
temp_new /= findDataResult.cFileName;
|
||||
|
||||
std::wstring temp_path = temp_new.generic_wstring();
|
||||
while (true) {
|
||||
size_t p = temp_path.find(L"/");
|
||||
if (p == std::wstring::npos) break;
|
||||
temp_path.replace(p, 1, L"\\");
|
||||
}
|
||||
IStorageItem^ item;
|
||||
if (findDataResult.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
item = RunAsyncAndCatchErrors<StorageFolder^>([&]() {
|
||||
return concurrency::create_task(LocateStorageItem<StorageFolder>(ref new Platform::String(temp_path.c_str())));
|
||||
}, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = RunAsyncAndCatchErrors<StorageFile^>([&]() {
|
||||
return concurrency::create_task(LocateStorageItem<StorageFile>(ref new Platform::String(temp_path.c_str())));
|
||||
}, nullptr);
|
||||
}
|
||||
|
||||
if (item)
|
||||
if (result)
|
||||
result->Append(item);
|
||||
}
|
||||
}
|
||||
} while (FindNextFile(searchResults, &findDataResult));
|
||||
FindClose(searchResults);
|
||||
if (result)
|
||||
rdir->directory = result->GetView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rdir->directory)
|
||||
return rdir;
|
||||
|
||||
|
|
Loading…
Reference in a new issue