性能优化
性能优化20261030-submit
This commit is contained in:
+13
-8
@@ -72,21 +72,26 @@ def compute_grid(width: int, height: int, feather: int):
|
||||
"""块数与块内容尺寸(在【原图】上切块)。
|
||||
|
||||
块内容尺寸(**不含羽化**)反解列/行数,使其尽量落在 [TILE_MIN, TILE_MAX];
|
||||
相邻块的重叠量 = `feather`(由 tile_batch 的 overlap 参数保证),不计入块尺寸
|
||||
—— 这样 feather 只控制接缝羽化宽度、不再撑大块尺寸(旧实现把 feather 加进块
|
||||
尺寸,导致 f=128 时块越界、有效羽化被整数除法反向截断)。
|
||||
相邻块的重叠量 = `feather`(由 tile_batch 的 overlap 参数保证)。
|
||||
|
||||
原图宽高均 ≤ TILE_MAX 时整图直喂(cols=rows=1,块=原图尺寸)。
|
||||
_pick_cols 与 _content_for 均以 `width + feather` / `height + feather` 为
|
||||
输入,保证 _layout 的 step = block - feather 恰好让 cols 块覆盖整条边:
|
||||
(cols-1) * (block - feather) + block >= width
|
||||
旧实现只给 _content_for 的 width 加了 feather,但 _pick_cols 仍用裸 width
|
||||
选列数,导致列数与块尺寸不匹配(1440px + f=64 → 选 2 列 → block=720 →
|
||||
step=656 → 实际需要 3 列)。
|
||||
|
||||
原图宽高均 <= TILE_MAX 时整图直喂(cols=rows=1,块=原图尺寸)。
|
||||
|
||||
返回的 cols/rows 与 tile_batch 经 `_layout(..., overlap=feather)` 算出的真实
|
||||
块数一致(两者共用同一套几何),规划面板显示的块数不再偏大(旧 P3)。
|
||||
"""
|
||||
if width <= TILE_MAX and height <= TILE_MAX:
|
||||
return 1, 1, width, height
|
||||
cols_content = _pick_cols(width, TILE_MIN, TILE_MAX)
|
||||
rows_content = _pick_cols(height, TILE_MIN, TILE_MAX)
|
||||
block_w = _content_for(width, cols_content)
|
||||
block_h = _content_for(height, rows_content)
|
||||
cols_content = _pick_cols(width + feather, TILE_MIN, TILE_MAX)
|
||||
rows_content = _pick_cols(height + feather, TILE_MIN, TILE_MAX)
|
||||
block_w = _content_for(width + feather, cols_content)
|
||||
block_h = _content_for(height + feather, rows_content)
|
||||
# 真实块数:与 tile_batch 共用 _layout(overlap=feather),面板与推理严格一致
|
||||
ncols, _ = ttp._layout(width, block_w, feather)
|
||||
nrows, _ = ttp._layout(height, block_h, feather)
|
||||
|
||||
Reference in New Issue
Block a user