diff options
| author | 2019-06-07 17:46:52 -0400 | |
|---|---|---|
| committer | 2019-06-07 17:46:57 -0400 | |
| commit | 11f2f0f45c09f49366b62ef32ff1f01fd9efb7a5 (patch) | |
| tree | 3f723cd6b6ba53248d2d35869bd274afde52e18d /src | |
| parent | Merge pull request #2514 from ReinUsesLisp/opengl-compat (diff) | |
| download | yuzu-11f2f0f45c09f49366b62ef32ff1f01fd9efb7a5.tar.gz yuzu-11f2f0f45c09f49366b62ef32ff1f01fd9efb7a5.tar.xz yuzu-11f2f0f45c09f49366b62ef32ff1f01fd9efb7a5.zip | |
constants: Extract backup JPEG used by account services
Diffstat (limited to 'src')
| -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 | |||
| 5 | arm/exclusive_monitor.h | 5 | arm/exclusive_monitor.h |
| 6 | arm/unicorn/arm_unicorn.cpp | 6 | arm/unicorn/arm_unicorn.cpp |
| 7 | arm/unicorn/arm_unicorn.h | 7 | arm/unicorn/arm_unicorn.h |
| 8 | constants.cpp | ||
| 9 | constants.h | ||
| 8 | core.cpp | 10 | core.cpp |
| 9 | core.h | 11 | core.h |
| 10 | core_cpu.cpp | 12 | 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 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/constants.h" | ||
| 6 | |||
| 7 | namespace Core::Constants { | ||
| 8 | const std::array<u8, 107> ACCOUNT_BACKUP_JPEG{{ | ||
| 9 | 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, | ||
| 10 | 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, | ||
| 11 | 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, | ||
| 12 | 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, | ||
| 13 | 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, | ||
| 14 | 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, | ||
| 15 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, | ||
| 16 | }}; | ||
| 17 | } | ||
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 @@ | |||
| 1 | // Copyright 2019 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | // This is to consolidate system-wide constants that are used by multiple components of yuzu. | ||
| 10 | // This is especially to prevent the case of something in frontend duplicating a constexpr array or | ||
| 11 | // directly including some service header for the sole purpose of data. | ||
| 12 | namespace Core::Constants { | ||
| 13 | |||
| 14 | // ACC Service - Blank JPEG used as user icon in absentia of real one. | ||
| 15 | extern const std::array<u8, 107> ACCOUNT_BACKUP_JPEG; | ||
| 16 | |||
| 17 | } // 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 @@ | |||
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | #include "common/string_util.h" | 11 | #include "common/string_util.h" |
| 12 | #include "common/swap.h" | 12 | #include "common/swap.h" |
| 13 | #include "core/constants.h" | ||
| 13 | #include "core/core_timing.h" | 14 | #include "core/core_timing.h" |
| 14 | #include "core/hle/ipc_helpers.h" | 15 | #include "core/hle/ipc_helpers.h" |
| 15 | #include "core/hle/service/acc/acc.h" | 16 | #include "core/hle/service/acc/acc.h" |
| @@ -21,19 +22,6 @@ | |||
| 21 | 22 | ||
| 22 | namespace Service::Account { | 23 | namespace Service::Account { |
| 23 | 24 | ||
| 24 | // Smallest JPEG https://github.com/mathiasbynens/small/blob/master/jpeg.jpg | ||
| 25 | // used as a backup should the one on disk not exist | ||
| 26 | constexpr u32 backup_jpeg_size = 107; | ||
| 27 | constexpr std::array<u8, backup_jpeg_size> backup_jpeg{{ | ||
| 28 | 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, | ||
| 29 | 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, | ||
| 30 | 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, | ||
| 31 | 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, | ||
| 32 | 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, | ||
| 33 | 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, | ||
| 34 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, | ||
| 35 | }}; | ||
| 36 | |||
| 37 | static std::string GetImagePath(Common::UUID uuid) { | 25 | static std::string GetImagePath(Common::UUID uuid) { |
| 38 | return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + | 26 | return FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + |
| 39 | "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; | 27 | "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg"; |
| @@ -101,8 +89,8 @@ private: | |||
| 101 | if (!image.IsOpen()) { | 89 | if (!image.IsOpen()) { |
| 102 | LOG_WARNING(Service_ACC, | 90 | LOG_WARNING(Service_ACC, |
| 103 | "Failed to load user provided image! Falling back to built-in backup..."); | 91 | "Failed to load user provided image! Falling back to built-in backup..."); |
| 104 | ctx.WriteBuffer(backup_jpeg); | 92 | ctx.WriteBuffer(Core::Constants::ACCOUNT_BACKUP_JPEG); |
| 105 | rb.Push<u32>(backup_jpeg_size); | 93 | rb.Push<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()); |
| 106 | return; | 94 | return; |
| 107 | } | 95 | } |
| 108 | 96 | ||
| @@ -124,7 +112,7 @@ private: | |||
| 124 | if (!image.IsOpen()) { | 112 | if (!image.IsOpen()) { |
| 125 | LOG_WARNING(Service_ACC, | 113 | LOG_WARNING(Service_ACC, |
| 126 | "Failed to load user provided image! Falling back to built-in backup..."); | 114 | "Failed to load user provided image! Falling back to built-in backup..."); |
| 127 | rb.Push<u32>(backup_jpeg_size); | 115 | rb.Push<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size()); |
| 128 | } else { | 116 | } else { |
| 129 | rb.Push<u32>(SanitizeJPEGSize(image.GetSize())); | 117 | rb.Push<u32>(SanitizeJPEGSize(image.GetSize())); |
| 130 | } | 118 | } |
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 @@ | |||
| 12 | #include <QVBoxLayout> | 12 | #include <QVBoxLayout> |
| 13 | #include "common/file_util.h" | 13 | #include "common/file_util.h" |
| 14 | #include "common/string_util.h" | 14 | #include "common/string_util.h" |
| 15 | #include "core/constants.h" | ||
| 15 | #include "core/hle/lock.h" | 16 | #include "core/hle/lock.h" |
| 16 | #include "yuzu/applets/profile_select.h" | 17 | #include "yuzu/applets/profile_select.h" |
| 17 | #include "yuzu/main.h" | 18 | #include "yuzu/main.h" |
| 18 | 19 | ||
| 19 | // Same backup JPEG used by acc IProfile::GetImage if no jpeg found | ||
| 20 | constexpr std::array<u8, 107> backup_jpeg{ | ||
| 21 | 0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02, | ||
| 22 | 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05, | ||
| 23 | 0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e, | ||
| 24 | 0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13, | ||
| 25 | 0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc9, 0x00, 0x0b, 0x08, 0x00, 0x01, 0x00, 0x01, | ||
| 26 | 0x01, 0x01, 0x11, 0x00, 0xff, 0xcc, 0x00, 0x06, 0x00, 0x10, 0x10, 0x05, 0xff, 0xda, 0x00, 0x08, | ||
| 27 | 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xd2, 0xcf, 0x20, 0xff, 0xd9, | ||
| 28 | }; | ||
| 29 | |||
| 30 | QString FormatUserEntryText(const QString& username, Common::UUID uuid) { | 20 | QString FormatUserEntryText(const QString& username, Common::UUID uuid) { |
| 31 | return QtProfileSelectionDialog::tr( | 21 | return QtProfileSelectionDialog::tr( |
| 32 | "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " | 22 | "%1\n%2", "%1 is the profile username, %2 is the formatted UUID (e.g. " |
| @@ -45,7 +35,8 @@ QPixmap GetIcon(Common::UUID uuid) { | |||
| 45 | 35 | ||
| 46 | if (!icon) { | 36 | if (!icon) { |
| 47 | icon.fill(Qt::black); | 37 | icon.fill(Qt::black); |
| 48 | icon.loadFromData(backup_jpeg.data(), static_cast<u32>(backup_jpeg.size())); | 38 | icon.loadFromData(Core::Constants::ACCOUNT_BACKUP_JPEG.data(), |
| 39 | static_cast<u32>(Core::Constants::ACCOUNT_BACKUP_JPEG.size())); | ||
| 49 | } | 40 | } |
| 50 | 41 | ||
| 51 | return icon.scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); | 42 | return icon.scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |