API inconsistency with DPI_AWARE flag
还没有人认领这个 Issue。
- #100 来自 @EthanBlazkowicz —— 已关闭,未合并
评估
调研方向
首先跟踪 r_renderer_c::VirtualScreenScaleFactor() 以及 GetScreenSize 和 GetScaleFactor API 入口点,然后比较渲染函数如何处理其位置和大小参数。检查 PR 44、80 和 86 中的 DPI_AWARE 更改,以及相关的 Win32/GLFW 缩放代码。API 契约和运行时缩放行为保持一致,并且预期的 Lua 行为已由测试或有文档记录的验证路径覆盖,即表示完成。
由索引模型根据 Issue 内容生成。
描述
The DPI_AWARE flag was introduced with https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic/pull/44/commits/59492a4003ea77c03f9ae62c5e66a13afd02f313 as a way for the Lua code to opt out of the virtualization and get access to physical sizes/positions.
With the recent work on UI scaling in https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic/pull/80 and https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic/pull/86, the API has ended up in an inconsistent state where some functions use physical units if DPI_AWARE is set, but others still use virtual units in its arguments and return values.
For example, GetScreenSize returns physical units (i.e. the pixel size of the framebuffer), while all the other API functions still receive and return virtual units. It looks like PoB Lua code is not ready to deal with physical units, so the screen size is actually mapped right back to virtual units. Maybe PoB just shouldn't set the DPI_AWARE flag yet because everything seems to be done in virtual units at the moment. But that leads us to the second problem(?):
With the current implementation of r_renderer_c::VirtualScreenScaleFactor() and its usage in the API functions, the DPI_AWARE flag seems to serve two different functions:
- A way to influence the "API contract" between the Lua code and SimpleGraphic. Setting it tells the API to accept and return positions and sizes in physical units instead of virtual units (this seems to be in line with the original intention of this flag).
- To control whether application UI scaling is performed by the runtime. Before the recent changes,
VirtualScreenScaleFactorwas only used to determine which factor to return to Lua in theGetScaleFactorAPI function. Currently, it is also being used in the render functions to scale their position/size arguments. Not setting the flag means1.0is always returned, effectively turning off scaling.
The second behavior surprised me a bit. This means we cannot unset the flag and only use virtual units between Lua <-> Runtime because it would turn off the scaling entirely.
Here is how i expected it to work:
- Make the runtime always DPI aware and perform app scaling: I'm not very familiar with the win32 api but it looks like we can tell the OS that our application is per-monitor (v2) DPI aware. Maybe that's already the case? I've also spotted code that checks registry values to decide whether to ignore the scaling factor returned by GLFW. Not sure if that's needed anymore.
- Have the flag only affect the API contract, meaning physical units are used between Lua and SimpleGraphic if the flag is set, otherwise we only let Lua know about the virtual world. Not setting the flag shouldn't have any effect on whether scaling is performed.
- If users want to override the scaling factor given by the OS, they can use the newly added scaling factor override in the settings.
- With these changes, we can unset the
DPI_AWAREflag again, since PoB doesn't currently care about the physical world, but still retain the scaling behavior.
If i'm missing something or wrongly interpreted the intention behind the flag, then just ignore my approach. This API inconsistency manifested itself in a very minor problem that I've opted to fix on the Lua side for now: https://github.com/PathOfBuildingCommunity/PathOfBuilding/pull/9373.
- 主要语言
- C++
- 星标
- 22
- 派生
- 62
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 30/100
-
难度 3/5 1-2 天 新手友好度 45/100
-
难度 2/5 1-3 小时 新手友好度 45/100
查看 PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic 的全部 Issue
相似的 Issue
-
upstream update
难度 2/5 1-3 小时 新手友好度 65/100
conan-io/conan-center-index#31142 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 84/100
NVIDIA/DeepStream#78 ·