[Misc] Replaced const with constexpr where possible

This commit is contained in:
Xphalnos
2025-03-20 21:16:32 +01:00
committed by Radosław Gliński
parent d20620eb5e
commit 5f918ef28d
64 changed files with 191 additions and 190 deletions

View File

@@ -484,7 +484,7 @@ Presenter::PaintResult D3D12Presenter::PaintAndPresentImpl(
bool back_buffer_acquired = false;
bool back_buffer_bound = false;
bool back_buffer_clear_needed = true;
const float kBackBufferClearColor[] = {0.0f, 0.0f, 0.0f, 1.0f};
constexpr float kBackBufferClearColor[] = {0.0f, 0.0f, 0.0f, 1.0f};
// Draw the guest output.

View File

@@ -18,15 +18,15 @@
namespace xe {
namespace ui {
const int kMaxVertices = 16 << 10;
constexpr int kMaxVertices = 16 << 10;
const int kFontTextureWidth = 1024;
const int kFontTextureHeight = 9;
const int kFontCharWidth = 5;
const int kFontCharHeight = 8;
constexpr int kFontTextureWidth = 1024;
constexpr int kFontTextureHeight = 9;
constexpr int kFontCharWidth = 5;
constexpr int kFontCharHeight = 8;
// The last texel is for solid color.
const uint8_t kFontData[] = {
constexpr uint8_t kFontData[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View File

@@ -1,7 +1,7 @@
#include <utility>
#include <vector>
static const uint8_t player_one_notification_icon[] = {
static constexpr uint8_t player_one_notification_icon[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xc8,
0x08, 0x03, 0x00, 0x00, 0x00, 0x9a, 0x86, 0x5e, 0xac, 0x00, 0x00, 0x01,
@@ -843,8 +843,8 @@ static const uint8_t player_one_notification_icon[] = {
0x58, 0xd4, 0xdc, 0x23, 0xab, 0x5a, 0xab, 0xca, 0x0c, 0x37, 0x15, 0x26,
0x9a, 0xf0, 0x13, 0x17, 0x18, 0xe4, 0x66, 0x97, 0xad, 0xfd, 0xed, 0xe7,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
static const uint32_t player_one_notification_icon_len = 10092;
static const uint8_t player_two_notification_icon[] = {
static constexpr uint32_t player_one_notification_icon_len = 10092;
static constexpr uint8_t player_two_notification_icon[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xc8,
0x08, 0x03, 0x00, 0x00, 0x00, 0x9a, 0x86, 0x5e, 0xac, 0x00, 0x00, 0x01,
@@ -1694,8 +1694,8 @@ static const uint8_t player_two_notification_icon[] = {
0x59, 0xbf, 0xc7, 0x07, 0x68, 0x23, 0xbf, 0x02, 0x96, 0x37, 0xf1, 0x64,
0x78, 0x21, 0xeb, 0x57, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82};
static const uint32_t player_two_notification_icon_len = 10180;
static const uint8_t player_three_notification_icon[] = {
static constexpr uint32_t player_two_notification_icon_len = 10180;
static constexpr uint8_t player_three_notification_icon[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xc8,
0x08, 0x03, 0x00, 0x00, 0x00, 0x9a, 0x86, 0x5e, 0xac, 0x00, 0x00, 0x01,
@@ -2545,8 +2545,8 @@ static const uint8_t player_three_notification_icon[] = {
0x6a, 0xe6, 0x6e, 0xa6, 0x2a, 0x4c, 0x7b, 0xcd, 0x81, 0x05, 0x6f, 0x71,
0x02, 0xc0, 0x82, 0xc2, 0x2d, 0xcc, 0x87, 0x12, 0xac, 0x00, 0x00, 0x00,
0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
static const uint32_t player_three_notification_icon_len = 10185;
static const uint8_t player_four_notification_icon[] = {
static constexpr uint32_t player_three_notification_icon_len = 10185;
static constexpr uint8_t player_four_notification_icon[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xc8,
0x08, 0x03, 0x00, 0x00, 0x00, 0x9a, 0x86, 0x5e, 0xac, 0x00, 0x00, 0x01,
@@ -3405,8 +3405,8 @@ static const uint8_t player_four_notification_icon[] = {
0xc2, 0x8d, 0x78, 0xac, 0xb7, 0xf8, 0x07, 0xa4, 0x2c, 0x66, 0x66, 0x59,
0xf3, 0x58, 0x68, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82};
static const uint32_t player_four_notification_icon_len = 10287;
static const uint8_t player_any_notification_icon[] = {
static constexpr uint32_t player_four_notification_icon_len = 10287;
static constexpr uint8_t player_any_notification_icon[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xc8,
0x08, 0x03, 0x00, 0x00, 0x00, 0x9a, 0x86, 0x5e, 0xac, 0x00, 0x00, 0x01,
@@ -4267,9 +4267,9 @@ static const uint8_t player_any_notification_icon[] = {
0xb9, 0x01, 0x91, 0x58, 0x44, 0x55, 0x84, 0x09, 0x11, 0xf6, 0xec, 0xad,
0xa6, 0xf0, 0x15, 0x17, 0xd8, 0xd1, 0xd1, 0x7d, 0x69, 0x7e, 0xcd, 0x46,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
static const uint32_t player_any_notification_icon_len = 10320;
static constexpr uint32_t player_any_notification_icon_len = 10320;
static const uint8_t locked_achievement_icon_data[] = {
static constexpr uint8_t locked_achievement_icon_data[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80,
0x08, 0x06, 0x00, 0x00, 0x00, 0xc3, 0x3e, 0x61, 0xcb, 0x00, 0x00, 0x01,

View File

@@ -68,7 +68,7 @@ bool Win32WindowedAppContext::Initialize() {
// Create the message-only window for executing pending functions - using a
// window instead of executing them between iterations so non-main message
// loops, such as Windows modals, can execute pending functions too.
static const WCHAR kPendingFunctionsWindowClassName[] =
static constexpr WCHAR kPendingFunctionsWindowClassName[] =
L"XeniaPendingFunctionsWindowClass";
if (!pending_functions_window_class_registered_) {
WNDCLASSEXW pending_functions_window_class = {};

View File

@@ -45,10 +45,10 @@ static void write_process_memory(HANDLE process, uintptr_t offset,
}
}
static const unsigned char pattern_cmp_processorfeature_28_[] = {
static constexpr unsigned char pattern_cmp_processorfeature_28_[] = {
0x80, 0x3C, 0x25, 0x90,
0x02, 0xFE, 0x7F, 0x00}; // cmp byte ptr ds:7FFE0290h, 0
static const unsigned char pattern_replacement[] = {
static constexpr unsigned char pattern_replacement[] = {
0x48, 0x39, 0xe4, // cmp rsp, rsp = always Z
0x0F, 0x1F, 0x44, 0x00, 0x00 // 5byte nop
};