fix(UI): 边界框不再内缩 + 文本获得几何身份 + 补全漏项 + 描边提速 32%
## 1. 取消内缩(这是"边框不清晰"的主因)
第九轮为"父子矩形共边不叠粗"给 depth > 0 的 box 加了 1px 内缩。结果 GX 徽标
(30x17 逻辑像素的胶囊,圆角 = 高的一半,外接矩形正好等于 LaneBadgeRect)内缩 1px 后
框比形状小一圈 ⇒ 左右尖端与上下圆弧全部落在框外。
现行规则:**框 = 可见形状的外接矩形,绝不内缩**。父子共边时让"后画的覆盖"即可,
这本来就是正确的图层语义。层级 > 0 只影响配色,不再影响几何。
## 2. 文本第一次有了几何身份(唯一出口回报,不逐处登记)
文本是本项目唯一"没有几何身份"的元素:65 处绘制点各自现算 gd::RectF、画完即弃。
逐处补登记必漏,因此在唯一出口回报一次:
PaintUtil 新增
class UiTextRectSink { virtual void OnTextRect(const gd::RectF&) = 0; };
void UiSetTextRectSink(UiTextRectSink*); // 开关关闭时为 nullptr
void UiSetTextRectOffset(float dx, float dy); // 离屏位图渲染的坐标换算
UiTextRectSink* UiGetTextRectSink();
DrawUiText() / UiTextAtClipped() 画完后按对齐方式 + 实测宽高把布局矩形**收窄成墨迹矩形**
再回报。UiDebugBoxList 直接继承该接口,宿主只需 UiSetTextRectSink(&m_debugBoxes) 一句。
开关关闭时只是一次空指针判断,正常绘制零影响。
## 3. 缓存命中的行也要有文本框
面板的行是"先画进位图再贴回",命中缓存的帧**根本不调用 UiText** ⇒ 文本框第二帧起消失。
做法:行渲染时用本地 RowTextCollector 收集(位图坐标)→ 连同位图存进
RowBitmapCache::textRects → 贴图时按 (originX, originY) 回放。
⚠️ **必须无条件收集**:只在"外层有收集器"时收集会导致"关调试时滚过列表 → 打开调试 →
命中缓存 → 永远没有文本框"。
## 4. 补齐 PlotView 漏项(全部读现成成员)
m_timeAxisRect / m_scrollBarRect / BackToTopRect() / m_cursorSpanRect /
m_cursorLabelRects / EditFieldRect()
## 5. 描边提速:图元 12 → 8
微基准结论:图元数量是唯一瓶颈(每次 FillRectangle ≈1µs)。
旧实现把每条边拆成"中段 1px + 两端各一段加粗"= 12 次;新实现 = 4 条 1px 边 + 4 个自适应角块。
实测 paintBoxes 5.892ms → 4.028ms(-32%),观感几乎一致(角仍是两条粗边的交点)。
⚠️ 不要改写成 GraphicsPath/FillPath(单次约 20µs,比 12 段还慢);
GDI PolyPolygon 一次画 5688 个矩形要 114ms,更不能用。
## 6. 关闭开关时清空容器(释放内存,避免误读)
## 7. 验证
- make release / make debug 零 error 零 warning;TargetCheck.exe 909,824 B(888.5 KiB < 900 KiB)。
- 新增探针 .preflight/lbcovr 7/7:box-time-axis / box-plot-scrollbar / box-back-to-top /
box-gx-badge-matches-pill(容差 0.5px)/ text-boxes-collected(89 个)/
row-text-boxes-from-cached-rows / boxes-cleared-when-off。
- 回归:lbcheck 21/21、lbresid 5/5、lbzorder 4/4、uicheck 69/69。
- rendercheck:8 个场景的整帧与区域哈希与上一轮**逐一相同** + FUNC 7/7
(证明调试功能对正常绘制零影响)。
- 帧耗时分解(MF4 / 283 网格):base 9.06ms、仅强制整帧 6.66ms、完整调试 11.35ms;
collect 0.082ms、paintBoxes 4.028ms(上一轮 5.892ms)。
## 8. 文档
Documents/UI_Refactor_Plan.md / UI_Refactor_Progress.md / UI_Refactor_Report.md 追加第九阶段;
Documents/agent_mem.md 同步变更日志与「2026-10-28 第十一轮」硬约束与踩坑。
This commit is contained in:
1 parent
57e12cfb27
commit
aa4925a2b7
14 files changed
+635
-107
No files matched your search
@@ -18,6 +18,7 @@
|
||||
#include "Theme.hpp"
|
||||
#include "Toolbar.hpp"
|
||||
#include "UiComponent.hpp"
|
||||
#include "UiDebugBounds.hpp"
|
||||
#include "UiSurface.hpp"
|
||||
|
||||
namespace jdi
|
||||
@@ -398,8 +399,11 @@ namespace jdi
|
||||
/**
|
||||
* @brief 绘制全部 UI 控件的布局边界(调试开关开启时在 Render 的最后一步调用)。
|
||||
*
|
||||
* 遍历组件表(底 → 顶)并让每个组件上报自己的内部结构;随后补上不属于
|
||||
* 任何组件的两块区域(面板分隔条、客户区外框)。
|
||||
* 内容分两路:
|
||||
* * **组件结构**:遍历组件表(底 → 顶)让每个组件上报内部结构,再补上不属于任何
|
||||
* 组件的区域(客户区外框、面板分隔条、菜单 / 拾色器);
|
||||
* * **文本**:绘制期间由 `UiSetTextRectSink(&m_debugBoxes)` 自动收集(见 `PaintUtil`),
|
||||
* 因为文本是本项目唯一"没有几何身份"的元素,它在 60+ 个调用点现算矩形、画完即弃。
|
||||
*
|
||||
* @param [IN,OUT] g 绘图上下文。
|
||||
* @param [IN] width 客户区宽度。
|
||||
@@ -478,6 +482,14 @@ namespace jdi
|
||||
*/
|
||||
bool m_showLayoutBounds = false;
|
||||
|
||||
/**
|
||||
* @brief 调试 box 容器(只在 `m_showLayoutBounds` 为真时使用)。
|
||||
*
|
||||
* 作为成员而不是局部变量:避免开关打开时每帧重新分配,
|
||||
* 也让它能直接充当 `PaintUtil` 的文本收集器(`UiTextRectSink`)。
|
||||
*/
|
||||
UiDebugBoxList m_debugBoxes;
|
||||
|
||||
/** @brief 填充组件表(`Initialize` 里 `Setup` 之后调用一次)。 */
|
||||
void BuildComponentTable();
|
||||
|
||||
|
||||
@@ -522,6 +522,21 @@ namespace jdi
|
||||
g.SetSmoothingMode(gd::SmoothingModeAntiAlias);
|
||||
g.SetPixelOffsetMode(gd::PixelOffsetModeHalf);
|
||||
g.SetTextRenderingHint(gd::TextRenderingHintClearTypeGridFit);
|
||||
|
||||
// ⚠️ 调试:文本是本项目唯一"没有几何身份"的绘制元素(60+ 个调用点现算矩形、
|
||||
// 画完即弃),因此在这里安装收集器,让 `PaintUtil` 在绘制时把**实际墨迹矩形**
|
||||
// 回报给 `m_debugBoxes`。开关关闭时完全不安装(空指针,一次判空即返回)。
|
||||
if (m_showLayoutBounds)
|
||||
{
|
||||
m_debugBoxes.Clear();
|
||||
m_debugBoxes.SetLayer(2); // 基础内容层(工具栏/面板/绘图区)
|
||||
UiSetTextRectSink(&m_debugBoxes);
|
||||
}
|
||||
else if (!m_debugBoxes.Empty())
|
||||
{
|
||||
// 关闭后释放容器(否则上一次的几何会一直占着内存,也容易被误读成"仍在收集")。
|
||||
m_debugBoxes.Clear();
|
||||
}
|
||||
// 信号列表 / 样式区「目标」行的悬停 → 绘图区联动高亮(网格变色 + 该信号曲线高亮)。
|
||||
// 用户 2026-10-15 要求;鼠标在网格里移动**不再**触发网格变色高亮。
|
||||
// ⚠️ 每帧同步(而不是只在 WM_MOUSEMOVE 里同步)才能覆盖全部改变悬停的路径:
|
||||
@@ -553,7 +568,17 @@ namespace jdi
|
||||
m_plot.Paint(g);
|
||||
|
||||
// 弹出菜单与浮动拾色器始终绘制在最上层,保证与主界面风格一致。
|
||||
// ⚠️ 调试:它们是不透明浮层,文本要记入更高的绘制层,
|
||||
// 否则会被自己登记到遮挡矩形里的"挖洞"逻辑裁掉。
|
||||
if (m_showLayoutBounds)
|
||||
{
|
||||
m_debugBoxes.SetLayer(5);
|
||||
}
|
||||
m_menu.Paint(g);
|
||||
if (m_showLayoutBounds)
|
||||
{
|
||||
m_debugBoxes.SetLayer(6);
|
||||
}
|
||||
m_colorPicker.Paint(g);
|
||||
|
||||
// 加载遮罩层在一切内容之上(包括菜单与拾色器),形成模态观感。
|
||||
@@ -563,6 +588,7 @@ namespace jdi
|
||||
// 位图缓存 —— 否则关掉开关后线条会残留在缓存里。
|
||||
if (m_showLayoutBounds)
|
||||
{
|
||||
UiSetTextRectSink(nullptr);
|
||||
PaintLayoutBounds(g, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1156,40 +1156,42 @@ namespace jdi
|
||||
|
||||
void Application::PaintLayoutBounds(gd::Graphics& g, int width, int height)
|
||||
{
|
||||
UiDebugBoxList boxes;
|
||||
// ⚠️ 复用成员容器(不是局部变量):文本几何已经在**绘制期间**由 `PaintUtil`
|
||||
// 通过 `UiSetTextRectSink(&m_debugBoxes)` 收进来了,这里只负责补组件结构。
|
||||
m_debugBoxes.SetLayer(0);
|
||||
|
||||
// 客户区外框:便于确认"窗口边缘 == 最外层边界"。
|
||||
boxes.Add(gd::RectF(0.0f, 0.0f, static_cast<float>(width), static_cast<float>(height)), 0);
|
||||
m_debugBoxes.Add(gd::RectF(0.0f, 0.0f, static_cast<float>(width),
|
||||
static_cast<float>(height)), 0);
|
||||
|
||||
// 组件区域(底 → 顶;组件自己负责补齐内部结构)。
|
||||
// ⚠️ 两点都很重要:
|
||||
// 1. `SetClip(组件区域)`:组件内部的元素可能落在自己地盘之外(典型:滚出可视区的
|
||||
// 网格 `lane.rect` 的 Y 为负数),不裁剪会把边框画到工具栏/标签栏上
|
||||
// —— 这正是"工具栏上出现绘制残留"的直接原因。
|
||||
// 网格 `lane.rect` 的 Y 为负数),不裁剪会把边框画到工具栏/标签栏上。
|
||||
// 2. 每收集完一个组件就 `PushLayer()`:浮层压在本体之上(右键二级菜单压在行上面),
|
||||
// 只有按收集顺序分层,后收集的内容才画在上面。
|
||||
for (const ComponentEntry& entry : m_components)
|
||||
{
|
||||
if (entry.component != nullptr)
|
||||
{
|
||||
boxes.SetClip(entry.component->Area());
|
||||
entry.component->CollectDebugBoxes(boxes);
|
||||
m_debugBoxes.SetClip(entry.component->Area());
|
||||
entry.component->CollectDebugBoxes(m_debugBoxes);
|
||||
}
|
||||
boxes.PushLayer();
|
||||
m_debugBoxes.PushLayer();
|
||||
}
|
||||
|
||||
// 不属于任何组件的两块:面板分隔条(由宿主直接填充色块)、菜单 / 拾色器(浮层)。
|
||||
// ⚠️ 浮层**不设裁剪矩形**:菜单的二级子菜单会展开到菜单本体之外,设裁剪会把它裁掉;
|
||||
// 它们自己会把本体登记为"遮挡矩形"(见 `PopupMenu::CollectDebugBoxes`),
|
||||
// 由绘制阶段把更低层的 box 从浮层区域里挖掉。
|
||||
boxes.SetClip(gd::RectF());
|
||||
boxes.Add(m_splitterRect, 0);
|
||||
boxes.PushLayer();
|
||||
m_menu.CollectDebugBoxes(boxes);
|
||||
boxes.PushLayer();
|
||||
m_colorPicker.CollectDebugBoxes(boxes);
|
||||
m_debugBoxes.SetClip(gd::RectF());
|
||||
m_debugBoxes.Add(m_splitterRect, 0);
|
||||
m_debugBoxes.PushLayer();
|
||||
m_menu.CollectDebugBoxes(m_debugBoxes);
|
||||
m_debugBoxes.PushLayer();
|
||||
m_colorPicker.CollectDebugBoxes(m_debugBoxes);
|
||||
|
||||
UiDebugPaintBoxList(g, boxes);
|
||||
UiDebugPaintBoxList(g, m_debugBoxes);
|
||||
}
|
||||
|
||||
void Application::DispatchMenuResult(const MenuResult& result)
|
||||
|
||||
@@ -589,6 +589,19 @@ namespace jdi
|
||||
boxes.Add(hit.text, 3);
|
||||
}
|
||||
|
||||
// 层级 1/2:绘图区里**不属于任何网格**的固定构件。
|
||||
// 这些曾经全部漏掉(调试时"看得见却没框")—— 它们都已经有成员变量,直接读即可。
|
||||
boxes.Add(m_timeAxisRect, 1);
|
||||
boxes.Add(m_scrollBarRect, 2);
|
||||
boxes.Add(BackToTopRect(), 2);
|
||||
|
||||
// 层级 2/3:时间光标读数标签(避让后的实际矩形,绘制时已登记)。
|
||||
boxes.Add(m_cursorSpanRect, 2);
|
||||
boxes.AddAll(m_cursorLabelRects, 3);
|
||||
|
||||
// 层级 3:内联输入框(正在编辑时才有意义)。
|
||||
boxes.Add(EditFieldRect(), 3);
|
||||
|
||||
// 层级 2/3/4:5 类实验性功能浮动面板的内部控件。
|
||||
// 这些矩形由 `EdgePanelLayoutFor` 统一算出(绘制与命中共用),一个循环即可全部上报。
|
||||
for (std::size_t index = 0; index < m_lanes.size(); ++index)
|
||||
|
||||
@@ -171,6 +171,59 @@ namespace jdi
|
||||
void UiTextClipped(gd::Graphics& g, const std::wstring& text, HFONT font, const gd::RectF& rect,
|
||||
std::uint32_t argb, TextAlign align, const gd::RectF& clipRect);
|
||||
|
||||
/**
|
||||
* @brief 文本几何收集器(调试用「显示布局边界」)。
|
||||
*
|
||||
* 文本是本项目里**唯一**没有几何身份的绘制元素:`UiText` / `UiTextClipped` /
|
||||
* `UiTextAtClipped` 每次都在调用点现算一个矩形、画完即弃,全仓有 60+ 处这样的调用点。
|
||||
* 与其在 60 处逐个补登记(必漏),不如在**绘制唯一出口**里回报一次。
|
||||
*
|
||||
* ⚠️ 只在调试开关打开时才被安装(见 `UiSetTextRectSink`),平时为空指针、
|
||||
* 一次判空即返回,对正常绘制零影响。
|
||||
*/
|
||||
class UiTextRectSink
|
||||
{
|
||||
public:
|
||||
virtual ~UiTextRectSink() = default;
|
||||
|
||||
/**
|
||||
* @brief 回报一段文本**实际占用**的矩形(已按对齐方式与实测宽度收窄)。
|
||||
* @param [IN] rect 文本墨迹矩形(客户区坐标)。
|
||||
*/
|
||||
virtual void OnTextRect(const gd::RectF& rect) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 安装 / 卸载文本几何收集器(nullptr = 卸载)。
|
||||
*
|
||||
* 单线程 UI 绘制 ⇒ 用文件级静态指针即可,不需要加锁。
|
||||
*
|
||||
* @param [IN] sink 收集器(允许为空)。
|
||||
*/
|
||||
void UiSetTextRectSink(UiTextRectSink* sink);
|
||||
|
||||
/**
|
||||
* @brief 取当前安装的文本几何收集器(`nullptr` = 未安装)。
|
||||
*
|
||||
* 供"先画进离屏位图再贴回"的组件使用:它需要暂存自己的文本框,
|
||||
* 并在贴图时按原点偏移回放给外层收集器。
|
||||
*
|
||||
* @return 当前收集器(可能为空)。
|
||||
*/
|
||||
UiTextRectSink* UiGetTextRectSink();
|
||||
|
||||
/**
|
||||
* @brief 设置文本矩形的坐标偏移(默认 `(0, 0)`)。
|
||||
*
|
||||
* 有些组件把内容先画进**离屏位图**再贴回(`SignalPanel` 的行位图缓存),
|
||||
* 此时回报的矩形处在位图坐标系 —— 传一位图原点偏移即可换算回屏幕坐标,
|
||||
* 调试层才能把框画在对的位置。
|
||||
*
|
||||
* @param [IN] dx 横坐标偏移。
|
||||
* @param [IN] dy 纵坐标偏移。
|
||||
*/
|
||||
void UiSetTextRectOffset(float dx, float dy);
|
||||
|
||||
/**
|
||||
* @brief 测量单行文本的像素宽度(无需 GDI+ 上下文,可在布局阶段调用)。
|
||||
* @param [IN] font 字体句柄。
|
||||
@@ -179,6 +232,14 @@ namespace jdi
|
||||
*/
|
||||
float UiMeasureTextWidth(HFONT font, const std::wstring& text);
|
||||
|
||||
/**
|
||||
* @brief 测量单行文本的字符单元高度(垂直居中口径与 `UiText` 一致)。
|
||||
* @param [IN] font 字体句柄。
|
||||
* @param [IN] text 文本内容。
|
||||
* @return 字符单元高度。
|
||||
*/
|
||||
float UiMeasureTextHeight(HFONT font, const std::wstring& text);
|
||||
|
||||
/**
|
||||
* @brief 在指定裁剪矩形内以显式起点绘制一段文本(使用 GDI ExtTextOut 裁剪)。
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "PaintUtil.hpp"
|
||||
#include "Theme.hpp"
|
||||
|
||||
namespace jdi
|
||||
@@ -50,7 +51,7 @@ namespace jdi
|
||||
* 没有它,"信号面板的行边界"会盖住"右键弹出的二级菜单"(菜单是后收集的浮层)。
|
||||
* * `depth`(层级):同一层内先画父(浅层)再画子(深层),子元素的彩色包角才不被父覆盖。
|
||||
*/
|
||||
class UiDebugBoxList
|
||||
class UiDebugBoxList : public UiTextRectSink
|
||||
{
|
||||
public:
|
||||
/** @brief 清空(复用同一实例时调用),同时把绘制层复位为 0。 */
|
||||
@@ -62,6 +63,14 @@ namespace jdi
|
||||
* (例如菜单的二级子菜单)也应在收集子层之前调用。
|
||||
*/
|
||||
void PushLayer() { ++m_layer; }
|
||||
/**
|
||||
* @brief 显式设置当前绘制层(绘制期间收集文本几何时用)。
|
||||
* @param [IN] layer 层号(越大越靠上)。
|
||||
*/
|
||||
void SetLayer(int layer) { m_layer = layer; }
|
||||
|
||||
/** @brief 回报一段文本的墨迹矩形(由 `PaintUtil` 在绘制文本时调用)。 */
|
||||
void OnTextRect(const gd::RectF& rect) override;
|
||||
/**
|
||||
* @brief 设置后续 box 的裁剪矩形(= 当前组件的区域)。
|
||||
*
|
||||
@@ -115,13 +124,14 @@ namespace jdi
|
||||
*
|
||||
* 视觉规则:
|
||||
* * 四条边固定 1 设备像素;
|
||||
* * 四个角额外加粗成 `⌜ ⌝ ⌞ ⌟` 包角 —— 这是"一眼定位元素边界"的关键,
|
||||
* * 四个角额外加粗成 `⌜ ⌝ ⌞ ⌟` —— 这是"一眼定位元素边界"的关键,
|
||||
* 即使多个矩形共边也能靠角的形状分辨层次;
|
||||
* * **包角粗细与长度都随矩形短边自适应**:元素越小越细(小方框不会被描成"粗边框"),
|
||||
* 短边 ≤ 12px 时只画角、不画边(四个 L 形小标记,最不干扰内容),
|
||||
* 短边 ≤ 5px 时完全不画(否则就盖住元素本身了);
|
||||
* * 层级 > 0 的矩形整体内缩 1 像素(短边太小时不内缩),避免与父矩形共边时叠成粗线;
|
||||
* * **只描边、不填充、不写文字** —— 填充会糊住内容,文字标签在小元素上会连成一片。
|
||||
* 短边 ≤ 12px 时只画四个角块、不画边,短边 ≤ 5px 时完全不画(否则就盖住元素本身了);
|
||||
* * **不做任何内缩**:框必须与"可见形状的外接矩形"完全重合。
|
||||
* 曾经为"父子共边不叠粗"内缩 1px,结果把胶囊/圆角元素(GX 徽标、色块、✕)
|
||||
* 的圆弧留在框外 —— 那是错误的取舍。重叠时让"后画的那个"覆盖即可;
|
||||
* * **只描边、不填充、不写字** —— 填充会糊住内容。
|
||||
*
|
||||
* ⚠️ 线宽按**设备像素**固定(不乘 `scale`)并临时 `PixelOffsetModeNone` + 关抗锯齿,
|
||||
* 否则 1px 线会被抗锯齿摊成 2px 灰边,无法判断真实边界。
|
||||
|
||||
@@ -405,6 +405,50 @@ namespace jdi
|
||||
|
||||
namespace
|
||||
{
|
||||
/** @brief 当前安装的文本几何收集器(`nullptr` = 不收集,调试开关关闭)。 */
|
||||
UiTextRectSink* g_textRectSink = nullptr;
|
||||
/** @brief 当前文本矩形的坐标偏移(离屏位图渲染时非零)。 */
|
||||
float g_textRectOffsetX = 0.0f;
|
||||
float g_textRectOffsetY = 0.0f;
|
||||
|
||||
/**
|
||||
* @brief 回报一段文本的墨迹矩形(仅在收集器已安装时执行)。
|
||||
*
|
||||
* 入参 `rect` 是**布局矩形**(可能整行宽);这里按对齐方式与实测宽度/高度把它
|
||||
* 收窄成文字真正占据的那一块 —— 否则每个文本 box 都会跟整行一样宽,边界失去意义。
|
||||
*
|
||||
* @param [IN] text 文本内容。
|
||||
* @param [IN] font 字体句柄。
|
||||
* @param [IN] rect 布局矩形。
|
||||
* @param [IN] align 水平对齐方式。
|
||||
*/
|
||||
void ReportTextRect(const std::wstring& text, HFONT font, const gd::RectF& rect, TextAlign align)
|
||||
{
|
||||
if (g_textRectSink == nullptr || text.empty() || font == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const TextExtent extent = MeasureText(font, text);
|
||||
if (extent.width <= 0.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const float width = std::min(extent.width, rect.Width);
|
||||
const float height = std::min(std::max(extent.height, 1.0f), rect.Height);
|
||||
float x = rect.X;
|
||||
if (align == TextAlign::CENTER)
|
||||
{
|
||||
x = rect.X + (rect.Width - width) * 0.5f;
|
||||
}
|
||||
else if (align == TextAlign::RIGHT)
|
||||
{
|
||||
x = rect.X + rect.Width - width;
|
||||
}
|
||||
const float y = rect.Y + (rect.Height - height) * 0.5f;
|
||||
g_textRectSink->OnTextRect(
|
||||
gd::RectF(x + g_textRectOffsetX, y + g_textRectOffsetY, width, height));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief `UiText` 与 `UiTextClipped` 的公共实现。
|
||||
*
|
||||
@@ -483,6 +527,9 @@ namespace jdi
|
||||
|
||||
DrawTextW(hdc, text.c_str(), static_cast<int>(text.size()), &rc, flags);
|
||||
|
||||
// 调试:回报文字真正占据的矩形(在恢复 DC 状态之前算,此时字体仍被选中)。
|
||||
ReportTextRect(text, font, rect, align);
|
||||
|
||||
SetTextColor(hdc, oldColor);
|
||||
SetBkMode(hdc, oldMode);
|
||||
SelectObject(hdc, oldFont);
|
||||
@@ -513,6 +560,27 @@ namespace jdi
|
||||
return MeasureText(font, text).width;
|
||||
}
|
||||
|
||||
float UiMeasureTextHeight(HFONT font, const std::wstring& text)
|
||||
{
|
||||
return MeasureText(font, text).height;
|
||||
}
|
||||
|
||||
void UiSetTextRectSink(UiTextRectSink* sink)
|
||||
{
|
||||
g_textRectSink = sink;
|
||||
}
|
||||
|
||||
UiTextRectSink* UiGetTextRectSink()
|
||||
{
|
||||
return g_textRectSink;
|
||||
}
|
||||
|
||||
void UiSetTextRectOffset(float dx, float dy)
|
||||
{
|
||||
g_textRectOffsetX = dx;
|
||||
g_textRectOffsetY = dy;
|
||||
}
|
||||
|
||||
std::wstring UiEllipsize(const std::wstring& text, HFONT font, float maxWidth)
|
||||
{
|
||||
if (text.empty() || font == nullptr || maxWidth <= 0.0f)
|
||||
@@ -576,6 +644,19 @@ namespace jdi
|
||||
ExtTextOutW(hdc, static_cast<int>(std::floor(x)), baselineY, ETO_CLIPPED, &clip, text.c_str(),
|
||||
static_cast<UINT>(text.size()), nullptr);
|
||||
|
||||
// 调试:回报文字真正占据的矩形(起点由调用方给出,宽度取实测值)。
|
||||
if (g_textRectSink != nullptr)
|
||||
{
|
||||
const float width = UiMeasureTextWidth(font, text);
|
||||
if (width > 0.0f)
|
||||
{
|
||||
const float height = std::max(1.0f, static_cast<float>(metrics.tmHeight));
|
||||
g_textRectSink->OnTextRect(
|
||||
gd::RectF(std::floor(x) + g_textRectOffsetX,
|
||||
rect.Y + (rect.Height - height) * 0.5f + g_textRectOffsetY, width, height));
|
||||
}
|
||||
}
|
||||
|
||||
SetTextColor(hdc, oldColor);
|
||||
SetBkMode(hdc, oldMode);
|
||||
SelectObject(hdc, oldFont);
|
||||
|
||||
@@ -16,12 +16,10 @@ namespace jdi
|
||||
constexpr int kNodeCornerThick = 3;
|
||||
/** @brief 包角沿边延伸的长度上限(设备像素)。 */
|
||||
constexpr int kCornerLenMax = 14;
|
||||
/** @brief 短边不超过该值时**只画角、不画边**(小方框画满一圈会像粗边框)。 */
|
||||
/** @brief 短边不超过该值时**只画四个角块、不画边**(小方框画满一圈会像粗边框)。 */
|
||||
constexpr int kEdgelessThreshold = 12;
|
||||
/** @brief 短边不超过该值时完全不画(再画就盖住元素本身了)。 */
|
||||
constexpr int kSkipThreshold = 5;
|
||||
/** @brief 短边小于该值时不做内缩(内缩会把小元素缩成一条线)。 */
|
||||
constexpr int kInsetThreshold = 10;
|
||||
|
||||
/** @brief 一个已对齐到整像素、可直接填充的矩形。 */
|
||||
struct PixelRect
|
||||
@@ -40,6 +38,10 @@ namespace jdi
|
||||
*
|
||||
* 走 GDI+ 而不是 `UiFillRect`:这里需要**精确的 1px 覆盖**,而 `UiFillRect` 的快
|
||||
* 路径按 `floor/ceil` 取整并可能转交 GDI,混进调试层会带来额外状态切换开销。
|
||||
*
|
||||
* ⚠️ **每次图元调用约 1µs**(实测 474 个 box × 12 段 = 5.9ms/帧),因此这里刻意
|
||||
* 把图元数量从 12 压到 8;并且**不要**改写成 `GraphicsPath` —— `FillPath` 单次约
|
||||
* 20µs,比 12 段 `FillRectangle` 还慢(本机实测 22.8ms vs 13.0ms)。
|
||||
*/
|
||||
void FillPixels(gd::Graphics& g, int x, int y, int width, int height, std::uint32_t argb)
|
||||
{
|
||||
@@ -51,24 +53,18 @@ namespace jdi
|
||||
g.FillRectangle(&brush, x, y, width, height);
|
||||
}
|
||||
|
||||
/** @brief 把逻辑矩形对齐到整像素(`inset` 先内缩,用于避免父子共边)。 */
|
||||
PixelRect AlignToPixels(const gd::RectF& rect, int inset)
|
||||
/** @brief 把逻辑矩形对齐到整像素(**不内缩**,见头文件说明)。 */
|
||||
PixelRect AlignToPixels(const gd::RectF& rect)
|
||||
{
|
||||
const float shrink = static_cast<float>(inset);
|
||||
const float x = rect.X + shrink;
|
||||
const float y = rect.Y + shrink;
|
||||
const float width = rect.Width - shrink * 2.0f;
|
||||
const float height = rect.Height - shrink * 2.0f;
|
||||
if (!(width > 0.0f) || !(height > 0.0f))
|
||||
if (!(rect.Width > 0.0f) || !(rect.Height > 0.0f))
|
||||
{
|
||||
return PixelRect();
|
||||
}
|
||||
|
||||
PixelRect out;
|
||||
out.left = static_cast<int>(std::lround(x));
|
||||
out.top = static_cast<int>(std::lround(y));
|
||||
out.right = static_cast<int>(std::lround(x + width)) - 1;
|
||||
out.bottom = static_cast<int>(std::lround(y + height)) - 1;
|
||||
out.left = static_cast<int>(std::lround(rect.X));
|
||||
out.top = static_cast<int>(std::lround(rect.Y));
|
||||
out.right = static_cast<int>(std::lround(rect.X + rect.Width)) - 1;
|
||||
out.bottom = static_cast<int>(std::lround(rect.Y + rect.Height)) - 1;
|
||||
if (out.right < out.left)
|
||||
{
|
||||
out.right = out.left;
|
||||
@@ -89,16 +85,10 @@ namespace jdi
|
||||
m_clip = gd::RectF();
|
||||
}
|
||||
|
||||
void UiDebugBoxList::AddOccluder(const gd::RectF& rect)
|
||||
void UiDebugBoxList::OnTextRect(const gd::RectF& rect)
|
||||
{
|
||||
if (!(rect.Width > 0.0f) || !(rect.Height > 0.0f))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Occluder occluder;
|
||||
occluder.rect = rect;
|
||||
occluder.layer = m_layer;
|
||||
m_occluders.push_back(occluder);
|
||||
// 文本用固定层级 4:它总是"最里层"的元素(复选框里的字、行里的信号名…)。
|
||||
Add(rect, 4);
|
||||
}
|
||||
|
||||
void UiDebugBoxList::Add(const gd::RectF& rect, int depth)
|
||||
@@ -132,6 +122,18 @@ namespace jdi
|
||||
}
|
||||
}
|
||||
|
||||
void UiDebugBoxList::AddOccluder(const gd::RectF& rect)
|
||||
{
|
||||
if (!(rect.Width > 0.0f) || !(rect.Height > 0.0f))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Occluder occluder;
|
||||
occluder.rect = rect;
|
||||
occluder.layer = m_layer;
|
||||
m_occluders.push_back(occluder);
|
||||
}
|
||||
|
||||
std::uint32_t UiDebugBoundsColor(int depth)
|
||||
{
|
||||
// 与主题无关的固定配色:调试层必须"永远显眼",不能跟随用户主题变成接近底色。
|
||||
@@ -143,8 +145,10 @@ namespace jdi
|
||||
return 0xFFE040FBu; // 品红:组件内部的功能分区
|
||||
case 2:
|
||||
return 0xFFFFB300u; // 琥珀:具体控件 / 行
|
||||
case 3:
|
||||
return 0xFF66BB6Au; // 绿:更深的子块(复选框、色块、✕ …)
|
||||
default:
|
||||
return 0xFF66BB6Au; // 绿:更深的子块(复选框、文本、✕ …)
|
||||
return 0xFFFF7043u; // 橙:文本墨迹矩形
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,35 +162,30 @@ namespace jdi
|
||||
{
|
||||
const int level = (depth < 0) ? 0 : depth;
|
||||
|
||||
// 先用未内缩的尺寸判断"值不值得画"和"要不要内缩":
|
||||
// 内缩是给"父子共边"用的,元素本身很小时内缩只会把它缩没。
|
||||
const float rawShortSide = std::min(rect.Width, rect.Height);
|
||||
if (rawShortSide <= static_cast<float>(kSkipThreshold))
|
||||
// 先判断"值不值得画":元素太小时画上去就是糊住它本身。
|
||||
if (std::min(rect.Width, rect.Height) <= static_cast<float>(kSkipThreshold))
|
||||
{
|
||||
return; // 太小:画上去就是糊住元素本身。
|
||||
return;
|
||||
}
|
||||
const int inset = (level > 0 && rawShortSide >= static_cast<float>(kInsetThreshold)) ? 1 : 0;
|
||||
|
||||
PixelRect pixels = AlignToPixels(rect, inset);
|
||||
PixelRect pixels = AlignToPixels(rect);
|
||||
if (!pixels.Valid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// ⚠️ 与裁剪矩形求交(见 `UiDebugBoxList::SetClip`):组件内部的元素可能落在地盘之外。
|
||||
// 用 floor/ceil 而不是取整:裁剪是“能看见多少就画多少”,宁可多一像素也不要把
|
||||
// 用 floor/ceil 而不是取整:裁剪是"能看见多少就画多少",宁可多一像素也不要把
|
||||
// 紧贴边界的包角整个裁掉。
|
||||
if (clip.Width > 0.0f && clip.Height > 0.0f)
|
||||
{
|
||||
const int clipLeft = static_cast<int>(std::floor(clip.X));
|
||||
const int clipTop = static_cast<int>(std::floor(clip.Y));
|
||||
const int clipRight = static_cast<int>(std::ceil(clip.X + clip.Width)) - 1;
|
||||
const int clipBottom = static_cast<int>(std::ceil(clip.Y + clip.Height)) - 1;
|
||||
PixelRect clipped;
|
||||
clipped.left = std::max(pixels.left, clipLeft);
|
||||
clipped.top = std::max(pixels.top, clipTop);
|
||||
clipped.right = std::min(pixels.right, clipRight);
|
||||
clipped.bottom = std::min(pixels.bottom, clipBottom);
|
||||
clipped.left = std::max(pixels.left, static_cast<int>(std::floor(clip.X)));
|
||||
clipped.top = std::max(pixels.top, static_cast<int>(std::floor(clip.Y)));
|
||||
clipped.right =
|
||||
std::min(pixels.right, static_cast<int>(std::ceil(clip.X + clip.Width)) - 1);
|
||||
clipped.bottom =
|
||||
std::min(pixels.bottom, static_cast<int>(std::ceil(clip.Y + clip.Height)) - 1);
|
||||
if (!clipped.Valid())
|
||||
{
|
||||
return;
|
||||
@@ -199,51 +198,44 @@ namespace jdi
|
||||
const int shortSide = std::min(width, height);
|
||||
const std::uint32_t color = UiDebugBoundsColor(level);
|
||||
|
||||
// ⚠️ **包角粗细随尺寸自适应**:这是"小元素变成粗描边"的修复点。
|
||||
// 基准 4/3px 只在足够大的矩形上使用;短边越小越细,最终退化为 1px。
|
||||
// 同时不超过短边的 1/4,避免包角在元素自身上"占比过大"。
|
||||
// 包角粗细随尺寸自适应("小元素变成粗描边"的修复点):
|
||||
// 基准 4/3px 只在足够大的矩形上使用;短边越小越细,且不超过短边的 1/4。
|
||||
const int baseThick = (level == 0) ? kAreaCornerThick : kNodeCornerThick;
|
||||
int cornerThick = std::min(baseThick, shortSide / 10);
|
||||
int cornerThick = std::max(1, std::min(baseThick, shortSide / 10));
|
||||
cornerThick = std::max(1, std::min(cornerThick, std::max(1, shortSide / 4)));
|
||||
|
||||
// 包角沿边延伸的长度:短边的 1/3,不超过上限,也不小于角本身。
|
||||
// 包角长度随短边变化:短边的 1/3,不超过上限,也不小于角本身。
|
||||
int cornerLen = std::min(kCornerLenMax, std::max(1, shortSide / 3));
|
||||
cornerLen = std::max(cornerLen, cornerThick);
|
||||
|
||||
// 小方框只画角、不画边:一圈连续描边会让复选框/色块/✕ 看起来"被粗框包住",
|
||||
// 而四个 L 形小标记既不糊内容,又能立刻定位边界的四角。
|
||||
const bool drawEdges = (shortSide > kEdgelessThreshold);
|
||||
|
||||
const gd::GraphicsState state = g.Save();
|
||||
// 描边必须锐利:关抗锯齿 + 关半像素偏移,矩形已对齐整像素 ⇒ 1px 就是 1px。
|
||||
g.SetSmoothingMode(gd::SmoothingModeNone);
|
||||
g.SetPixelOffsetMode(gd::PixelOffsetModeNone);
|
||||
|
||||
// ⚠️ 图元数量直接决定耗时(每个约 1µs),因此这里固定为**最多 8 次**:
|
||||
// 4 条 1px 边 + 4 个加粗角块。
|
||||
// 旧实现把每条边拆成"中段 1px + 两端各一段加粗"共 12 次,观感几乎相同
|
||||
// (角本来就是"两条粗边的交点"),却多花 50% 时间。
|
||||
// 短边很小的矩形只画 4 个角块(画满一圈会让复选框/色块看起来"被框住")。
|
||||
const bool drawEdges = (shortSide > kEdgelessThreshold);
|
||||
if (drawEdges)
|
||||
{
|
||||
// 四边:统一 1px,用实心矩形而不是 `DrawRectangle`
|
||||
//(后者会因笔宽奇偶而偏移半像素,且抗锯齿会糊成 2px)。
|
||||
FillPixels(g, pixels.left, pixels.top, width, kEdgeStroke, color); // 上
|
||||
FillPixels(g, pixels.left, pixels.bottom, width, kEdgeStroke, color); // 下
|
||||
FillPixels(g, pixels.left, pixels.top, kEdgeStroke, height, color); // 左
|
||||
FillPixels(g, pixels.right, pixels.top, kEdgeStroke, height, color); // 右
|
||||
FillPixels(g, pixels.left, pixels.top, width, kEdgeStroke, color); // 上
|
||||
FillPixels(g, pixels.left, pixels.bottom, width, kEdgeStroke, color); // 下
|
||||
FillPixels(g, pixels.left, pixels.top, kEdgeStroke, height, color); // 左
|
||||
FillPixels(g, pixels.right, pixels.top, kEdgeStroke, height, color); // 右
|
||||
}
|
||||
|
||||
// 四个角:加粗成 ⌜ ⌝ ⌞ ⌟ 包角(粗细见上)。
|
||||
// 左上
|
||||
FillPixels(g, pixels.left, pixels.top, cornerLen, cornerThick, color);
|
||||
FillPixels(g, pixels.left, pixels.top, cornerThick, cornerLen, color);
|
||||
// 右上
|
||||
FillPixels(g, pixels.right - cornerLen + 1, pixels.top, cornerLen, cornerThick, color);
|
||||
FillPixels(g, pixels.right - cornerThick + 1, pixels.top, cornerThick, cornerLen, color);
|
||||
// 左下
|
||||
FillPixels(g, pixels.left, pixels.bottom - cornerThick + 1, cornerLen, cornerThick, color);
|
||||
FillPixels(g, pixels.left, pixels.bottom - cornerLen + 1, cornerThick, cornerLen, color);
|
||||
// 右下
|
||||
FillPixels(g, pixels.right - cornerLen + 1, pixels.bottom - cornerThick + 1, cornerLen,
|
||||
cornerThick, color);
|
||||
FillPixels(g, pixels.right - cornerThick + 1, pixels.bottom - cornerLen + 1, cornerThick,
|
||||
cornerLen, color);
|
||||
// 四个加粗角块(粗细随尺寸自适应,见上)。
|
||||
// * 大矩形:角块是 `cornerThick` 见方的方块,与四条 1px 边接成 `⌜ ⌝ ⌞ ⌟`;
|
||||
// * 小方框(不画边):角块沿水平方向拉长到 `cornerLen`,让"四个角"更明显。
|
||||
const int blockW = std::min(drawEdges ? cornerThick : cornerLen, width);
|
||||
const int blockH = std::min(cornerThick, height);
|
||||
FillPixels(g, pixels.left, pixels.top, blockW, blockH, color);
|
||||
FillPixels(g, pixels.right - blockW + 1, pixels.top, blockW, blockH, color);
|
||||
FillPixels(g, pixels.left, pixels.bottom - blockH + 1, blockW, blockH, color);
|
||||
FillPixels(g, pixels.right - blockW + 1, pixels.bottom - blockH + 1, blockW, blockH, color);
|
||||
|
||||
g.Restore(state);
|
||||
}
|
||||
@@ -278,27 +270,22 @@ namespace jdi
|
||||
for (const UiDebugBox* box : ordered)
|
||||
{
|
||||
// ⚠️ 遮挡:浮层(菜单 / 拾色器)是不透明的,它上面的内容不该出现下层组件的边框线。
|
||||
// 仅靠 layer 排序只能决定“两个 box 重叠时谁压谁”,不能阻止“先画的线仍然可见”,
|
||||
// 仅靠 layer 排序只能决定"两个 box 重叠时谁压谁",不能阻止"先画的线仍然可见",
|
||||
// 因此这里把**更高层**的遮挡矩形从裁剪区里排除。
|
||||
bool occluded = false;
|
||||
gd::Region region;
|
||||
bool regionReady = false;
|
||||
bool occluded = false;
|
||||
for (const UiDebugBoxList::Occluder& occluder : boxes.Occluders())
|
||||
{
|
||||
if (occluder.layer <= box->layer)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!regionReady)
|
||||
if (!occluded)
|
||||
{
|
||||
// 以“整个客户区”为起点(足够大的矩形,超出窗口的部分自然不会被画到)。
|
||||
const gd::RectF everything(-100000.0f, -100000.0f, 200000.0f, 200000.0f);
|
||||
region.MakeInfinite();
|
||||
region.Intersect(everything);
|
||||
regionReady = true;
|
||||
occluded = true;
|
||||
}
|
||||
region.Exclude(occluder.rect);
|
||||
occluded = true;
|
||||
}
|
||||
if (!occluded)
|
||||
{
|
||||
@@ -306,7 +293,7 @@ namespace jdi
|
||||
continue;
|
||||
}
|
||||
|
||||
// 已有裁剪矩形时先与它求交,再设进 Graphics(region 天然支持这种“挖洞”裁剪)。
|
||||
// 已有裁剪矩形时先与它求交,再设进 Graphics(region 天然支持这种"挖洞"裁剪)。
|
||||
if (box->clip.Width > 0.0f && box->clip.Height > 0.0f)
|
||||
{
|
||||
region.Intersect(box->clip);
|
||||
|
||||
@@ -897,6 +897,13 @@ namespace jdi
|
||||
std::uint64_t key = 0; /**< 内容键(不一致即重建)。 */
|
||||
int width = 0; /**< 位图宽度(= 列表宽度)。 */
|
||||
int height = 0; /**< 位图高度(= 行高)。 */
|
||||
/**
|
||||
* @brief 本行文本的**墨迹矩形**(位图坐标;调试用)。
|
||||
*
|
||||
* ⚠️ 必须缓存:命中缓存的帧根本不会调用 `UiText`,绘制期的文本收集器自然收不到
|
||||
* 任何东西 —— 不缓存就会出现"第一帧有文本框、之后全部消失"。
|
||||
*/
|
||||
std::vector<gd::RectF> textRects;
|
||||
};
|
||||
|
||||
std::vector<RowBitmapCache> m_rowBitmapCache; /**< 与 `m_rows` 同序的行位图缓存。 */
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
// SignalPanel 实现分片 —— 本文件只包含 SignalPanel 的**成员函数定义**(纯代码搬移,行为与拆分前完全一致)。
|
||||
// SignalPanel 实现分片 —— 绘制:列表行(含行位图缓存)、样式区、筛选框、滚动条。
|
||||
//
|
||||
// 共用的常量与自由函数在 SignalPanelInternal.hpp(命名空间 `spdetail`,全部 inline)。
|
||||
// 分片按“职责”划分:核心(状态/布局/几何)、渲染、交互与编辑,见各文件名。
|
||||
// 共用的常量与工具函数在 SignalPanelInternal.hpp(命名空间 `spdetail`,全部 inline)。
|
||||
// 六个分片按**职责**划分:
|
||||
// SignalPanel.cpp 核心:状态、行集合、布局与几何、可见性
|
||||
// SignalPanelPaint.cpp 绘制:列表行(含行位图缓存)、样式区、筛选框、滚动条(**本文件**)
|
||||
// SignalPanelInteraction.cpp 交互:命中测试、鼠标/键盘派发、光标形状
|
||||
// SignalPanelEdit.cpp 内联编辑:筛选框、组名/信号名、数值输入、颜色与透明度
|
||||
// SignalPanelScroll.cpp 动画与滚动:分组折起、联动滚动、"滚动到目标信号"
|
||||
// SignalPanelMenu.cpp 弹出菜单:系数/偏移、镜像、右键菜单与命令回执
|
||||
#include "SignalPanelInternal.hpp"
|
||||
|
||||
#include <cstring>
|
||||
@@ -9,6 +15,23 @@
|
||||
namespace jdi
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
/**
|
||||
* @brief 行位图渲染时使用的**临时**文本几何收集器(调试用)。
|
||||
*
|
||||
* 行的内容先画进位图再贴回屏幕,因此这里收到的是**位图坐标**;
|
||||
* `PaintRowCached` 会把它们连同位图一起缓存,并在贴图时按原点偏移回放给外层收集器。
|
||||
* ⚠️ 不缓存的话,"命中缓存的帧根本不调用 `UiText`",文本框会在第二帧全部消失。
|
||||
*/
|
||||
class RowTextCollector : public UiTextRectSink
|
||||
{
|
||||
public:
|
||||
void OnTextRect(const gd::RectF& rect) override { rects.push_back(rect); }
|
||||
std::vector<gd::RectF> rects; /**< 位图坐标下的文本墨迹矩形。 */
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void SignalPanel::PaintStickyGroupRow(gd::Graphics& g, int row)
|
||||
{
|
||||
if (row < 0 || row >= static_cast<int>(m_rows.size()) ||
|
||||
@@ -459,6 +482,15 @@ namespace jdi
|
||||
m_rowRenderActive = true;
|
||||
m_rowRenderOriginX = static_cast<float>(originX);
|
||||
m_rowRenderOriginY = static_cast<float>(originY);
|
||||
// 调试:把文本收集器临时指向一个**位图坐标**的本地容器(偏移 0),
|
||||
// 渲染完成后连同矩形一起存进缓存,命中缓存时再按原点偏移回放。
|
||||
// ⚠️ **无条件收集**(不管外层是否有收集器):行位图可能在任何一帧被渲染
|
||||
//(例如用户在关闭调试时滚动过列表),若只在"外层有收集器"时才收集,
|
||||
// 之后打开调试会命中缓存而永远拿不到文本框。收集成本只发生在**缓存未命中**的行上。
|
||||
UiTextRectSink* const outerSink = UiGetTextRectSink();
|
||||
RowTextCollector rowTextBoxes;
|
||||
UiSetTextRectSink(&rowTextBoxes);
|
||||
UiSetTextRectOffset(0.0f, 0.0f);
|
||||
m_rowClipRender = true;
|
||||
if (m_rows[static_cast<std::size_t>(row)].kind == RowKind::GROUP)
|
||||
{
|
||||
@@ -470,9 +502,22 @@ namespace jdi
|
||||
}
|
||||
m_rowClipRender = false;
|
||||
m_rowRenderActive = false;
|
||||
cache.textRects = rowTextBoxes.rects;
|
||||
UiSetTextRectOffset(0.0f, 0.0f);
|
||||
UiSetTextRectSink(outerSink);
|
||||
}
|
||||
cache.key = key;
|
||||
}
|
||||
// 调试:把本行的文本框回放给外层收集器(缓存命中 / 刚渲染两条路共用这一段)。
|
||||
if (UiTextRectSink* const outerSink = UiGetTextRectSink())
|
||||
{
|
||||
for (const gd::RectF& textRect : cache.textRects)
|
||||
{
|
||||
outerSink->OnTextRect(gd::RectF(textRect.X + static_cast<float>(originX),
|
||||
textRect.Y + static_cast<float>(originY),
|
||||
textRect.Width, textRect.Height));
|
||||
}
|
||||
}
|
||||
// ⚠️ 整块 1:1 搬运(不经过 GDI+ 采样/混合),字的亚像素边缘才能原样保留。
|
||||
// ⚠️ **必须自己给 DC 设裁剪**:`Graphics::GetHDC()` 交给我们的 DC 上,(a) GDI 绘制
|
||||
// 不受 GDI+ `SetClip` 的约束(这是本文件多处注释过的坑),(b) 折起/展开动画时行会
|
||||
|
||||
Reference in new issue
Block a user