diff options
Diffstat (limited to 'src/common')
33 files changed, 52 insertions, 44 deletions
diff --git a/src/common/atomic_ops.h b/src/common/atomic_ops.h index 2b1f515e8..b94d73c7a 100644 --- a/src/common/atomic_ops.h +++ b/src/common/atomic_ops.h @@ -4,13 +4,12 @@ #pragma once -#include <cstring> -#include <memory> - #include "common/common_types.h" #if _MSC_VER #include <intrin.h> +#else +#include <cstring> #endif namespace Common { diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 0f0661172..7f8620e7d 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -33,7 +33,6 @@ #include <cstddef> #include <limits> #include <type_traits> -#include "common/common_funcs.h" #include "common/swap.h" /* diff --git a/src/common/dynamic_library.cpp b/src/common/dynamic_library.cpp index 7f0a10521..11003e1d6 100644 --- a/src/common/dynamic_library.cpp +++ b/src/common/dynamic_library.cpp @@ -2,7 +2,6 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include <cstring> #include <string> #include <utility> diff --git a/src/common/fs/file.cpp b/src/common/fs/file.cpp index 274f57659..5d71275ef 100644 --- a/src/common/fs/file.cpp +++ b/src/common/fs/file.cpp @@ -4,7 +4,6 @@ #include "common/fs/file.h" #include "common/fs/fs.h" -#include "common/fs/path_util.h" #include "common/logging/log.h" #ifdef _WIN32 diff --git a/src/common/fs/file.h b/src/common/fs/file.h index a4f7944cd..8a2cab0af 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h @@ -6,10 +6,8 @@ #include <cstdio> #include <filesystem> -#include <fstream> #include <span> #include <type_traits> -#include <vector> #include "common/concepts.h" #include "common/fs/fs_types.h" diff --git a/src/common/fs/fs_types.h b/src/common/fs/fs_types.h index 089980aee..f5853f624 100644 --- a/src/common/fs/fs_types.h +++ b/src/common/fs/fs_types.h @@ -7,7 +7,6 @@ #include <functional> #include "common/common_funcs.h" -#include "common/common_types.h" namespace Common::FS { diff --git a/src/common/fs/fs_util.h b/src/common/fs/fs_util.h index 1620d38c9..392af89f7 100644 --- a/src/common/fs/fs_util.h +++ b/src/common/fs/fs_util.h @@ -8,7 +8,6 @@ #include <filesystem> #include <span> #include <string> -#include <string_view> #include "common/common_types.h" diff --git a/src/common/hex_util.h b/src/common/hex_util.h index 5e9b6ef8b..323c8fb33 100644 --- a/src/common/hex_util.h +++ b/src/common/hex_util.h @@ -7,7 +7,6 @@ #include <array> #include <cstddef> #include <string> -#include <type_traits> #include <vector> #include <fmt/format.h> #include "common/common_types.h" diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index c465cfc14..e829af1ac 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -18,6 +18,7 @@ #include <fcntl.h> #include <sys/mman.h> #include <unistd.h> +#include "common/scope_exit.h" #endif // ^^^ Linux ^^^ @@ -27,7 +28,6 @@ #include "common/assert.h" #include "common/host_memory.h" #include "common/logging/log.h" -#include "common/scope_exit.h" namespace Common { diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h index b296b639e..eaf5675e3 100644 --- a/src/common/intrusive_red_black_tree.h +++ b/src/common/intrusive_red_black_tree.h @@ -4,7 +4,6 @@ #pragma once -#include "common/alignment.h" #include "common/common_funcs.h" #include "common/parent_of_member.h" #include "common/tree.h" diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 4a2462ec4..b3793106d 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -5,10 +5,8 @@ #include <atomic> #include <chrono> #include <climits> -#include <exception> #include <stop_token> #include <thread> -#include <vector> #include <fmt/format.h> diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index bf785f402..a0e80fe3c 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -4,7 +4,6 @@ #pragma once -#include <filesystem> #include "common/logging/filter.h" namespace Common::Log { diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 4afc1369a..9120cc178 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -119,6 +119,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Service, NPNS) \ SUB(Service, NS) \ SUB(Service, NVDRV) \ + SUB(Service, NVFlinger) \ SUB(Service, OLSC) \ SUB(Service, PCIE) \ SUB(Service, PCTL) \ diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h index 1a3074e04..29419f051 100644 --- a/src/common/logging/filter.h +++ b/src/common/logging/filter.h @@ -7,7 +7,6 @@ #include <array> #include <chrono> #include <cstddef> -#include <string_view> #include "common/logging/log.h" namespace Common::Log { diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 10b2281db..b2cad58d8 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -10,12 +10,10 @@ #endif #include "common/assert.h" -#include "common/common_funcs.h" #include "common/logging/filter.h" #include "common/logging/log.h" #include "common/logging/log_entry.h" #include "common/logging/text_formatter.h" -#include "common/string_util.h" namespace Common::Log { diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h index 171e74cfe..92c0bf0c5 100644 --- a/src/common/logging/text_formatter.h +++ b/src/common/logging/text_formatter.h @@ -4,7 +4,6 @@ #pragma once -#include <cstddef> #include <string> namespace Common::Log { diff --git a/src/common/logging/types.h b/src/common/logging/types.h index 2b6e4daa7..f803ab796 100644 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -87,6 +87,7 @@ enum class Class : u8 { Service_NPNS, ///< The NPNS service Service_NS, ///< The NS services Service_NVDRV, ///< The NVDRV (Nvidia driver) service + Service_NVFlinger, ///< The NVFlinger service Service_OLSC, ///< The OLSC service Service_PCIE, ///< The PCIe service Service_PCTL, ///< The PCTL (Parental control) service diff --git a/src/common/math_util.h b/src/common/math_util.h index 510c4e56d..54485bf53 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -4,6 +4,7 @@ #pragma once +#include <algorithm> #include <cstdlib> #include <type_traits> @@ -20,10 +21,32 @@ struct Rectangle { constexpr Rectangle() = default; + constexpr Rectangle(T width, T height) : right(width), bottom(height) {} + constexpr Rectangle(T left_, T top_, T right_, T bottom_) : left(left_), top(top_), right(right_), bottom(bottom_) {} - [[nodiscard]] T GetWidth() const { + [[nodiscard]] constexpr T Left() const { + return left; + } + + [[nodiscard]] constexpr T Top() const { + return top; + } + + [[nodiscard]] constexpr T Right() const { + return right; + } + + [[nodiscard]] constexpr T Bottom() const { + return bottom; + } + + [[nodiscard]] constexpr bool IsEmpty() const { + return (GetWidth() <= 0) || (GetHeight() <= 0); + } + + [[nodiscard]] constexpr T GetWidth() const { if constexpr (std::is_floating_point_v<T>) { return std::abs(right - left); } else { @@ -31,7 +54,7 @@ struct Rectangle { } } - [[nodiscard]] T GetHeight() const { + [[nodiscard]] constexpr T GetHeight() const { if constexpr (std::is_floating_point_v<T>) { return std::abs(bottom - top); } else { @@ -39,18 +62,35 @@ struct Rectangle { } } - [[nodiscard]] Rectangle<T> TranslateX(const T x) const { + [[nodiscard]] constexpr Rectangle<T> TranslateX(const T x) const { return Rectangle{left + x, top, right + x, bottom}; } - [[nodiscard]] Rectangle<T> TranslateY(const T y) const { + [[nodiscard]] constexpr Rectangle<T> TranslateY(const T y) const { return Rectangle{left, top + y, right, bottom + y}; } - [[nodiscard]] Rectangle<T> Scale(const float s) const { + [[nodiscard]] constexpr Rectangle<T> Scale(const float s) const { return Rectangle{left, top, static_cast<T>(static_cast<float>(left + GetWidth()) * s), static_cast<T>(static_cast<float>(top + GetHeight()) * s)}; } + + [[nodiscard]] constexpr bool operator==(const Rectangle<T>& rhs) const { + return (left == rhs.left) && (top == rhs.top) && (right == rhs.right) && + (bottom == rhs.bottom); + } + + [[nodiscard]] constexpr bool operator!=(const Rectangle<T>& rhs) const { + return !operator==(rhs); + } + + [[nodiscard]] constexpr bool Intersect(const Rectangle<T>& with, Rectangle<T>* result) const { + result->left = std::max(left, with.left); + result->top = std::max(top, with.top); + result->right = std::min(right, with.right); + result->bottom = std::min(bottom, with.bottom); + return !result->IsEmpty(); + } }; template <typename T> diff --git a/src/common/memory_detect.cpp b/src/common/memory_detect.cpp index 8cff6ec37..7a75a5ff4 100644 --- a/src/common/memory_detect.cpp +++ b/src/common/memory_detect.cpp @@ -70,4 +70,4 @@ const MemoryInfo& GetMemInfo() { return mem_info; } -} // namespace Common
\ No newline at end of file +} // namespace Common diff --git a/src/common/nvidia_flags.cpp b/src/common/nvidia_flags.cpp index d1afd1f1d..c732c233e 100644 --- a/src/common/nvidia_flags.cpp +++ b/src/common/nvidia_flags.cpp @@ -6,7 +6,6 @@ #include <fmt/format.h> -#include "common/fs/file.h" #include "common/fs/fs.h" #include "common/fs/path_util.h" #include "common/nvidia_flags.h" diff --git a/src/common/page_table.h b/src/common/page_table.h index 82d91e9f3..13f4b44c0 100644 --- a/src/common/page_table.h +++ b/src/common/page_table.h @@ -5,7 +5,6 @@ #pragma once #include <atomic> -#include <tuple> #include "common/common_types.h" #include "common/virtual_buffer.h" diff --git a/src/common/parent_of_member.h b/src/common/parent_of_member.h index 58c70b0e7..ad075615b 100644 --- a/src/common/parent_of_member.h +++ b/src/common/parent_of_member.h @@ -7,7 +7,6 @@ #include <type_traits> #include "common/assert.h" -#include "common/common_types.h" namespace Common { namespace detail { diff --git a/src/common/ring_buffer.h b/src/common/ring_buffer.h index 4a8d09806..db6aa6b95 100644 --- a/src/common/ring_buffer.h +++ b/src/common/ring_buffer.h @@ -12,7 +12,6 @@ #include <new> #include <type_traits> #include <vector> -#include "common/common_types.h" namespace Common { diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 662171138..3695dae4d 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -5,11 +5,9 @@ #include <algorithm> #include <cctype> #include <codecvt> -#include <cstdlib> #include <locale> #include <sstream> -#include "common/logging/log.h" #include "common/string_util.h" #ifdef _WIN32 diff --git a/src/common/telemetry.cpp b/src/common/telemetry.cpp index 98c82cd17..67261c55b 100644 --- a/src/common/telemetry.cpp +++ b/src/common/telemetry.cpp @@ -4,7 +4,6 @@ #include <algorithm> #include <cstring> -#include "common/assert.h" #include "common/scm_rev.h" #include "common/telemetry.h" diff --git a/src/common/telemetry.h b/src/common/telemetry.h index 3524c857e..f9a824a7d 100644 --- a/src/common/telemetry.h +++ b/src/common/telemetry.h @@ -8,7 +8,6 @@ #include <map> #include <memory> #include <string> -#include <string_view> #include "common/common_funcs.h" #include "common/common_types.h" diff --git a/src/common/uint128.h b/src/common/uint128.h index 4780b2f9d..ad1b90414 100644 --- a/src/common/uint128.h +++ b/src/common/uint128.h @@ -4,7 +4,6 @@ #pragma once -#include <cstring> #include <utility> #ifdef _MSC_VER @@ -13,6 +12,7 @@ #pragma intrinsic(_umul128) #pragma intrinsic(_udiv128) #else +#include <cstring> #include <x86intrin.h> #endif diff --git a/src/common/uuid.h b/src/common/uuid.h index fe31e64e6..c450d9e20 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h @@ -7,7 +7,6 @@ #include <array> #include <functional> #include <string> -#include <string_view> #include "common/common_types.h" diff --git a/src/common/virtual_buffer.h b/src/common/virtual_buffer.h index fb1a6f81f..cac4f4895 100644 --- a/src/common/virtual_buffer.h +++ b/src/common/virtual_buffer.h @@ -4,7 +4,6 @@ #pragma once -#include <type_traits> #include <utility> namespace Common { diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp index 9acf7551e..f30d91692 100644 --- a/src/common/wall_clock.cpp +++ b/src/common/wall_clock.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <cstdint> - #include "common/uint128.h" #include "common/wall_clock.h" diff --git a/src/common/x64/cpu_detect.cpp b/src/common/x64/cpu_detect.cpp index d81edb140..f5296b32a 100644 --- a/src/common/x64/cpu_detect.cpp +++ b/src/common/x64/cpu_detect.cpp @@ -4,7 +4,6 @@ #include <array> #include <cstring> #include <iterator> -#include <span> #include <string_view> #include "common/bit_util.h" #include "common/common_types.h" diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index 91b842829..347e41efc 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp @@ -4,8 +4,6 @@ #include <array> #include <chrono> -#include <limits> -#include <mutex> #include <thread> #include "common/atomic_ops.h" diff --git a/src/common/x64/native_clock.h b/src/common/x64/native_clock.h index 7cbd400d2..2c3082ea0 100644 --- a/src/common/x64/native_clock.h +++ b/src/common/x64/native_clock.h @@ -4,8 +4,6 @@ #pragma once -#include <optional> - #include "common/wall_clock.h" namespace Common { |