diff options
author | Zach Hilman <DarkLordZach@users.noreply.github.com> | 2019-06-08 00:39:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-08 00:39:37 +0200 |
commit | 357ea15a39645213ee52fe8fcf8cd06f7eea208e (patch) | |
tree | 3f723cd6b6ba53248d2d35869bd274afde52e18d | |
parent | Merge pull request #2514 from ReinUsesLisp/opengl-compat (diff) | |
parent | constants: Extract backup JPEG used by account services (diff) | |
download | yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar.gz yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar.bz2 yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar.lz yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar.xz yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar.zst yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.zip |
-rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/core/constants.cpp | 17 | ||||
-rw-r--r-- | src/core/constants.h | 17 | ||||
-rw-r--r-- | src/core/hle/service/acc/acc.cpp | 20 | ||||
-rw-r--r-- | src/yuzu/applets/profile_select.cpp | 15 |
5 files changed, 43 insertions, 28 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6bf512e12..a2e2e976e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -5,6 +5,8 @@ add_library(core STATIC arm/exclusive_monitor.h arm/unicorn/arm_unicorn.cpp arm/unicorn/arm_unicorn.h + constants.cpp + constants.h core.cpp core.h core_cpu.cpp diff --git a/src/core/constants.cpp b/src/core/constants.cpp new file mode 100644 index 000000000..dccb3e03c --- /dev/null +++ b/src/core/constants.cpp @@ -0,0 +1,17 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/constants.h" + +namespace Core::Constants { +const std::array<u8, 107> ACCOUNT_BACKUP_JPEG{{ + 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, + 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, + 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, + 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, + 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, + 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, + 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, +}}; +} diff --git a/src/core/constants.h b/src/core/constants.h new file mode 100644 index 000000000..6d0ec022a --- /dev/null +++ b/src/core/constants.h @@ -0,0 +1,17 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" + +// This is to consolidate system-wide constants that are used by multiple components of yuzu. +// This is especially to prevent the case of something in frontend duplicating a constexpr array or +// directly including some service header for the sole purpose of data. +namespace Core::Constants { + +// ACC Service - Blank JPEG used as user icon in absentia of real one. +extern const std::array<u8, 107> ACCOUNT_BACKUP_JPEG; + +} // namespace Core::Constants diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 86bf53d08..cb66e344b 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp @@ -10,6 +10,7 @@ #include "common/logging/log.h" #include "common/string_util.h" #include "common/swap.h" +#include "core/constants.h" #include "core/core_timing.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/acc/acc.h" @@ -21,19 +22,6 @@ namespace Service::Account { -// Smallest JPEG https://github.com/mathiasbynens/small/blob/master/jpeg.jpg -// used as a backup should the one on disk not exist -constexpr u32 backup_jpeg_size = 107; -constexpr std::array<u8, backup_jpeg_size> backup_jpeg{{ - 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, - 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, - 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, - 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, - 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, - 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, -}}; - static std::string GetImagePath(Common::UUID uuid) { return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; @@ -101,8 +89,8 @@ private: if (!image.IsOpen()) { LOG_WARNING(Service_ACC, "Failed to load user provided image! Falling back to built-in backup..."); - ctx.WriteBuffer(backup_jpeg); - rb.Push<u32>(backup_jpeg_size); + ctx.WriteBuffer(Core::Constants::ACCOUNT_BACKUP_JPEG); + rb.Push<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()); return; } @@ -124,7 +112,7 @@ private: if (!image.IsOpen()) { LOG_WARNING(Service_ACC, "Failed to load user provided image! Falling back to built-in backup..."); - rb.Push<u32>(backup_jpeg_size); + rb.Push<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()); } else { rb.Push<u32>(SanitizeJPEGSize(image.GetSize())); } diff --git a/src/yuzu/applets/profile_select.cpp b/src/yuzu/applets/profile_select.cpp index 6b5c7ba61..6aff38735 100644 --- a/src/yuzu/applets/profile_select.cpp +++ b/src/yuzu/applets/profile_select.cpp @@ -12,21 +12,11 @@ #include <QVBoxLayout> #include "common/file_util.h" #include "common/string_util.h" +#include "core/constants.h" #include "core/hle/lock.h" #include "yuzu/applets/profile_select.h" #include "yuzu/main.h" -// Same backup JPEG used by acc IProfile::GetImage if no jpeg found -constexpr std::array<u8, 107> backup_jpeg{ - 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, - 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, - 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, - 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, - 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, - 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, - 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, -}; - QString FormatUserEntryText(const QString& username, Common::UUID uuid) { return QtProfileSelectionDialog::tr( "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " @@ -45,7 +35,8 @@ QPixmap GetIcon(Common::UUID uuid) { if (!icon) { icon.fill(Qt::black); - icon.loadFromData(backup_jpeg.data(), static_cast<u32>(backup_jpeg.size())); + icon.loadFromData(Core::Constants::ACCOUNT_BACKUP_JPEG.data(), + static_cast<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size())); } return icon.scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |