* Compute a balanced column layout for threads. * * @param heights – Estimated pixel height for each thread (in display order). * @param numColumns – Maximum number of columns to distribute into. * @param flexOrder – When true, threads may be reordered across columns for * b
(
heights: number[],
numColumns: number,
flexOrder: boolean = false,
)
| 2703 | * thread indices. Empty columns are omitted. |
| 2704 | */ |
| 2705 | function computeThreadColumnLayout( |
| 2706 | heights: number[], |
| 2707 | numColumns: number, |
| 2708 | flexOrder: boolean = false, |
| 2709 | ): number[][] { |
| 2710 | if (heights.length === 0) return []; |
| 2711 | if (heights.length === 1) return [[0]]; |
| 2712 | |
| 2713 | const cols = Math.min(numColumns, heights.length); |
| 2714 | if (cols <= 1) return [heights.map((_, i) => i)]; |
| 2715 | |
| 2716 | return flexOrder |
| 2717 | ? layoutFlexOrder(heights, cols) |
| 2718 | : layoutPreserveOrder(heights, cols); |
| 2719 | } |
| 2720 | |
| 2721 | /** |
| 2722 | * Balanced layout *with* reordering (LPT – Longest Processing Time first). |
no test coverage detected