summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-06-07 18:39:37 -0400
committerGravatar GitHub2019-06-07 18:39:37 -0400
commit357ea15a39645213ee52fe8fcf8cd06f7eea208e (patch)
tree3f723cd6b6ba53248d2d35869bd274afde52e18d /src/core
parentMerge pull request #2514 from ReinUsesLisp/opengl-compat (diff)
parentconstants: Extract backup JPEG used by account services (diff)
downloadyuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar.gz
yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.tar.xz
yuzu-357ea15a39645213ee52fe8fcf8cd06f7eea208e.zip
Merge pull request #2293 from DarkLordZach/system-constants
core: Remove duplicated account JPEG data structure
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/constants.cpp17
-rw-r--r--src/core/constants.h17
-rw-r--r--src/core/hle/service/acc/acc.cpp20
4 files changed, 40 insertions, 16 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
7namespace Core::Constants {
8const 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.
12namespace Core::Constants {
13
14// ACC Service - Blank JPEG used as user icon in absentia of real one.
15extern 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
22namespace Service::Account { 23namespace 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
26constexpr u32 backup_jpeg_size = 107;
27constexpr 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
37static std::string GetImagePath(Common::UUID uuid) { 25static 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 }