优化 WeaselUI:预热并复用候选窗 DirectWrite 资源#1886
Open
dragonknightk wants to merge 1 commit into
Open
Conversation
Contributor
|
关于ui,我有重构一版在我的仓库的pb分支,拆完了,可能再等等看? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
UI::Prewarm(),在首次候选窗渲染前初始化DirectWriteResources。WeaselPanel复用UI持有的PDWR,避免预热资源和真实候选窗资源分离。背景
本地排查发现,首次显示候选窗时,Direct2D 的 DC render target 创建可能落在按键同步路径里。代表样本如下:
tsf.on_key_down总耗时280.56ms,其中ID2D1Factory::CreateDCRenderTarget耗时247.77ms。tsf.on_test_key_down总耗时192.03ms,其中ID2D1Factory::CreateDCRenderTarget耗时166.99ms。这段耗时发生在候选 UI 启动期间,用户体感上就是首次候选窗出现时输入卡顿。本 PR 将这部分资源准备尽量提前,并让真实候选面板复用预热后的资源,避免首次可见候选窗渲染在同一个按键同步路径上承担完整初始化成本。
改动边界
与已有 PR 的关系
与 #1839 都涉及候选面板生命周期,但本 PR 不改变
UI::Create()的幂等行为,也不改变面板销毁语义。与 #1869 都属于候选窗性能方向,但处理点不同:#1869 更关注候选窗重复显示和定位,本 PR 关注 DirectWrite/Direct2D 渲染资源的预热与复用。
测试
clang-format --style=file --Werror --dry-run。xmake f -a x64 -m release && xmake。WeaselUI和WeaselTSF相关代码路径可编译。