Magpie/src/Magpie.Core/ScalingOptions.cpp
Xu d8dd777053
优化显卡选择并实现监听显卡变化 (#1037)
* fix: 优化初始化失败逻辑

* feat: 实现 AdapterService 功能

* feat: 优化 GPU 选择

* feat: 实现根据显卡改变更新配置文件

* feat: 支持检测运行时显卡变化

* feat: 排除不支持功能级别 11 的显卡

* perf: 延迟检查显卡的功能级别以加快主窗口显示

* fix: 确保检查显卡的功能级别在主窗口显示后执行
2024-12-24 20:52:40 +08:00

99 lines
2.3 KiB
C++

#include "pch.h"
#include "ScalingOptions.h"
#include "Logger.h"
#include "StrHelper.h"
namespace Magpie {
static std::string LogParameters(const phmap::flat_hash_map<std::wstring, float>& params) noexcept {
std::string result;
if (params.empty()) {
result = "";
} else {
for (const auto& pair : params) {
result.append(fmt::format("\n\t\t\t\t{}: {}", StrHelper::UTF16ToUTF8(pair.first), pair.second));
}
}
return result;
}
static std::string LogEffects(const std::vector<EffectOption>& effects) noexcept {
std::string result;
for (const EffectOption& effect : effects) {
result.append(fmt::format(R"(
{}
scalingType: {}
scale: {},{}
parameters: {})",
StrHelper::UTF16ToUTF8(effect.name),
(int)effect.scalingType,
effect.scale.first, effect.scale.second,
LogParameters(effect.parameters)
));
}
return result;
}
void ScalingOptions::Log() const noexcept {
Logger::Get().Info(fmt::format(R"(缩放选项
IsWindowResizingDisabled: {}
IsDebugMode: {}
IsEffectCacheDisabled: {}
IsFontCacheDisabled: {}
IsSaveEffectSources: {}
IsWarningsAreErrors: {}
IsAllowScalingMaximized: {}
IsSimulateExclusiveFullscreen: {}
Is3DGameMode: {}
IsShowFPS: {}
IsCaptureTitleBar: {}
IsAdjustCursorSpeed: {}
IsDrawCursor: {}
IsDirectFlipDisabled: {}
IsStatisticsForDynamicDetectionEnabled: {}
IsTouchSupportEnabled: {}
cropping: {},{},{},{}
graphicsCardId:
idx: {}
venderId: {}
deviceId: {}
maxFrameRate: {}
cursorScaling: {}
captureMethod: {}
multiMonitorUsage: {}
cursorInterpolationMode: {}
duplicateFrameDetectionMode: {}
effects: {})",
IsWindowResizingDisabled(),
IsDebugMode(),
IsEffectCacheDisabled(),
IsFontCacheDisabled(),
IsSaveEffectSources(),
IsWarningsAreErrors(),
IsAllowScalingMaximized(),
IsSimulateExclusiveFullscreen(),
Is3DGameMode(),
IsShowFPS(),
IsCaptureTitleBar(),
IsAdjustCursorSpeed(),
IsDrawCursor(),
IsDirectFlipDisabled(),
IsStatisticsForDynamicDetectionEnabled(),
IsTouchSupportEnabled(),
cropping.Left, cropping.Top, cropping.Right, cropping.Bottom,
graphicsCardId.idx,
graphicsCardId.vendorId,
graphicsCardId.deviceId,
maxFrameRate.has_value() ? *maxFrameRate : 0.0f,
cursorScaling,
(int)captureMethod,
(int)multiMonitorUsage,
(int)cursorInterpolationMode,
(int)duplicateFrameDetectionMode,
LogEffects(effects)
));
}
}