Repository navigation
fix(windows): 避免自动颜色管理开启时串流误启 HDR - #1183
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
HDR 状态 API 与行为测试 src/platform/windows/display_device/hdr_state_api.h, tests/unit/platform/windows/test_hdr_state_api.cpp |
新增 HDR 状态查询与设置逻辑。现代查询仅在返回 ERROR_INVALID_PARAMETER 或 ERROR_NOT_SUPPORTED 时使用旧版 API;其他错误直接返回。测试覆盖 HDR 与 ACM/WCG 状态区分、旧版回退及写入错误处理。 |
Windows 显示设备集成 src/platform/windows/display_device/windows_utils.cpp |
HDR 状态查询和设置改为调用新 API。查询失败时记录错误并返回 unknown;设置失败时记录错误并返回 false。 |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers: qiin2333
Merge Risk: 
Minimal · up to 181e6
-
The reported legacy-system behavior predates this change. No identified PR regression remains to block merging after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
|
nice work |
开启 Windows 自动颜色管理(ACM)但关闭 HDR 时,开始或结束串流可能把原有显示器的 HDR 打开。修复后按实际 HDR 用户开关保存、设置和恢复状态,ACM 可以继续开启。
原因与修改
旧
DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO::advancedColorEnabled表示某种高级颜色模式已开启,不能区分 SDR 的 WCG/ACM 与 HDR。Windows 11 26200 实机上,HDR 关闭且 ACM 开启时,旧接口仍报告 enabled;随后旧 setter 会真正开启 HDR。GET_ADVANCED_COLOR_INFO_2,读取highDynamicRangeSupported和highDynamicRangeUserEnabled。保存用户开关,避免系统策略暂时抑制 HDR 时错误覆盖其意图。SET_HDR_STATE,不写 WCG 开关。新接口已可用时,HDR 写入失败不会回退到旧的高级颜色 setter。ERROR_INVALID_PARAMETER/ERROR_NOT_SUPPORTED时使用原有接口,保留旧系统兼容;其他失败正常上报。Related: #13(历史讨论中已有关闭 ACM 的绕过办法)。
验证
NOMINMAX:7 个测试全部通过。.clang-format检查;git diff --check通过。独立代码审查已完成。验证边界
本机未配置仓库要求的完整 MSYS2/UCRT64 主机构建依赖,未完成整个 Sunshine 主机的构建,也未用补丁二进制完成 Moonlight 连接/退出循环。旧 Windows 的回退路径已模拟测试,尚未旧系统实机验证。
旧版本已持久化的
original_hdr_states=enabled无法区分真实 HDR 与误存的 ACM,不会盲目迁移;遇到旧快照时,应在非串流状态重置 Sunshine 显示设备记忆,再确认 Windows HDR 设置。