mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
refactor: 共享代码使用 Magpie 命名空间
This commit is contained in:
parent
d816d67683
commit
c178e071a7
19 changed files with 64 additions and 9 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
<Type Name="SmallVectorImpl<*>">
|
||||
<Type Name="Magpie::SmallVectorImpl<*>">
|
||||
<DisplayString IncludeView ="elt0" Condition="Size == 0"></DisplayString>
|
||||
<DisplayString IncludeView ="elt0">{(($T1*)BeginX)[0]}{*this,view(elt1)}</DisplayString>
|
||||
<DisplayString IncludeView ="elt1" Condition="Size == 1"></DisplayString>
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ bool ShaderEffectParser::ParseForDesc(
|
|||
if (!source.ends_with('\n')) {
|
||||
source.push_back('\n');
|
||||
}
|
||||
std::string_view sourceView(source);
|
||||
// std::string_view sourceView(source);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#endif
|
||||
#include "CommonSharedConstants.h"
|
||||
|
||||
using namespace Magpie;
|
||||
using namespace winrt::Windows::UI::Xaml::Input;
|
||||
|
||||
namespace winrt::Magpie::implementation {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ struct Row {
|
|||
size = {};
|
||||
}
|
||||
|
||||
SmallVector<UvRect> childrenRects;
|
||||
::Magpie::SmallVector<UvRect> childrenRects;
|
||||
UvMeasure size;
|
||||
};
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ private:
|
|||
Thickness _padding{};
|
||||
winrt::Magpie::StretchChild _stretchChild = StretchChild::None;
|
||||
|
||||
SmallVector<Row, 0> _rows;
|
||||
::Magpie::SmallVector<Row, 0> _rows;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
struct CommonSharedConstants {
|
||||
static constexpr const wchar_t* SINGLE_INSTANCE_MUTEX_NAME = L"{4C416227-4A30-4A2F-8F23-8701544DD7D6}";
|
||||
static constexpr const wchar_t* TOUCH_HELPER_SINGLE_INSTANCE_MUTEX_NAME = L"{BD7A3F98-F4A9-44B6-9C8A-17B8DE00FEC3}";
|
||||
|
|
@ -43,3 +45,5 @@ struct CommonSharedConstants {
|
|||
|
||||
static constexpr int MAX_LOG_SIZE = 500000;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef MP_DEBUG_INFO
|
||||
namespace Magpie {
|
||||
|
||||
#ifdef MP_DEBUG_INFO
|
||||
// 不要定义成匿名类,和 inline 冲突
|
||||
struct DebugInfo {
|
||||
// 模拟低速 GPU
|
||||
|
|
@ -60,5 +61,6 @@ struct DebugInfo {
|
|||
};
|
||||
|
||||
inline DebugInfo DEBUG_INFO;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include "StrHelper.h"
|
||||
#include <spdlog/sinks/rotating_file_sink.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
bool Logger::Initialize(spdlog::level::level_enum logLevel, std::wstring logFileName, int logArchiveAboveSize, int logMaxArchiveFiles) noexcept {
|
||||
try {
|
||||
_logger = spdlog::rotating_logger_mt(".", std::move(logFileName), logArchiveAboveSize, logMaxArchiveFiles);
|
||||
|
|
@ -55,3 +57,5 @@ void Logger::_Log(spdlog::level::level_enum logLevel, std::string_view msg, cons
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
#endif
|
||||
#include <fmt/printf.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
// std::source_location 中的函数名包含整个签名过于冗长,我们只需记录函数名,
|
||||
// 因此创建自己的 SourceLocation
|
||||
struct SourceLocation {
|
||||
|
|
@ -144,3 +146,5 @@ private:
|
|||
|
||||
std::shared_ptr<spdlog::logger> _logger;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
// Check that no bytes are wasted and everything is well-aligned.
|
||||
namespace {
|
||||
struct Struct16B {
|
||||
|
|
@ -148,3 +150,5 @@ template class SmallVectorBase<uint64_t>;
|
|||
// Assertions to ensure this #if stays in sync with SmallVectorSizeType.
|
||||
static_assert(sizeof(SmallVectorSizeType<char>) == sizeof(uint64_t),
|
||||
"Expected SmallVectorBase<uint64_t> variant to be in use.");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@
|
|||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
template <class Iterator>
|
||||
using EnableIfConvertibleToInputIterator = std::enable_if_t<std::is_convertible<
|
||||
typename std::iterator_traits<Iterator>::iterator_category,
|
||||
|
|
@ -1317,17 +1319,19 @@ template <typename Out, typename R> SmallVector<Out> to_vector_of(R&& Range) {
|
|||
return { std::begin(Range), std::end(Range) };
|
||||
}
|
||||
|
||||
} // end namespace Magpie
|
||||
|
||||
namespace std {
|
||||
|
||||
/// Implement std::swap in terms of SmallVector swap.
|
||||
template <typename T>
|
||||
inline void swap(SmallVectorImpl<T>& LHS, SmallVectorImpl<T>& RHS) {
|
||||
inline void swap(::Magpie::SmallVectorImpl<T>& LHS, ::Magpie::SmallVectorImpl<T>& RHS) {
|
||||
LHS.swap(RHS);
|
||||
}
|
||||
|
||||
/// Implement std::swap in terms of SmallVector swap.
|
||||
template <typename T, unsigned N>
|
||||
inline void swap(SmallVector<T, N>& LHS, SmallVector<T, N>& RHS) {
|
||||
inline void swap(::Magpie::SmallVector<T, N>& LHS, ::Magpie::SmallVector<T, N>& RHS) {
|
||||
LHS.swap(RHS);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include "StrHelper.h"
|
||||
#include "Logger.h"
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
std::wstring StrHelper::UTF8ToUTF16(std::string_view str) noexcept {
|
||||
if (str.empty()) {
|
||||
return {};
|
||||
|
|
@ -61,3 +63,5 @@ std::string StrHelper::UTF16ToUTF8(std::wstring_view str) noexcept {
|
|||
std::string StrHelper::UTF16ToANSI(std::wstring_view str) noexcept {
|
||||
return UTF16ToOther(CP_ACP, str);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <wtypes.h> // BSTR
|
||||
#include "SmallVector.h"
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
struct StrHelper {
|
||||
static std::wstring UTF8ToUTF16(std::string_view str) noexcept;
|
||||
|
||||
|
|
@ -265,3 +267,5 @@ private:
|
|||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include "Version.h"
|
||||
#include "StrHelper.h"
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
bool Version::Parse(std::string_view str) noexcept {
|
||||
if (str.empty()) {
|
||||
return false;
|
||||
|
|
@ -32,3 +34,5 @@ bool Version::Parse(std::string_view str) noexcept {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
#include <tuple>
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
struct Version {
|
||||
constexpr Version() {}
|
||||
constexpr Version(uint32_t major, uint32_t minor, uint32_t patch)
|
||||
|
|
@ -26,3 +28,5 @@ struct Version {
|
|||
uint32_t minor = 0;
|
||||
uint32_t patch = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "Logger.h"
|
||||
#include <magnification.h>
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
static const UINT WM_MAGPIE_SCALINGCHANGED =
|
||||
RegisterWindowMessage(CommonSharedConstants::WM_MAGPIE_SCALINGCHANGED);
|
||||
// 用于与主程序交互。wParam 的值:
|
||||
|
|
@ -40,7 +42,7 @@ bool App::Initialzie() noexcept {
|
|||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int App::Run() noexcept {
|
||||
|
|
@ -277,3 +279,5 @@ void App::_Uninitialize() noexcept {
|
|||
_hSingleInstanceMutex.reset();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
class App {
|
||||
public:
|
||||
static App& Get() noexcept {
|
||||
|
|
@ -36,3 +38,5 @@ private:
|
|||
bool _isInputTransformEnabled = false;
|
||||
bool _isTimerOn = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#include "CommonSharedConstants.h"
|
||||
#include "Logger.h"
|
||||
|
||||
using namespace Magpie;
|
||||
|
||||
static void InitializeLogger() noexcept {
|
||||
// 日志文件创建在 Temp 目录中
|
||||
std::wstring logPath(MAX_PATH + 1, L'\0');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include "pch.h"
|
||||
#include "Version.h"
|
||||
|
||||
namespace Magpie {
|
||||
|
||||
static constexpr const wchar_t* V0_9_101_FILES[] = {
|
||||
L"assets\\NotoSansSC-Regular.otf",
|
||||
L"effects\\Anime4K\\Anime4K_3D_AA_Upscale_US.hlsl",
|
||||
|
|
@ -819,3 +821,5 @@ private:
|
|||
return std::span((const wchar_t**)arr, N);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include "Version.h"
|
||||
#include <shellapi.h>
|
||||
|
||||
using namespace Magpie;
|
||||
|
||||
static void InitializeLogger() noexcept {
|
||||
// 日志文件创建在 Temp 目录中
|
||||
std::wstring logPath(MAX_PATH + 1, L'\0');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue