Snapshot before max-resize threshold diagnosis

This commit is contained in:
Codex
2026-04-09 03:23:10 +08:00
parent 77a8fe568a
commit f567369300
25 changed files with 1489 additions and 36 deletions
+37 -2
View File
@@ -126,8 +126,10 @@ void Control::requestRepaint(Control* parent)
{
if (shouldDeferManagedRepaint())
{
// 托管路径:当前正在 Window 的事件分发阶段,不能立即绘制;
// 这里只登记 source,真正的 root 选择由 Window 在 requestManagedRepaint 中完成。
if (auto* host = getHostWindow())
host->requestManagedRepaint();
host->requestManagedRepaint(this);
return;
}
@@ -157,8 +159,10 @@ void Control::onRequestRepaintAsRoot()
{
if (shouldDeferManagedRepaint())
{
// 即使已经冒泡到 root,只要还在托管分发期,也不能直接绘制;
// 仍然回到 Window 做统一提交。
if (auto* host = getHostWindow())
host->requestManagedRepaint();
host->requestManagedRepaint(this);
return;
}
@@ -178,6 +182,9 @@ bool Control::shouldDeferManagedRepaint() const
return host && host->isManagedDispatchActive();
}
// 获取宿主 Window
// - 顶层控件由 Window/addDialog 直接注入;
// - 子控件没有直接注入时,沿 parent 链向上回溯即可。
Window* Control::getHostWindow() const
{
if (hostWindow)
@@ -185,6 +192,18 @@ Window* Control::getHostWindow() const
return parent ? parent->getHostWindow() : nullptr;
}
// 托管重绘 root 选择规则:
// - 对于直接挂在 Window 下的控件,root 就是它自己;
// - 对于嵌套在 Canvas/TabControl/Dialog 内的子控件,沿 parent 向上找到与宿主 Window 同属一棵树的最上层控件。
Control* Control::getManagedRepaintRoot()
{
Control* root = this;
Window* host = getHostWindow();
while (root->parent && root->parent->getHostWindow() == host)
root = root->parent;
return root;
}
RECT Control::getBoundsRect() const
{
RECT rc{};
@@ -195,6 +214,22 @@ RECT Control::getBoundsRect() const
return rc;
}
bool Control::canCommitManagedPartialRepaint() const
{
// 基类默认不承诺自己能安全做局部提交;
// 只有 Canvas / TabControl / Dialog 这类“拥有完整背景语义”的 root 才会 override 为 true。
return false;
}
void Control::commitManagedRepaint()
{
if (!show)
return;
// 基类兜底:如果没有更具体的容器实现,就按根级重绘处理。
if (dirty)
onRequestRepaintAsRoot();
}
void Control::saveBackground(int x, int y, int w, int h)
{